babylon.d.txt 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299
  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. let Epsilon: number;
  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 Color3 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. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. 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;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. 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;
  3178. /**
  3179. * Creates a new matrix 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. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * 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"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * 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".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * 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"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * 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".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * 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.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * 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.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * 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).
  4323. * 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.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @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.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** 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 */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** 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 */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** 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 */
  4494. static readonly GEQUAL: number;
  4495. /** 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 */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * 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.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * 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.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Class used to store and describe the pipeline context associated with an effect
  5217. */
  5218. export interface IPipelineContext {
  5219. /**
  5220. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5221. */
  5222. isAsync: boolean;
  5223. /**
  5224. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5225. */
  5226. isReady: boolean;
  5227. }
  5228. }
  5229. declare module BABYLON {
  5230. /**
  5231. * Class used to store gfx data (like WebGLBuffer)
  5232. */
  5233. export class DataBuffer {
  5234. /**
  5235. * Gets or sets the number of objects referencing this buffer
  5236. */
  5237. references: number;
  5238. /** Gets or sets the size of the underlying buffer */
  5239. capacity: number;
  5240. /**
  5241. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5242. */
  5243. is32Bits: boolean;
  5244. /**
  5245. * Gets the underlying buffer
  5246. */
  5247. readonly underlyingResource: any;
  5248. }
  5249. }
  5250. declare module BABYLON {
  5251. /**
  5252. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5253. */
  5254. export class PerformanceMonitor {
  5255. private _enabled;
  5256. private _rollingFrameTime;
  5257. private _lastFrameTimeMs;
  5258. /**
  5259. * constructor
  5260. * @param frameSampleSize The number of samples required to saturate the sliding window
  5261. */
  5262. constructor(frameSampleSize?: number);
  5263. /**
  5264. * Samples current frame
  5265. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5266. */
  5267. sampleFrame(timeMs?: number): void;
  5268. /**
  5269. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5270. */
  5271. readonly averageFrameTime: number;
  5272. /**
  5273. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5274. */
  5275. readonly averageFrameTimeVariance: number;
  5276. /**
  5277. * Returns the frame time of the most recent frame
  5278. */
  5279. readonly instantaneousFrameTime: number;
  5280. /**
  5281. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5282. */
  5283. readonly averageFPS: number;
  5284. /**
  5285. * Returns the average framerate in frames per second using the most recent frame time
  5286. */
  5287. readonly instantaneousFPS: number;
  5288. /**
  5289. * Returns true if enough samples have been taken to completely fill the sliding window
  5290. */
  5291. readonly isSaturated: boolean;
  5292. /**
  5293. * Enables contributions to the sliding window sample set
  5294. */
  5295. enable(): void;
  5296. /**
  5297. * Disables contributions to the sliding window sample set
  5298. * Samples will not be interpolated over the disabled period
  5299. */
  5300. disable(): void;
  5301. /**
  5302. * Returns true if sampling is enabled
  5303. */
  5304. readonly isEnabled: boolean;
  5305. /**
  5306. * Resets performance monitor
  5307. */
  5308. reset(): void;
  5309. }
  5310. /**
  5311. * RollingAverage
  5312. *
  5313. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5314. */
  5315. export class RollingAverage {
  5316. /**
  5317. * Current average
  5318. */
  5319. average: number;
  5320. /**
  5321. * Current variance
  5322. */
  5323. variance: number;
  5324. protected _samples: Array<number>;
  5325. protected _sampleCount: number;
  5326. protected _pos: number;
  5327. protected _m2: number;
  5328. /**
  5329. * constructor
  5330. * @param length The number of samples required to saturate the sliding window
  5331. */
  5332. constructor(length: number);
  5333. /**
  5334. * Adds a sample to the sample set
  5335. * @param v The sample value
  5336. */
  5337. add(v: number): void;
  5338. /**
  5339. * Returns previously added values or null if outside of history or outside the sliding window domain
  5340. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5341. * @return Value previously recorded with add() or null if outside of range
  5342. */
  5343. history(i: number): number;
  5344. /**
  5345. * Returns true if enough samples have been taken to completely fill the sliding window
  5346. * @return true if sample-set saturated
  5347. */
  5348. isSaturated(): boolean;
  5349. /**
  5350. * Resets the rolling average (equivalent to 0 samples taken so far)
  5351. */
  5352. reset(): void;
  5353. /**
  5354. * Wraps a value around the sample range boundaries
  5355. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5356. * @return Wrapped position in sample range
  5357. */
  5358. protected _wrapPosition(i: number): number;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /**
  5363. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5364. * The underlying implementation relies on an associative array to ensure the best performances.
  5365. * The value can be anything including 'null' but except 'undefined'
  5366. */
  5367. export class StringDictionary<T> {
  5368. /**
  5369. * This will clear this dictionary and copy the content from the 'source' one.
  5370. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5371. * @param source the dictionary to take the content from and copy to this dictionary
  5372. */
  5373. copyFrom(source: StringDictionary<T>): void;
  5374. /**
  5375. * Get a value based from its key
  5376. * @param key the given key to get the matching value from
  5377. * @return the value if found, otherwise undefined is returned
  5378. */
  5379. get(key: string): T | undefined;
  5380. /**
  5381. * Get a value from its key or add it if it doesn't exist.
  5382. * This method will ensure you that a given key/data will be present in the dictionary.
  5383. * @param key the given key to get the matching value from
  5384. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5385. * The factory will only be invoked if there's no data for the given key.
  5386. * @return the value corresponding to the key.
  5387. */
  5388. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5389. /**
  5390. * Get a value from its key if present in the dictionary otherwise add it
  5391. * @param key the key to get the value from
  5392. * @param val if there's no such key/value pair in the dictionary add it with this value
  5393. * @return the value corresponding to the key
  5394. */
  5395. getOrAdd(key: string, val: T): T;
  5396. /**
  5397. * Check if there's a given key in the dictionary
  5398. * @param key the key to check for
  5399. * @return true if the key is present, false otherwise
  5400. */
  5401. contains(key: string): boolean;
  5402. /**
  5403. * Add a new key and its corresponding value
  5404. * @param key the key to add
  5405. * @param value the value corresponding to the key
  5406. * @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
  5407. */
  5408. add(key: string, value: T): boolean;
  5409. /**
  5410. * Update a specific value associated to a key
  5411. * @param key defines the key to use
  5412. * @param value defines the value to store
  5413. * @returns true if the value was updated (or false if the key was not found)
  5414. */
  5415. set(key: string, value: T): boolean;
  5416. /**
  5417. * Get the element of the given key and remove it from the dictionary
  5418. * @param key defines the key to search
  5419. * @returns the value associated with the key or null if not found
  5420. */
  5421. getAndRemove(key: string): Nullable<T>;
  5422. /**
  5423. * Remove a key/value from the dictionary.
  5424. * @param key the key to remove
  5425. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5426. */
  5427. remove(key: string): boolean;
  5428. /**
  5429. * Clear the whole content of the dictionary
  5430. */
  5431. clear(): void;
  5432. /**
  5433. * Gets the current count
  5434. */
  5435. readonly count: number;
  5436. /**
  5437. * Execute a callback on each key/val of the dictionary.
  5438. * Note that you can remove any element in this dictionary in the callback implementation
  5439. * @param callback the callback to execute on a given key/value pair
  5440. */
  5441. forEach(callback: (key: string, val: T) => void): void;
  5442. /**
  5443. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5444. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5445. * Note that you can remove any element in this dictionary in the callback implementation
  5446. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5447. * @returns the first item
  5448. */
  5449. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5450. private _count;
  5451. private _data;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. /**
  5456. * Helper class that provides a small promise polyfill
  5457. */
  5458. export class PromisePolyfill {
  5459. /**
  5460. * Static function used to check if the polyfill is required
  5461. * If this is the case then the function will inject the polyfill to window.Promise
  5462. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5463. */
  5464. static Apply(force?: boolean): void;
  5465. }
  5466. }
  5467. declare module BABYLON {
  5468. /**
  5469. * Class used to store data that will be store in GPU memory
  5470. */
  5471. export class Buffer {
  5472. private _engine;
  5473. private _buffer;
  5474. /** @hidden */ data: Nullable<DataArray>;
  5475. private _updatable;
  5476. private _instanced;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Constructor
  5483. * @param engine the engine
  5484. * @param data the data to use for this buffer
  5485. * @param updatable whether the data is updatable
  5486. * @param stride the stride (optional)
  5487. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5488. * @param instanced whether the buffer is instanced (optional)
  5489. * @param useBytes set to true if the stride in in bytes (optional)
  5490. */
  5491. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5492. /**
  5493. * Create a new VertexBuffer based on the current buffer
  5494. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5495. * @param offset defines offset in the buffer (0 by default)
  5496. * @param size defines the size in floats of attributes (position is 3 for instance)
  5497. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5498. * @param instanced defines if the vertex buffer contains indexed data
  5499. * @param useBytes defines if the offset and stride are in bytes
  5500. * @returns the new vertex buffer
  5501. */
  5502. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5503. /**
  5504. * Gets a boolean indicating if the Buffer is updatable?
  5505. * @returns true if the buffer is updatable
  5506. */
  5507. isUpdatable(): boolean;
  5508. /**
  5509. * Gets current buffer's data
  5510. * @returns a DataArray or null
  5511. */
  5512. getData(): Nullable<DataArray>;
  5513. /**
  5514. * Gets underlying native buffer
  5515. * @returns underlying native buffer
  5516. */
  5517. getBuffer(): Nullable<DataBuffer>;
  5518. /**
  5519. * Gets the stride in float32 units (i.e. byte stride / 4).
  5520. * May not be an integer if the byte stride is not divisible by 4.
  5521. * DEPRECATED. Use byteStride instead.
  5522. * @returns the stride in float32 units
  5523. */
  5524. getStrideSize(): number;
  5525. /**
  5526. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5527. * @param data defines the data to store
  5528. */
  5529. create(data?: Nullable<DataArray>): void;
  5530. /** @hidden */ rebuild(): void;
  5531. /**
  5532. * Update current buffer data
  5533. * @param data defines the data to store
  5534. */
  5535. update(data: DataArray): void;
  5536. /**
  5537. * Updates the data directly.
  5538. * @param data the new data
  5539. * @param offset the new offset
  5540. * @param vertexCount the vertex count (optional)
  5541. * @param useBytes set to true if the offset is in bytes
  5542. */
  5543. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5544. /**
  5545. * Release all resources
  5546. */
  5547. dispose(): void;
  5548. }
  5549. /**
  5550. * Specialized buffer used to store vertex data
  5551. */
  5552. export class VertexBuffer {
  5553. /** @hidden */ buffer: Buffer;
  5554. private _kind;
  5555. private _size;
  5556. private _ownsBuffer;
  5557. private _instanced;
  5558. private _instanceDivisor;
  5559. /**
  5560. * The byte type.
  5561. */
  5562. static readonly BYTE: number;
  5563. /**
  5564. * The unsigned byte type.
  5565. */
  5566. static readonly UNSIGNED_BYTE: number;
  5567. /**
  5568. * The short type.
  5569. */
  5570. static readonly SHORT: number;
  5571. /**
  5572. * The unsigned short type.
  5573. */
  5574. static readonly UNSIGNED_SHORT: number;
  5575. /**
  5576. * The integer type.
  5577. */
  5578. static readonly INT: number;
  5579. /**
  5580. * The unsigned integer type.
  5581. */
  5582. static readonly UNSIGNED_INT: number;
  5583. /**
  5584. * The float type.
  5585. */
  5586. static readonly FLOAT: number;
  5587. /**
  5588. * Gets or sets the instance divisor when in instanced mode
  5589. */
  5590. instanceDivisor: number;
  5591. /**
  5592. * Gets the byte stride.
  5593. */
  5594. readonly byteStride: number;
  5595. /**
  5596. * Gets the byte offset.
  5597. */
  5598. readonly byteOffset: number;
  5599. /**
  5600. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5601. */
  5602. readonly normalized: boolean;
  5603. /**
  5604. * Gets the data type of each component in the array.
  5605. */
  5606. readonly type: number;
  5607. /**
  5608. * Constructor
  5609. * @param engine the engine
  5610. * @param data the data to use for this vertex buffer
  5611. * @param kind the vertex buffer kind
  5612. * @param updatable whether the data is updatable
  5613. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5614. * @param stride the stride (optional)
  5615. * @param instanced whether the buffer is instanced (optional)
  5616. * @param offset the offset of the data (optional)
  5617. * @param size the number of components (optional)
  5618. * @param type the type of the component (optional)
  5619. * @param normalized whether the data contains normalized data (optional)
  5620. * @param useBytes set to true if stride and offset are in bytes (optional)
  5621. */
  5622. 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);
  5623. /** @hidden */ rebuild(): void;
  5624. /**
  5625. * Returns the kind of the VertexBuffer (string)
  5626. * @returns a string
  5627. */
  5628. getKind(): string;
  5629. /**
  5630. * Gets a boolean indicating if the VertexBuffer is updatable?
  5631. * @returns true if the buffer is updatable
  5632. */
  5633. isUpdatable(): boolean;
  5634. /**
  5635. * Gets current buffer's data
  5636. * @returns a DataArray or null
  5637. */
  5638. getData(): Nullable<DataArray>;
  5639. /**
  5640. * Gets underlying native buffer
  5641. * @returns underlying native buffer
  5642. */
  5643. getBuffer(): Nullable<DataBuffer>;
  5644. /**
  5645. * Gets the stride in float32 units (i.e. byte stride / 4).
  5646. * May not be an integer if the byte stride is not divisible by 4.
  5647. * DEPRECATED. Use byteStride instead.
  5648. * @returns the stride in float32 units
  5649. */
  5650. getStrideSize(): number;
  5651. /**
  5652. * Returns the offset as a multiple of the type byte length.
  5653. * DEPRECATED. Use byteOffset instead.
  5654. * @returns the offset in bytes
  5655. */
  5656. getOffset(): number;
  5657. /**
  5658. * Returns the number of components per vertex attribute (integer)
  5659. * @returns the size in float
  5660. */
  5661. getSize(): number;
  5662. /**
  5663. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5664. * @returns true if this buffer is instanced
  5665. */
  5666. getIsInstanced(): boolean;
  5667. /**
  5668. * Returns the instancing divisor, zero for non-instanced (integer).
  5669. * @returns a number
  5670. */
  5671. getInstanceDivisor(): number;
  5672. /**
  5673. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5674. * @param data defines the data to store
  5675. */
  5676. create(data?: DataArray): void;
  5677. /**
  5678. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5679. * This function will create a new buffer if the current one is not updatable
  5680. * @param data defines the data to store
  5681. */
  5682. update(data: DataArray): void;
  5683. /**
  5684. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5685. * Returns the directly updated WebGLBuffer.
  5686. * @param data the new data
  5687. * @param offset the new offset
  5688. * @param useBytes set to true if the offset is in bytes
  5689. */
  5690. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5691. /**
  5692. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5693. */
  5694. dispose(): void;
  5695. /**
  5696. * Enumerates each value of this vertex buffer as numbers.
  5697. * @param count the number of values to enumerate
  5698. * @param callback the callback function called for each value
  5699. */
  5700. forEach(count: number, callback: (value: number, index: number) => void): void;
  5701. /**
  5702. * Positions
  5703. */
  5704. static readonly PositionKind: string;
  5705. /**
  5706. * Normals
  5707. */
  5708. static readonly NormalKind: string;
  5709. /**
  5710. * Tangents
  5711. */
  5712. static readonly TangentKind: string;
  5713. /**
  5714. * Texture coordinates
  5715. */
  5716. static readonly UVKind: string;
  5717. /**
  5718. * Texture coordinates 2
  5719. */
  5720. static readonly UV2Kind: string;
  5721. /**
  5722. * Texture coordinates 3
  5723. */
  5724. static readonly UV3Kind: string;
  5725. /**
  5726. * Texture coordinates 4
  5727. */
  5728. static readonly UV4Kind: string;
  5729. /**
  5730. * Texture coordinates 5
  5731. */
  5732. static readonly UV5Kind: string;
  5733. /**
  5734. * Texture coordinates 6
  5735. */
  5736. static readonly UV6Kind: string;
  5737. /**
  5738. * Colors
  5739. */
  5740. static readonly ColorKind: string;
  5741. /**
  5742. * Matrix indices (for bones)
  5743. */
  5744. static readonly MatricesIndicesKind: string;
  5745. /**
  5746. * Matrix weights (for bones)
  5747. */
  5748. static readonly MatricesWeightsKind: string;
  5749. /**
  5750. * Additional matrix indices (for bones)
  5751. */
  5752. static readonly MatricesIndicesExtraKind: string;
  5753. /**
  5754. * Additional matrix weights (for bones)
  5755. */
  5756. static readonly MatricesWeightsExtraKind: string;
  5757. /**
  5758. * Deduces the stride given a kind.
  5759. * @param kind The kind string to deduce
  5760. * @returns The deduced stride
  5761. */
  5762. static DeduceStride(kind: string): number;
  5763. /**
  5764. * Gets the byte length of the given type.
  5765. * @param type the type
  5766. * @returns the number of bytes
  5767. */
  5768. static GetTypeByteLength(type: number): number;
  5769. /**
  5770. * Enumerates each value of the given parameters as numbers.
  5771. * @param data the data to enumerate
  5772. * @param byteOffset the byte offset of the data
  5773. * @param byteStride the byte stride of the data
  5774. * @param componentCount the number of components per element
  5775. * @param componentType the type of the component
  5776. * @param count the total number of components
  5777. * @param normalized whether the data is normalized
  5778. * @param callback the callback function called for each value
  5779. */
  5780. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5781. private static _GetFloatValue;
  5782. }
  5783. }
  5784. declare module BABYLON {
  5785. /**
  5786. * Class representing spherical polynomial coefficients to the 3rd degree
  5787. */
  5788. export class SphericalPolynomial {
  5789. /**
  5790. * The x coefficients of the spherical polynomial
  5791. */
  5792. x: Vector3;
  5793. /**
  5794. * The y coefficients of the spherical polynomial
  5795. */
  5796. y: Vector3;
  5797. /**
  5798. * The z coefficients of the spherical polynomial
  5799. */
  5800. z: Vector3;
  5801. /**
  5802. * The xx coefficients of the spherical polynomial
  5803. */
  5804. xx: Vector3;
  5805. /**
  5806. * The yy coefficients of the spherical polynomial
  5807. */
  5808. yy: Vector3;
  5809. /**
  5810. * The zz coefficients of the spherical polynomial
  5811. */
  5812. zz: Vector3;
  5813. /**
  5814. * The xy coefficients of the spherical polynomial
  5815. */
  5816. xy: Vector3;
  5817. /**
  5818. * The yz coefficients of the spherical polynomial
  5819. */
  5820. yz: Vector3;
  5821. /**
  5822. * The zx coefficients of the spherical polynomial
  5823. */
  5824. zx: Vector3;
  5825. /**
  5826. * Adds an ambient color to the spherical polynomial
  5827. * @param color the color to add
  5828. */
  5829. addAmbient(color: Color3): void;
  5830. /**
  5831. * Scales the spherical polynomial by the given amount
  5832. * @param scale the amount to scale
  5833. */
  5834. scale(scale: number): void;
  5835. /**
  5836. * Gets the spherical polynomial from harmonics
  5837. * @param harmonics the spherical harmonics
  5838. * @returns the spherical polynomial
  5839. */
  5840. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5841. /**
  5842. * Constructs a spherical polynomial from an array.
  5843. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5844. * @returns the spherical polynomial
  5845. */
  5846. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5847. }
  5848. /**
  5849. * Class representing spherical harmonics coefficients to the 3rd degree
  5850. */
  5851. export class SphericalHarmonics {
  5852. /**
  5853. * The l0,0 coefficients of the spherical harmonics
  5854. */
  5855. l00: Vector3;
  5856. /**
  5857. * The l1,-1 coefficients of the spherical harmonics
  5858. */
  5859. l1_1: Vector3;
  5860. /**
  5861. * The l1,0 coefficients of the spherical harmonics
  5862. */
  5863. l10: Vector3;
  5864. /**
  5865. * The l1,1 coefficients of the spherical harmonics
  5866. */
  5867. l11: Vector3;
  5868. /**
  5869. * The l2,-2 coefficients of the spherical harmonics
  5870. */
  5871. l2_2: Vector3;
  5872. /**
  5873. * The l2,-1 coefficients of the spherical harmonics
  5874. */
  5875. l2_1: Vector3;
  5876. /**
  5877. * The l2,0 coefficients of the spherical harmonics
  5878. */
  5879. l20: Vector3;
  5880. /**
  5881. * The l2,1 coefficients of the spherical harmonics
  5882. */
  5883. l21: Vector3;
  5884. /**
  5885. * The l2,2 coefficients of the spherical harmonics
  5886. */
  5887. lL22: Vector3;
  5888. /**
  5889. * Adds a light to the spherical harmonics
  5890. * @param direction the direction of the light
  5891. * @param color the color of the light
  5892. * @param deltaSolidAngle the delta solid angle of the light
  5893. */
  5894. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5895. /**
  5896. * Scales the spherical harmonics by the given amount
  5897. * @param scale the amount to scale
  5898. */
  5899. scale(scale: number): void;
  5900. /**
  5901. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5902. *
  5903. * ```
  5904. * E_lm = A_l * L_lm
  5905. * ```
  5906. *
  5907. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5908. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5909. * the scaling factors are given in equation 9.
  5910. */
  5911. convertIncidentRadianceToIrradiance(): void;
  5912. /**
  5913. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5914. *
  5915. * ```
  5916. * L = (1/pi) * E * rho
  5917. * ```
  5918. *
  5919. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5920. */
  5921. convertIrradianceToLambertianRadiance(): void;
  5922. /**
  5923. * Gets the spherical harmonics from polynomial
  5924. * @param polynomial the spherical polynomial
  5925. * @returns the spherical harmonics
  5926. */
  5927. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5928. /**
  5929. * Constructs a spherical harmonics from an array.
  5930. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5931. * @returns the spherical harmonics
  5932. */
  5933. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5939. */
  5940. export interface CubeMapInfo {
  5941. /**
  5942. * The pixel array for the front face.
  5943. * This is stored in format, left to right, up to down format.
  5944. */
  5945. front: Nullable<ArrayBufferView>;
  5946. /**
  5947. * The pixel array for the back face.
  5948. * This is stored in format, left to right, up to down format.
  5949. */
  5950. back: Nullable<ArrayBufferView>;
  5951. /**
  5952. * The pixel array for the left face.
  5953. * This is stored in format, left to right, up to down format.
  5954. */
  5955. left: Nullable<ArrayBufferView>;
  5956. /**
  5957. * The pixel array for the right face.
  5958. * This is stored in format, left to right, up to down format.
  5959. */
  5960. right: Nullable<ArrayBufferView>;
  5961. /**
  5962. * The pixel array for the up face.
  5963. * This is stored in format, left to right, up to down format.
  5964. */
  5965. up: Nullable<ArrayBufferView>;
  5966. /**
  5967. * The pixel array for the down face.
  5968. * This is stored in format, left to right, up to down format.
  5969. */
  5970. down: Nullable<ArrayBufferView>;
  5971. /**
  5972. * The size of the cubemap stored.
  5973. *
  5974. * Each faces will be size * size pixels.
  5975. */
  5976. size: number;
  5977. /**
  5978. * The format of the texture.
  5979. *
  5980. * RGBA, RGB.
  5981. */
  5982. format: number;
  5983. /**
  5984. * The type of the texture data.
  5985. *
  5986. * UNSIGNED_INT, FLOAT.
  5987. */
  5988. type: number;
  5989. /**
  5990. * Specifies whether the texture is in gamma space.
  5991. */
  5992. gammaSpace: boolean;
  5993. }
  5994. /**
  5995. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5996. */
  5997. export class PanoramaToCubeMapTools {
  5998. private static FACE_FRONT;
  5999. private static FACE_BACK;
  6000. private static FACE_RIGHT;
  6001. private static FACE_LEFT;
  6002. private static FACE_DOWN;
  6003. private static FACE_UP;
  6004. /**
  6005. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6006. *
  6007. * @param float32Array The source data.
  6008. * @param inputWidth The width of the input panorama.
  6009. * @param inputHeight The height of the input panorama.
  6010. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6011. * @return The cubemap data
  6012. */
  6013. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6014. private static CreateCubemapTexture;
  6015. private static CalcProjectionSpherical;
  6016. }
  6017. }
  6018. declare module BABYLON {
  6019. /**
  6020. * Helper class dealing with the extraction of spherical polynomial dataArray
  6021. * from a cube map.
  6022. */
  6023. export class CubeMapToSphericalPolynomialTools {
  6024. private static FileFaces;
  6025. /**
  6026. * Converts a texture to the according Spherical Polynomial data.
  6027. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6028. *
  6029. * @param texture The texture to extract the information from.
  6030. * @return The Spherical Polynomial data.
  6031. */
  6032. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6033. /**
  6034. * Converts a cubemap to the according Spherical Polynomial data.
  6035. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6036. *
  6037. * @param cubeInfo The Cube map to extract the information from.
  6038. * @return The Spherical Polynomial data.
  6039. */
  6040. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6046. * during the life time of the application.
  6047. */
  6048. export class EngineStore {
  6049. /** Gets the list of created engines */
  6050. static Instances: Engine[];
  6051. /**
  6052. * Gets the latest created engine
  6053. */
  6054. static readonly LastCreatedEngine: Nullable<Engine>;
  6055. /**
  6056. * Gets the latest created scene
  6057. */
  6058. static readonly LastCreatedScene: Nullable<Scene>;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * Define options used to create a render target texture
  6064. */
  6065. export class RenderTargetCreationOptions {
  6066. /**
  6067. * Specifies is mipmaps must be generated
  6068. */
  6069. generateMipMaps?: boolean;
  6070. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6071. generateDepthBuffer?: boolean;
  6072. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6073. generateStencilBuffer?: boolean;
  6074. /** Defines texture type (int by default) */
  6075. type?: number;
  6076. /** Defines sampling mode (trilinear by default) */
  6077. samplingMode?: number;
  6078. /** Defines format (RGBA by default) */
  6079. format?: number;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * @hidden
  6085. **/
  6086. export class _AlphaState {
  6087. private _isAlphaBlendDirty;
  6088. private _isBlendFunctionParametersDirty;
  6089. private _isBlendEquationParametersDirty;
  6090. private _isBlendConstantsDirty;
  6091. private _alphaBlend;
  6092. private _blendFunctionParameters;
  6093. private _blendEquationParameters;
  6094. private _blendConstants;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. alphaBlend: boolean;
  6101. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6102. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6103. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6104. reset(): void;
  6105. apply(gl: WebGLRenderingContext): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * @hidden
  6111. **/
  6112. export class _DepthCullingState {
  6113. private _isDepthTestDirty;
  6114. private _isDepthMaskDirty;
  6115. private _isDepthFuncDirty;
  6116. private _isCullFaceDirty;
  6117. private _isCullDirty;
  6118. private _isZOffsetDirty;
  6119. private _isFrontFaceDirty;
  6120. private _depthTest;
  6121. private _depthMask;
  6122. private _depthFunc;
  6123. private _cull;
  6124. private _cullFace;
  6125. private _zOffset;
  6126. private _frontFace;
  6127. /**
  6128. * Initializes the state.
  6129. */
  6130. constructor();
  6131. readonly isDirty: boolean;
  6132. zOffset: number;
  6133. cullFace: Nullable<number>;
  6134. cull: Nullable<boolean>;
  6135. depthFunc: Nullable<number>;
  6136. depthMask: boolean;
  6137. depthTest: boolean;
  6138. frontFace: Nullable<number>;
  6139. reset(): void;
  6140. apply(gl: WebGLRenderingContext): void;
  6141. }
  6142. }
  6143. declare module BABYLON {
  6144. /**
  6145. * @hidden
  6146. **/
  6147. export class _StencilState {
  6148. /** 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 */
  6149. static readonly ALWAYS: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be kept */
  6151. static readonly KEEP: number;
  6152. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6153. static readonly REPLACE: number;
  6154. private _isStencilTestDirty;
  6155. private _isStencilMaskDirty;
  6156. private _isStencilFuncDirty;
  6157. private _isStencilOpDirty;
  6158. private _stencilTest;
  6159. private _stencilMask;
  6160. private _stencilFunc;
  6161. private _stencilFuncRef;
  6162. private _stencilFuncMask;
  6163. private _stencilOpStencilFail;
  6164. private _stencilOpDepthFail;
  6165. private _stencilOpStencilDepthPass;
  6166. readonly isDirty: boolean;
  6167. stencilFunc: number;
  6168. stencilFuncRef: number;
  6169. stencilFuncMask: number;
  6170. stencilOpStencilFail: number;
  6171. stencilOpDepthFail: number;
  6172. stencilOpStencilDepthPass: number;
  6173. stencilMask: number;
  6174. stencilTest: boolean;
  6175. constructor();
  6176. reset(): void;
  6177. apply(gl: WebGLRenderingContext): void;
  6178. }
  6179. }
  6180. declare module BABYLON {
  6181. /**
  6182. * @hidden
  6183. **/
  6184. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture {
  6193. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6194. /**
  6195. * The source of the texture data is unknown
  6196. */
  6197. static DATASOURCE_UNKNOWN: number;
  6198. /**
  6199. * Texture data comes from an URL
  6200. */
  6201. static DATASOURCE_URL: number;
  6202. /**
  6203. * Texture data is only used for temporary storage
  6204. */
  6205. static DATASOURCE_TEMP: number;
  6206. /**
  6207. * Texture data comes from raw data (ArrayBuffer)
  6208. */
  6209. static DATASOURCE_RAW: number;
  6210. /**
  6211. * Texture content is dynamic (video or dynamic texture)
  6212. */
  6213. static DATASOURCE_DYNAMIC: number;
  6214. /**
  6215. * Texture content is generated by rendering to it
  6216. */
  6217. static DATASOURCE_RENDERTARGET: number;
  6218. /**
  6219. * Texture content is part of a multi render target process
  6220. */
  6221. static DATASOURCE_MULTIRENDERTARGET: number;
  6222. /**
  6223. * Texture data comes from a cube data file
  6224. */
  6225. static DATASOURCE_CUBE: number;
  6226. /**
  6227. * Texture data comes from a raw cube data
  6228. */
  6229. static DATASOURCE_CUBERAW: number;
  6230. /**
  6231. * Texture data come from a prefiltered cube data file
  6232. */
  6233. static DATASOURCE_CUBEPREFILTERED: number;
  6234. /**
  6235. * Texture content is raw 3D data
  6236. */
  6237. static DATASOURCE_RAW3D: number;
  6238. /**
  6239. * Texture content is a depth texture
  6240. */
  6241. static DATASOURCE_DEPTHTEXTURE: number;
  6242. /**
  6243. * Texture data comes from a raw cube data encoded with RGBD
  6244. */
  6245. static DATASOURCE_CUBERAW_RGBD: number;
  6246. /**
  6247. * Defines if the texture is ready
  6248. */
  6249. isReady: boolean;
  6250. /**
  6251. * Defines if the texture is a cube texture
  6252. */
  6253. isCube: boolean;
  6254. /**
  6255. * Defines if the texture contains 3D data
  6256. */
  6257. is3D: boolean;
  6258. /**
  6259. * Defines if the texture contains multiview data
  6260. */
  6261. isMultiview: boolean;
  6262. /**
  6263. * Gets the URL used to load this texture
  6264. */
  6265. url: string;
  6266. /**
  6267. * Gets the sampling mode of the texture
  6268. */
  6269. samplingMode: number;
  6270. /**
  6271. * Gets a boolean indicating if the texture needs mipmaps generation
  6272. */
  6273. generateMipMaps: boolean;
  6274. /**
  6275. * Gets the number of samples used by the texture (WebGL2+ only)
  6276. */
  6277. samples: number;
  6278. /**
  6279. * Gets the type of the texture (int, float...)
  6280. */
  6281. type: number;
  6282. /**
  6283. * Gets the format of the texture (RGB, RGBA...)
  6284. */
  6285. format: number;
  6286. /**
  6287. * Observable called when the texture is loaded
  6288. */
  6289. onLoadedObservable: Observable<InternalTexture>;
  6290. /**
  6291. * Gets the width of the texture
  6292. */
  6293. width: number;
  6294. /**
  6295. * Gets the height of the texture
  6296. */
  6297. height: number;
  6298. /**
  6299. * Gets the depth of the texture
  6300. */
  6301. depth: number;
  6302. /**
  6303. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6304. */
  6305. baseWidth: number;
  6306. /**
  6307. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6308. */
  6309. baseHeight: number;
  6310. /**
  6311. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6312. */
  6313. baseDepth: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture is inverted on Y axis
  6316. */
  6317. invertY: boolean;
  6318. /** @hidden */ invertVScale: boolean;
  6319. /** @hidden */ associatedChannel: number;
  6320. /** @hidden */ dataSource: number;
  6321. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6322. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6323. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6324. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6325. /** @hidden */ size: number;
  6326. /** @hidden */ extension: string;
  6327. /** @hidden */ files: Nullable<string[]>;
  6328. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6329. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6330. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6331. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6332. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6333. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6334. /** @hidden */ attachments: Nullable<number[]>;
  6335. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6336. /** @hidden */ cachedWrapU: Nullable<number>;
  6337. /** @hidden */ cachedWrapV: Nullable<number>;
  6338. /** @hidden */ cachedWrapR: Nullable<number>;
  6339. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6340. /** @hidden */ isDisabled: boolean;
  6341. /** @hidden */ compression: Nullable<string>;
  6342. /** @hidden */ generateStencilBuffer: boolean;
  6343. /** @hidden */ generateDepthBuffer: boolean;
  6344. /** @hidden */ comparisonFunction: number;
  6345. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6346. /** @hidden */ lodGenerationScale: number;
  6347. /** @hidden */ lodGenerationOffset: number;
  6348. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6349. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6350. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6351. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6352. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6353. /** @hidden */ isRGBD: boolean;
  6354. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6355. /** @hidden */ references: number;
  6356. private _engine;
  6357. /**
  6358. * Gets the Engine the texture belongs to.
  6359. * @returns The babylon engine
  6360. */
  6361. getEngine(): Engine;
  6362. /**
  6363. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6364. */
  6365. readonly dataSource: number;
  6366. /**
  6367. * Creates a new InternalTexture
  6368. * @param engine defines the engine to use
  6369. * @param dataSource defines the type of data that will be used
  6370. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6371. */
  6372. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6373. /**
  6374. * Increments the number of references (ie. the number of Texture that point to it)
  6375. */
  6376. incrementReferences(): void;
  6377. /**
  6378. * Change the size of the texture (not the size of the content)
  6379. * @param width defines the new width
  6380. * @param height defines the new height
  6381. * @param depth defines the new depth (1 by default)
  6382. */
  6383. updateSize(width: int, height: int, depth?: int): void;
  6384. /** @hidden */ rebuild(): void;
  6385. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6386. /**
  6387. * Dispose the current allocated resources
  6388. */
  6389. dispose(): void;
  6390. }
  6391. }
  6392. declare module BABYLON {
  6393. /**
  6394. * This represents the main contract an easing function should follow.
  6395. * Easing functions are used throughout the animation system.
  6396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6397. */
  6398. export interface IEasingFunction {
  6399. /**
  6400. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6401. * of the easing function.
  6402. * The link below provides some of the most common examples of easing functions.
  6403. * @see https://easings.net/
  6404. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6405. * @returns the corresponding value on the curve defined by the easing function
  6406. */
  6407. ease(gradient: number): number;
  6408. }
  6409. /**
  6410. * Base class used for every default easing function.
  6411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6412. */
  6413. export class EasingFunction implements IEasingFunction {
  6414. /**
  6415. * Interpolation follows the mathematical formula associated with the easing function.
  6416. */
  6417. static readonly EASINGMODE_EASEIN: number;
  6418. /**
  6419. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6420. */
  6421. static readonly EASINGMODE_EASEOUT: number;
  6422. /**
  6423. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6424. */
  6425. static readonly EASINGMODE_EASEINOUT: number;
  6426. private _easingMode;
  6427. /**
  6428. * Sets the easing mode of the current function.
  6429. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6430. */
  6431. setEasingMode(easingMode: number): void;
  6432. /**
  6433. * Gets the current easing mode.
  6434. * @returns the easing mode
  6435. */
  6436. getEasingMode(): number;
  6437. /**
  6438. * @hidden
  6439. */
  6440. easeInCore(gradient: number): number;
  6441. /**
  6442. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6443. * of the easing function.
  6444. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6445. * @returns the corresponding value on the curve defined by the easing function
  6446. */
  6447. ease(gradient: number): number;
  6448. }
  6449. /**
  6450. * Easing function with a circle shape (see link below).
  6451. * @see https://easings.net/#easeInCirc
  6452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6453. */
  6454. export class CircleEase extends EasingFunction implements IEasingFunction {
  6455. /** @hidden */
  6456. easeInCore(gradient: number): number;
  6457. }
  6458. /**
  6459. * Easing function with a ease back shape (see link below).
  6460. * @see https://easings.net/#easeInBack
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export class BackEase extends EasingFunction implements IEasingFunction {
  6464. /** Defines the amplitude of the function */
  6465. amplitude: number;
  6466. /**
  6467. * Instantiates a back ease easing
  6468. * @see https://easings.net/#easeInBack
  6469. * @param amplitude Defines the amplitude of the function
  6470. */
  6471. constructor(
  6472. /** Defines the amplitude of the function */
  6473. amplitude?: number);
  6474. /** @hidden */
  6475. easeInCore(gradient: number): number;
  6476. }
  6477. /**
  6478. * Easing function with a bouncing shape (see link below).
  6479. * @see https://easings.net/#easeInBounce
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export class BounceEase extends EasingFunction implements IEasingFunction {
  6483. /** Defines the number of bounces */
  6484. bounces: number;
  6485. /** Defines the amplitude of the bounce */
  6486. bounciness: number;
  6487. /**
  6488. * Instantiates a bounce easing
  6489. * @see https://easings.net/#easeInBounce
  6490. * @param bounces Defines the number of bounces
  6491. * @param bounciness Defines the amplitude of the bounce
  6492. */
  6493. constructor(
  6494. /** Defines the number of bounces */
  6495. bounces?: number,
  6496. /** Defines the amplitude of the bounce */
  6497. bounciness?: number);
  6498. /** @hidden */
  6499. easeInCore(gradient: number): number;
  6500. }
  6501. /**
  6502. * Easing function with a power of 3 shape (see link below).
  6503. * @see https://easings.net/#easeInCubic
  6504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6505. */
  6506. export class CubicEase extends EasingFunction implements IEasingFunction {
  6507. /** @hidden */
  6508. easeInCore(gradient: number): number;
  6509. }
  6510. /**
  6511. * Easing function with an elastic shape (see link below).
  6512. * @see https://easings.net/#easeInElastic
  6513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6514. */
  6515. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6516. /** Defines the number of oscillations*/
  6517. oscillations: number;
  6518. /** Defines the amplitude of the oscillations*/
  6519. springiness: number;
  6520. /**
  6521. * Instantiates an elastic easing function
  6522. * @see https://easings.net/#easeInElastic
  6523. * @param oscillations Defines the number of oscillations
  6524. * @param springiness Defines the amplitude of the oscillations
  6525. */
  6526. constructor(
  6527. /** Defines the number of oscillations*/
  6528. oscillations?: number,
  6529. /** Defines the amplitude of the oscillations*/
  6530. springiness?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with an exponential shape (see link below).
  6536. * @see https://easings.net/#easeInExpo
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6540. /** Defines the exponent of the function */
  6541. exponent: number;
  6542. /**
  6543. * Instantiates an exponential easing function
  6544. * @see https://easings.net/#easeInExpo
  6545. * @param exponent Defines the exponent of the function
  6546. */
  6547. constructor(
  6548. /** Defines the exponent of the function */
  6549. exponent?: number);
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a power shape (see link below).
  6555. * @see https://easings.net/#easeInQuad
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class PowerEase extends EasingFunction implements IEasingFunction {
  6559. /** Defines the power of the function */
  6560. power: number;
  6561. /**
  6562. * Instantiates an power base easing function
  6563. * @see https://easings.net/#easeInQuad
  6564. * @param power Defines the power of the function
  6565. */
  6566. constructor(
  6567. /** Defines the power of the function */
  6568. power?: number);
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a power of 2 shape (see link below).
  6574. * @see https://easings.net/#easeInQuad
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6578. /** @hidden */
  6579. easeInCore(gradient: number): number;
  6580. }
  6581. /**
  6582. * Easing function with a power of 4 shape (see link below).
  6583. * @see https://easings.net/#easeInQuart
  6584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6585. */
  6586. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a power of 5 shape (see link below).
  6592. * @see https://easings.net/#easeInQuint
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with a sin shape (see link below).
  6601. * @see https://easings.net/#easeInSine
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class SineEase extends EasingFunction implements IEasingFunction {
  6605. /** @hidden */
  6606. easeInCore(gradient: number): number;
  6607. }
  6608. /**
  6609. * Easing function with a bezier shape (see link below).
  6610. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6612. */
  6613. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6614. /** Defines the x component of the start tangent in the bezier curve */
  6615. x1: number;
  6616. /** Defines the y component of the start tangent in the bezier curve */
  6617. y1: number;
  6618. /** Defines the x component of the end tangent in the bezier curve */
  6619. x2: number;
  6620. /** Defines the y component of the end tangent in the bezier curve */
  6621. y2: number;
  6622. /**
  6623. * Instantiates a bezier function
  6624. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6625. * @param x1 Defines the x component of the start tangent in the bezier curve
  6626. * @param y1 Defines the y component of the start tangent in the bezier curve
  6627. * @param x2 Defines the x component of the end tangent in the bezier curve
  6628. * @param y2 Defines the y component of the end tangent in the bezier curve
  6629. */
  6630. constructor(
  6631. /** Defines the x component of the start tangent in the bezier curve */
  6632. x1?: number,
  6633. /** Defines the y component of the start tangent in the bezier curve */
  6634. y1?: number,
  6635. /** Defines the x component of the end tangent in the bezier curve */
  6636. x2?: number,
  6637. /** Defines the y component of the end tangent in the bezier curve */
  6638. y2?: number);
  6639. /** @hidden */
  6640. easeInCore(gradient: number): number;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Defines an interface which represents an animation key frame
  6646. */
  6647. export interface IAnimationKey {
  6648. /**
  6649. * Frame of the key frame
  6650. */
  6651. frame: number;
  6652. /**
  6653. * Value at the specifies key frame
  6654. */
  6655. value: any;
  6656. /**
  6657. * The input tangent for the cubic hermite spline
  6658. */
  6659. inTangent?: any;
  6660. /**
  6661. * The output tangent for the cubic hermite spline
  6662. */
  6663. outTangent?: any;
  6664. /**
  6665. * The animation interpolation type
  6666. */
  6667. interpolation?: AnimationKeyInterpolation;
  6668. }
  6669. /**
  6670. * Enum for the animation key frame interpolation type
  6671. */
  6672. export enum AnimationKeyInterpolation {
  6673. /**
  6674. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6675. */
  6676. STEP = 1
  6677. }
  6678. }
  6679. declare module BABYLON {
  6680. /**
  6681. * Represents the range of an animation
  6682. */
  6683. export class AnimationRange {
  6684. /**The name of the animation range**/
  6685. name: string;
  6686. /**The starting frame of the animation */
  6687. from: number;
  6688. /**The ending frame of the animation*/
  6689. to: number;
  6690. /**
  6691. * Initializes the range of an animation
  6692. * @param name The name of the animation range
  6693. * @param from The starting frame of the animation
  6694. * @param to The ending frame of the animation
  6695. */
  6696. constructor(
  6697. /**The name of the animation range**/
  6698. name: string,
  6699. /**The starting frame of the animation */
  6700. from: number,
  6701. /**The ending frame of the animation*/
  6702. to: number);
  6703. /**
  6704. * Makes a copy of the animation range
  6705. * @returns A copy of the animation range
  6706. */
  6707. clone(): AnimationRange;
  6708. }
  6709. }
  6710. declare module BABYLON {
  6711. /**
  6712. * Composed of a frame, and an action function
  6713. */
  6714. export class AnimationEvent {
  6715. /** The frame for which the event is triggered **/
  6716. frame: number;
  6717. /** The event to perform when triggered **/
  6718. action: (currentFrame: number) => void;
  6719. /** Specifies if the event should be triggered only once**/
  6720. onlyOnce?: boolean | undefined;
  6721. /**
  6722. * Specifies if the animation event is done
  6723. */
  6724. isDone: boolean;
  6725. /**
  6726. * Initializes the animation event
  6727. * @param frame The frame for which the event is triggered
  6728. * @param action The event to perform when triggered
  6729. * @param onlyOnce Specifies if the event should be triggered only once
  6730. */
  6731. constructor(
  6732. /** The frame for which the event is triggered **/
  6733. frame: number,
  6734. /** The event to perform when triggered **/
  6735. action: (currentFrame: number) => void,
  6736. /** Specifies if the event should be triggered only once**/
  6737. onlyOnce?: boolean | undefined);
  6738. /** @hidden */ clone(): AnimationEvent;
  6739. }
  6740. }
  6741. declare module BABYLON {
  6742. /**
  6743. * Interface used to define a behavior
  6744. */
  6745. export interface Behavior<T> {
  6746. /** gets or sets behavior's name */
  6747. name: string;
  6748. /**
  6749. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6750. */
  6751. init(): void;
  6752. /**
  6753. * Called when the behavior is attached to a target
  6754. * @param target defines the target where the behavior is attached to
  6755. */
  6756. attach(target: T): void;
  6757. /**
  6758. * Called when the behavior is detached from its target
  6759. */
  6760. detach(): void;
  6761. }
  6762. /**
  6763. * Interface implemented by classes supporting behaviors
  6764. */
  6765. export interface IBehaviorAware<T> {
  6766. /**
  6767. * Attach a behavior
  6768. * @param behavior defines the behavior to attach
  6769. * @returns the current host
  6770. */
  6771. addBehavior(behavior: Behavior<T>): T;
  6772. /**
  6773. * Remove a behavior from the current object
  6774. * @param behavior defines the behavior to detach
  6775. * @returns the current host
  6776. */
  6777. removeBehavior(behavior: Behavior<T>): T;
  6778. /**
  6779. * Gets a behavior using its name to search
  6780. * @param name defines the name to search
  6781. * @returns the behavior or null if not found
  6782. */
  6783. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6784. }
  6785. }
  6786. declare module BABYLON {
  6787. /**
  6788. * @hidden
  6789. */
  6790. export class IntersectionInfo {
  6791. bu: Nullable<number>;
  6792. bv: Nullable<number>;
  6793. distance: number;
  6794. faceId: number;
  6795. subMeshId: number;
  6796. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. /**
  6801. * Class used to store bounding sphere information
  6802. */
  6803. export class BoundingSphere {
  6804. /**
  6805. * Gets the center of the bounding sphere in local space
  6806. */
  6807. readonly center: Vector3;
  6808. /**
  6809. * Radius of the bounding sphere in local space
  6810. */
  6811. radius: number;
  6812. /**
  6813. * Gets the center of the bounding sphere in world space
  6814. */
  6815. readonly centerWorld: Vector3;
  6816. /**
  6817. * Radius of the bounding sphere in world space
  6818. */
  6819. radiusWorld: number;
  6820. /**
  6821. * Gets the minimum vector in local space
  6822. */
  6823. readonly minimum: Vector3;
  6824. /**
  6825. * Gets the maximum vector in local space
  6826. */
  6827. readonly maximum: Vector3;
  6828. private _worldMatrix;
  6829. private static readonly TmpVector3;
  6830. /**
  6831. * Creates a new bounding sphere
  6832. * @param min defines the minimum vector (in local space)
  6833. * @param max defines the maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6837. /**
  6838. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6839. * @param min defines the new minimum vector (in local space)
  6840. * @param max defines the new maximum vector (in local space)
  6841. * @param worldMatrix defines the new world matrix
  6842. */
  6843. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Scale the current bounding sphere by applying a scale factor
  6846. * @param factor defines the scale factor to apply
  6847. * @returns the current bounding box
  6848. */
  6849. scale(factor: number): BoundingSphere;
  6850. /**
  6851. * Gets the world matrix of the bounding box
  6852. * @returns a matrix
  6853. */
  6854. getWorldMatrix(): DeepImmutable<Matrix>;
  6855. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6856. /**
  6857. * Tests if the bounding sphere is intersecting the frustum planes
  6858. * @param frustumPlanes defines the frustum planes to test
  6859. * @returns true if there is an intersection
  6860. */
  6861. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6862. /**
  6863. * Tests if the bounding sphere center is in between the frustum planes.
  6864. * Used for optimistic fast inclusion.
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if the sphere center is in between the frustum planes
  6867. */
  6868. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if a point is inside the bounding sphere
  6871. * @param point defines the point to test
  6872. * @returns true if the point is inside the bounding sphere
  6873. */
  6874. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6875. /**
  6876. * Checks if two sphere intersct
  6877. * @param sphere0 sphere 0
  6878. * @param sphere1 sphere 1
  6879. * @returns true if the speres intersect
  6880. */
  6881. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6882. }
  6883. }
  6884. declare module BABYLON {
  6885. /**
  6886. * Class used to store bounding box information
  6887. */
  6888. export class BoundingBox implements ICullable {
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in local space
  6891. */
  6892. readonly vectors: Vector3[];
  6893. /**
  6894. * Gets the center of the bounding box in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Gets the center of the bounding box in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Gets the extend size in local space
  6903. */
  6904. readonly extendSize: Vector3;
  6905. /**
  6906. * Gets the extend size in world space
  6907. */
  6908. readonly extendSizeWorld: Vector3;
  6909. /**
  6910. * Gets the OBB (object bounding box) directions
  6911. */
  6912. readonly directions: Vector3[];
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in world space
  6915. */
  6916. readonly vectorsWorld: Vector3[];
  6917. /**
  6918. * Gets the minimum vector in world space
  6919. */
  6920. readonly minimumWorld: Vector3;
  6921. /**
  6922. * Gets the maximum vector in world space
  6923. */
  6924. readonly maximumWorld: Vector3;
  6925. /**
  6926. * Gets the minimum vector in local space
  6927. */
  6928. readonly minimum: Vector3;
  6929. /**
  6930. * Gets the maximum vector in local space
  6931. */
  6932. readonly maximum: Vector3;
  6933. private _worldMatrix;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * @hidden
  6937. */ tag: number;
  6938. /**
  6939. * Creates a new bounding box
  6940. * @param min defines the minimum vector (in local space)
  6941. * @param max defines the maximum vector (in local space)
  6942. * @param worldMatrix defines the new world matrix
  6943. */
  6944. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6945. /**
  6946. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6947. * @param min defines the new minimum vector (in local space)
  6948. * @param max defines the new maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6952. /**
  6953. * Scale the current bounding box by applying a scale factor
  6954. * @param factor defines the scale factor to apply
  6955. * @returns the current bounding box
  6956. */
  6957. scale(factor: number): BoundingBox;
  6958. /**
  6959. * Gets the world matrix of the bounding box
  6960. * @returns a matrix
  6961. */
  6962. getWorldMatrix(): DeepImmutable<Matrix>;
  6963. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module BABYLON {
  7028. /** @hidden */
  7029. export class Collider {
  7030. /** Define if a collision was found */
  7031. collisionFound: boolean;
  7032. /**
  7033. * Define last intersection point in local space
  7034. */
  7035. intersectionPoint: Vector3;
  7036. /**
  7037. * Define last collided mesh
  7038. */
  7039. collidedMesh: Nullable<AbstractMesh>;
  7040. private _collisionPoint;
  7041. private _planeIntersectionPoint;
  7042. private _tempVector;
  7043. private _tempVector2;
  7044. private _tempVector3;
  7045. private _tempVector4;
  7046. private _edge;
  7047. private _baseToVertex;
  7048. private _destinationPoint;
  7049. private _slidePlaneNormal;
  7050. private _displacementVector;
  7051. /** @hidden */ radius: Vector3;
  7052. /** @hidden */ retry: number;
  7053. private _velocity;
  7054. private _basePoint;
  7055. private _epsilon;
  7056. /** @hidden */ velocityWorldLength: number;
  7057. /** @hidden */ basePointWorld: Vector3;
  7058. private _velocityWorld;
  7059. private _normalizedVelocity;
  7060. /** @hidden */ initialVelocity: Vector3;
  7061. /** @hidden */ initialPosition: Vector3;
  7062. private _nearestDistance;
  7063. private _collisionMask;
  7064. collisionMask: number;
  7065. /**
  7066. * Gets the plane normal used to compute the sliding response (in local space)
  7067. */
  7068. readonly slidePlaneNormal: Vector3;
  7069. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7070. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7071. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7072. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7073. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7074. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7075. }
  7076. }
  7077. declare module BABYLON {
  7078. /**
  7079. * Interface for cullable objects
  7080. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7081. */
  7082. export interface ICullable {
  7083. /**
  7084. * Checks if the object or part of the object is in the frustum
  7085. * @param frustumPlanes Camera near/planes
  7086. * @returns true if the object is in frustum otherwise false
  7087. */
  7088. isInFrustum(frustumPlanes: Plane[]): boolean;
  7089. /**
  7090. * Checks if a cullable object (mesh...) is in the camera frustum
  7091. * Unlike isInFrustum this cheks the full bounding box
  7092. * @param frustumPlanes Camera near/planes
  7093. * @returns true if the object is in frustum otherwise false
  7094. */
  7095. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7096. }
  7097. /**
  7098. * Info for a bounding data of a mesh
  7099. */
  7100. export class BoundingInfo implements ICullable {
  7101. /**
  7102. * Bounding box for the mesh
  7103. */
  7104. readonly boundingBox: BoundingBox;
  7105. /**
  7106. * Bounding sphere for the mesh
  7107. */
  7108. readonly boundingSphere: BoundingSphere;
  7109. private _isLocked;
  7110. private static readonly TmpVector3;
  7111. /**
  7112. * Constructs bounding info
  7113. * @param minimum min vector of the bounding box/sphere
  7114. * @param maximum max vector of the bounding box/sphere
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * min vector of the bounding box/sphere
  7127. */
  7128. readonly minimum: Vector3;
  7129. /**
  7130. * max vector of the bounding box/sphere
  7131. */
  7132. readonly maximum: Vector3;
  7133. /**
  7134. * If the info is locked and won't be updated to avoid perf overhead
  7135. */
  7136. isLocked: boolean;
  7137. /**
  7138. * Updates the bounding sphere and box
  7139. * @param world world matrix to be used to update
  7140. */
  7141. update(world: DeepImmutable<Matrix>): void;
  7142. /**
  7143. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7144. * @param center New center of the bounding info
  7145. * @param extend New extend of the bounding info
  7146. * @returns the current bounding info
  7147. */
  7148. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7149. /**
  7150. * Scale the current bounding info by applying a scale factor
  7151. * @param factor defines the scale factor to apply
  7152. * @returns the current bounding info
  7153. */
  7154. scale(factor: number): BoundingInfo;
  7155. /**
  7156. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7157. * @param frustumPlanes defines the frustum to test
  7158. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7159. * @returns true if the bounding info is in the frustum planes
  7160. */
  7161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7162. /**
  7163. * Gets the world distance between the min and max points of the bounding box
  7164. */
  7165. readonly diagonalLength: number;
  7166. /**
  7167. * Checks if a cullable object (mesh...) is in the camera frustum
  7168. * Unlike isInFrustum this cheks the full bounding box
  7169. * @param frustumPlanes Camera near/planes
  7170. * @returns true if the object is in frustum otherwise false
  7171. */
  7172. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7173. /** @hidden */ checkCollision(collider: Collider): boolean;
  7174. /**
  7175. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param point the point to check intersection with
  7178. * @returns if the point intersects
  7179. */
  7180. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7181. /**
  7182. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7183. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7184. * @param boundingInfo the bounding info to check intersection with
  7185. * @param precise if the intersection should be done using OBB
  7186. * @returns if the bounding info intersects
  7187. */
  7188. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /**
  7193. * Defines an array and its length.
  7194. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7195. */
  7196. export interface ISmartArrayLike<T> {
  7197. /**
  7198. * The data of the array.
  7199. */
  7200. data: Array<T>;
  7201. /**
  7202. * The active length of the array.
  7203. */
  7204. length: number;
  7205. }
  7206. /**
  7207. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7208. */
  7209. export class SmartArray<T> implements ISmartArrayLike<T> {
  7210. /**
  7211. * The full set of data from the array.
  7212. */
  7213. data: Array<T>;
  7214. /**
  7215. * The active length of the array.
  7216. */
  7217. length: number;
  7218. protected _id: number;
  7219. /**
  7220. * Instantiates a Smart Array.
  7221. * @param capacity defines the default capacity of the array.
  7222. */
  7223. constructor(capacity: number);
  7224. /**
  7225. * Pushes a value at the end of the active data.
  7226. * @param value defines the object to push in the array.
  7227. */
  7228. push(value: T): void;
  7229. /**
  7230. * Iterates over the active data and apply the lambda to them.
  7231. * @param func defines the action to apply on each value.
  7232. */
  7233. forEach(func: (content: T) => void): void;
  7234. /**
  7235. * Sorts the full sets of data.
  7236. * @param compareFn defines the comparison function to apply.
  7237. */
  7238. sort(compareFn: (a: T, b: T) => number): void;
  7239. /**
  7240. * Resets the active data to an empty array.
  7241. */
  7242. reset(): void;
  7243. /**
  7244. * Releases all the data from the array as well as the array.
  7245. */
  7246. dispose(): void;
  7247. /**
  7248. * Concats the active data with a given array.
  7249. * @param array defines the data to concatenate with.
  7250. */
  7251. concat(array: any): void;
  7252. /**
  7253. * Returns the position of a value in the active data.
  7254. * @param value defines the value to find the index for
  7255. * @returns the index if found in the active data otherwise -1
  7256. */
  7257. indexOf(value: T): number;
  7258. /**
  7259. * Returns whether an element is part of the active data.
  7260. * @param value defines the value to look for
  7261. * @returns true if found in the active data otherwise false
  7262. */
  7263. contains(value: T): boolean;
  7264. private static _GlobalId;
  7265. }
  7266. /**
  7267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7268. * The data in this array can only be present once
  7269. */
  7270. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7271. private _duplicateId;
  7272. /**
  7273. * Pushes a value at the end of the active data.
  7274. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7275. * @param value defines the object to push in the array.
  7276. */
  7277. push(value: T): void;
  7278. /**
  7279. * Pushes a value at the end of the active data.
  7280. * If the data is already present, it won t be added again
  7281. * @param value defines the object to push in the array.
  7282. * @returns true if added false if it was already present
  7283. */
  7284. pushNoDuplicate(value: T): boolean;
  7285. /**
  7286. * Resets the active data to an empty array.
  7287. */
  7288. reset(): void;
  7289. /**
  7290. * Concats the active data with a given array.
  7291. * This ensures no dupplicate will be present in the result.
  7292. * @param array defines the data to concatenate with.
  7293. */
  7294. concatWithNoDuplicate(array: any): void;
  7295. }
  7296. }
  7297. declare module BABYLON {
  7298. /**
  7299. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7300. * separate meshes. This can be use to improve performances.
  7301. * @see http://doc.babylonjs.com/how_to/multi_materials
  7302. */
  7303. export class MultiMaterial extends Material {
  7304. private _subMaterials;
  7305. /**
  7306. * Gets or Sets the list of Materials used within the multi material.
  7307. * They need to be ordered according to the submeshes order in the associated mesh
  7308. */
  7309. subMaterials: Nullable<Material>[];
  7310. /**
  7311. * Function used to align with Node.getChildren()
  7312. * @returns the list of Materials used within the multi material
  7313. */
  7314. getChildren(): Nullable<Material>[];
  7315. /**
  7316. * Instantiates a new Multi Material
  7317. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7318. * separate meshes. This can be use to improve performances.
  7319. * @see http://doc.babylonjs.com/how_to/multi_materials
  7320. * @param name Define the name in the scene
  7321. * @param scene Define the scene the material belongs to
  7322. */
  7323. constructor(name: string, scene: Scene);
  7324. private _hookArray;
  7325. /**
  7326. * Get one of the submaterial by its index in the submaterials array
  7327. * @param index The index to look the sub material at
  7328. * @returns The Material if the index has been defined
  7329. */
  7330. getSubMaterial(index: number): Nullable<Material>;
  7331. /**
  7332. * Get the list of active textures for the whole sub materials list.
  7333. * @returns All the textures that will be used during the rendering
  7334. */
  7335. getActiveTextures(): BaseTexture[];
  7336. /**
  7337. * Gets the current class name of the material e.g. "MultiMaterial"
  7338. * Mainly use in serialization.
  7339. * @returns the class name
  7340. */
  7341. getClassName(): string;
  7342. /**
  7343. * Checks if the material is ready to render the requested sub mesh
  7344. * @param mesh Define the mesh the submesh belongs to
  7345. * @param subMesh Define the sub mesh to look readyness for
  7346. * @param useInstances Define whether or not the material is used with instances
  7347. * @returns true if ready, otherwise false
  7348. */
  7349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7350. /**
  7351. * Clones the current material and its related sub materials
  7352. * @param name Define the name of the newly cloned material
  7353. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7354. * @returns the cloned material
  7355. */
  7356. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7357. /**
  7358. * Serializes the materials into a JSON representation.
  7359. * @returns the JSON representation
  7360. */
  7361. serialize(): any;
  7362. /**
  7363. * Dispose the material and release its associated resources
  7364. * @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)
  7365. * @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)
  7366. * @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)
  7367. */
  7368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7369. /**
  7370. * Creates a MultiMaterial from parsed MultiMaterial data.
  7371. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7372. * @param scene defines the hosting scene
  7373. * @returns a new MultiMaterial
  7374. */
  7375. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. /**
  7380. * Class used to represent data loading progression
  7381. */
  7382. export class SceneLoaderFlags {
  7383. private static _ForceFullSceneLoadingForIncremental;
  7384. private static _ShowLoadingScreen;
  7385. private static _CleanBoneMatrixWeights;
  7386. private static _loggingLevel;
  7387. /**
  7388. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7389. */
  7390. static ForceFullSceneLoadingForIncremental: boolean;
  7391. /**
  7392. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7393. */
  7394. static ShowLoadingScreen: boolean;
  7395. /**
  7396. * Defines the current logging level (while loading the scene)
  7397. * @ignorenaming
  7398. */
  7399. static loggingLevel: number;
  7400. /**
  7401. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7402. */
  7403. static CleanBoneMatrixWeights: boolean;
  7404. }
  7405. }
  7406. declare module BABYLON {
  7407. /**
  7408. * 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.
  7409. * @see https://doc.babylonjs.com/how_to/transformnode
  7410. */
  7411. export class TransformNode extends Node {
  7412. /**
  7413. * Object will not rotate to face the camera
  7414. */
  7415. static BILLBOARDMODE_NONE: number;
  7416. /**
  7417. * Object will rotate to face the camera but only on the x axis
  7418. */
  7419. static BILLBOARDMODE_X: number;
  7420. /**
  7421. * Object will rotate to face the camera but only on the y axis
  7422. */
  7423. static BILLBOARDMODE_Y: number;
  7424. /**
  7425. * Object will rotate to face the camera but only on the z axis
  7426. */
  7427. static BILLBOARDMODE_Z: number;
  7428. /**
  7429. * Object will rotate to face the camera
  7430. */
  7431. static BILLBOARDMODE_ALL: number;
  7432. private _forward;
  7433. private _forwardInverted;
  7434. private _up;
  7435. private _right;
  7436. private _rightInverted;
  7437. private _position;
  7438. private _rotation;
  7439. private _rotationQuaternion;
  7440. protected _scaling: Vector3;
  7441. protected _isDirty: boolean;
  7442. private _transformToBoneReferal;
  7443. private _billboardMode;
  7444. /**
  7445. * Gets or sets the billboard mode. Default is 0.
  7446. *
  7447. * | Value | Type | Description |
  7448. * | --- | --- | --- |
  7449. * | 0 | BILLBOARDMODE_NONE | |
  7450. * | 1 | BILLBOARDMODE_X | |
  7451. * | 2 | BILLBOARDMODE_Y | |
  7452. * | 4 | BILLBOARDMODE_Z | |
  7453. * | 7 | BILLBOARDMODE_ALL | |
  7454. *
  7455. */
  7456. billboardMode: number;
  7457. private _preserveParentRotationForBillboard;
  7458. /**
  7459. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7460. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7461. */
  7462. preserveParentRotationForBillboard: boolean;
  7463. /**
  7464. * 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
  7465. */
  7466. scalingDeterminant: number;
  7467. private _infiniteDistance;
  7468. /**
  7469. * Gets or sets the distance of the object to max, often used by skybox
  7470. */
  7471. infiniteDistance: boolean;
  7472. /**
  7473. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7474. * By default the system will update normals to compensate
  7475. */
  7476. ignoreNonUniformScaling: boolean;
  7477. /**
  7478. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7479. */
  7480. reIntegrateRotationIntoRotationQuaternion: boolean;
  7481. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7482. /** @hidden */ localMatrix: Matrix;
  7483. private _usePivotMatrix;
  7484. private _absolutePosition;
  7485. private _pivotMatrix;
  7486. private _pivotMatrixInverse;
  7487. protected _postMultiplyPivotMatrix: boolean;
  7488. protected _isWorldMatrixFrozen: boolean;
  7489. /** @hidden */ indexInSceneTransformNodesArray: number;
  7490. /**
  7491. * An event triggered after the world matrix is updated
  7492. */
  7493. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7494. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7495. /**
  7496. * Gets a string identifying the name of the class
  7497. * @returns "TransformNode" string
  7498. */
  7499. getClassName(): string;
  7500. /**
  7501. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7502. */
  7503. position: Vector3;
  7504. /**
  7505. * 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)).
  7506. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7507. */
  7508. rotation: Vector3;
  7509. /**
  7510. * 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)).
  7511. */
  7512. scaling: Vector3;
  7513. /**
  7514. * 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).
  7515. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7516. */
  7517. rotationQuaternion: Nullable<Quaternion>;
  7518. /**
  7519. * The forward direction of that transform in world space.
  7520. */
  7521. readonly forward: Vector3;
  7522. /**
  7523. * The up direction of that transform in world space.
  7524. */
  7525. readonly up: Vector3;
  7526. /**
  7527. * The right direction of that transform in world space.
  7528. */
  7529. readonly right: Vector3;
  7530. /**
  7531. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7532. * @param matrix the matrix to copy the pose from
  7533. * @returns this TransformNode.
  7534. */
  7535. updatePoseMatrix(matrix: Matrix): TransformNode;
  7536. /**
  7537. * Returns the mesh Pose matrix.
  7538. * @returns the pose matrix
  7539. */
  7540. getPoseMatrix(): Matrix;
  7541. /** @hidden */ isSynchronized(): boolean;
  7542. /** @hidden */ initCache(): void;
  7543. /**
  7544. * Flag the transform node as dirty (Forcing it to update everything)
  7545. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7546. * @returns this transform node
  7547. */
  7548. markAsDirty(property: string): TransformNode;
  7549. /**
  7550. * Returns the current mesh absolute position.
  7551. * Returns a Vector3.
  7552. */
  7553. readonly absolutePosition: Vector3;
  7554. /**
  7555. * Sets a new matrix to apply before all other transformation
  7556. * @param matrix defines the transform matrix
  7557. * @returns the current TransformNode
  7558. */
  7559. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7560. /**
  7561. * Sets a new pivot matrix to the current node
  7562. * @param matrix defines the new pivot matrix to use
  7563. * @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
  7564. * @returns the current TransformNode
  7565. */
  7566. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7567. /**
  7568. * Returns the mesh pivot matrix.
  7569. * Default : Identity.
  7570. * @returns the matrix
  7571. */
  7572. getPivotMatrix(): Matrix;
  7573. /**
  7574. * Prevents the World matrix to be computed any longer.
  7575. * @returns the TransformNode.
  7576. */
  7577. freezeWorldMatrix(): TransformNode;
  7578. /**
  7579. * Allows back the World matrix computation.
  7580. * @returns the TransformNode.
  7581. */
  7582. unfreezeWorldMatrix(): this;
  7583. /**
  7584. * True if the World matrix has been frozen.
  7585. */
  7586. readonly isWorldMatrixFrozen: boolean;
  7587. /**
  7588. * Retuns the mesh absolute position in the World.
  7589. * @returns a Vector3.
  7590. */
  7591. getAbsolutePosition(): Vector3;
  7592. /**
  7593. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7594. * @param absolutePosition the absolute position to set
  7595. * @returns the TransformNode.
  7596. */
  7597. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7598. /**
  7599. * Sets the mesh position in its local space.
  7600. * @param vector3 the position to set in localspace
  7601. * @returns the TransformNode.
  7602. */
  7603. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7604. /**
  7605. * Returns the mesh position in the local space from the current World matrix values.
  7606. * @returns a new Vector3.
  7607. */
  7608. getPositionExpressedInLocalSpace(): Vector3;
  7609. /**
  7610. * Translates the mesh along the passed Vector3 in its local space.
  7611. * @param vector3 the distance to translate in localspace
  7612. * @returns the TransformNode.
  7613. */
  7614. locallyTranslate(vector3: Vector3): TransformNode;
  7615. private static _lookAtVectorCache;
  7616. /**
  7617. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7618. * @param targetPoint the position (must be in same space as current mesh) to look at
  7619. * @param yawCor optional yaw (y-axis) correction in radians
  7620. * @param pitchCor optional pitch (x-axis) correction in radians
  7621. * @param rollCor optional roll (z-axis) correction in radians
  7622. * @param space the choosen space of the target
  7623. * @returns the TransformNode.
  7624. */
  7625. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7626. /**
  7627. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7628. * This Vector3 is expressed in the World space.
  7629. * @param localAxis axis to rotate
  7630. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7631. */
  7632. getDirection(localAxis: Vector3): Vector3;
  7633. /**
  7634. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7635. * localAxis is expressed in the mesh local space.
  7636. * result is computed in the Wordl space from the mesh World matrix.
  7637. * @param localAxis axis to rotate
  7638. * @param result the resulting transformnode
  7639. * @returns this TransformNode.
  7640. */
  7641. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7642. /**
  7643. * Sets this transform node rotation to the given local axis.
  7644. * @param localAxis the axis in local space
  7645. * @param yawCor optional yaw (y-axis) correction in radians
  7646. * @param pitchCor optional pitch (x-axis) correction in radians
  7647. * @param rollCor optional roll (z-axis) correction in radians
  7648. * @returns this TransformNode
  7649. */
  7650. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7651. /**
  7652. * Sets a new pivot point to the current node
  7653. * @param point defines the new pivot point to use
  7654. * @param space defines if the point is in world or local space (local by default)
  7655. * @returns the current TransformNode
  7656. */
  7657. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7658. /**
  7659. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7660. * @returns the pivot point
  7661. */
  7662. getPivotPoint(): Vector3;
  7663. /**
  7664. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7665. * @param result the vector3 to store the result
  7666. * @returns this TransformNode.
  7667. */
  7668. getPivotPointToRef(result: Vector3): TransformNode;
  7669. /**
  7670. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7671. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7672. */
  7673. getAbsolutePivotPoint(): Vector3;
  7674. /**
  7675. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7676. * @param result vector3 to store the result
  7677. * @returns this TransformNode.
  7678. */
  7679. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7680. /**
  7681. * Defines the passed node as the parent of the current node.
  7682. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7683. * @see https://doc.babylonjs.com/how_to/parenting
  7684. * @param node the node ot set as the parent
  7685. * @returns this TransformNode.
  7686. */
  7687. setParent(node: Nullable<Node>): TransformNode;
  7688. private _nonUniformScaling;
  7689. /**
  7690. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7691. */
  7692. readonly nonUniformScaling: boolean;
  7693. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7694. /**
  7695. * Attach the current TransformNode to another TransformNode associated with a bone
  7696. * @param bone Bone affecting the TransformNode
  7697. * @param affectedTransformNode TransformNode associated with the bone
  7698. * @returns this object
  7699. */
  7700. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7701. /**
  7702. * Detach the transform node if its associated with a bone
  7703. * @returns this object
  7704. */
  7705. detachFromBone(): TransformNode;
  7706. private static _rotationAxisCache;
  7707. /**
  7708. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7709. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7710. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7711. * The passed axis is also normalized.
  7712. * @param axis the axis to rotate around
  7713. * @param amount the amount to rotate in radians
  7714. * @param space Space to rotate in (Default: local)
  7715. * @returns the TransformNode.
  7716. */
  7717. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7718. /**
  7719. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7720. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7721. * The passed axis is also normalized. .
  7722. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7723. * @param point the point to rotate around
  7724. * @param axis the axis to rotate around
  7725. * @param amount the amount to rotate in radians
  7726. * @returns the TransformNode
  7727. */
  7728. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7729. /**
  7730. * Translates the mesh along the axis vector for the passed distance in the given space.
  7731. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7732. * @param axis the axis to translate in
  7733. * @param distance the distance to translate
  7734. * @param space Space to rotate in (Default: local)
  7735. * @returns the TransformNode.
  7736. */
  7737. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7738. /**
  7739. * Adds a rotation step to the mesh current rotation.
  7740. * x, y, z are Euler angles expressed in radians.
  7741. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7742. * This means this rotation is made in the mesh local space only.
  7743. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7744. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7745. * ```javascript
  7746. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7747. * ```
  7748. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7749. * 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.
  7750. * @param x Rotation to add
  7751. * @param y Rotation to add
  7752. * @param z Rotation to add
  7753. * @returns the TransformNode.
  7754. */
  7755. addRotation(x: number, y: number, z: number): TransformNode;
  7756. /**
  7757. * @hidden
  7758. */
  7759. protected _getEffectiveParent(): Nullable<Node>;
  7760. /**
  7761. * Computes the world matrix of the node
  7762. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7763. * @returns the world matrix
  7764. */
  7765. computeWorldMatrix(force?: boolean): Matrix;
  7766. protected _afterComputeWorldMatrix(): void;
  7767. /**
  7768. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7769. * @param func callback function to add
  7770. *
  7771. * @returns the TransformNode.
  7772. */
  7773. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7774. /**
  7775. * Removes a registered callback function.
  7776. * @param func callback function to remove
  7777. * @returns the TransformNode.
  7778. */
  7779. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7780. /**
  7781. * Gets the position of the current mesh in camera space
  7782. * @param camera defines the camera to use
  7783. * @returns a position
  7784. */
  7785. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7786. /**
  7787. * Returns the distance from the mesh to the active camera
  7788. * @param camera defines the camera to use
  7789. * @returns the distance
  7790. */
  7791. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7792. /**
  7793. * Clone the current transform node
  7794. * @param name Name of the new clone
  7795. * @param newParent New parent for the clone
  7796. * @param doNotCloneChildren Do not clone children hierarchy
  7797. * @returns the new transform node
  7798. */
  7799. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7800. /**
  7801. * Serializes the objects information.
  7802. * @param currentSerializationObject defines the object to serialize in
  7803. * @returns the serialized object
  7804. */
  7805. serialize(currentSerializationObject?: any): any;
  7806. /**
  7807. * Returns a new TransformNode object parsed from the source provided.
  7808. * @param parsedTransformNode is the source.
  7809. * @param scene the scne the object belongs to
  7810. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7811. * @returns a new TransformNode object parsed from the source provided.
  7812. */
  7813. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7814. /**
  7815. * Get all child-transformNodes of this node
  7816. * @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
  7817. * @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
  7818. * @returns an array of TransformNode
  7819. */
  7820. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7821. /**
  7822. * Releases resources associated with this transform node.
  7823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7825. */
  7826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7827. }
  7828. }
  7829. declare module BABYLON {
  7830. /**
  7831. * Class used to override all child animations of a given target
  7832. */
  7833. export class AnimationPropertiesOverride {
  7834. /**
  7835. * Gets or sets a value indicating if animation blending must be used
  7836. */
  7837. enableBlending: boolean;
  7838. /**
  7839. * Gets or sets the blending speed to use when enableBlending is true
  7840. */
  7841. blendingSpeed: number;
  7842. /**
  7843. * Gets or sets the default loop mode to use
  7844. */
  7845. loopMode: number;
  7846. }
  7847. }
  7848. declare module BABYLON {
  7849. /**
  7850. * Class used to store bone information
  7851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7852. */
  7853. export class Bone extends Node {
  7854. /**
  7855. * defines the bone name
  7856. */
  7857. name: string;
  7858. private static _tmpVecs;
  7859. private static _tmpQuat;
  7860. private static _tmpMats;
  7861. /**
  7862. * Gets the list of child bones
  7863. */
  7864. children: Bone[];
  7865. /** Gets the animations associated with this bone */
  7866. animations: Animation[];
  7867. /**
  7868. * Gets or sets bone length
  7869. */
  7870. length: number;
  7871. /**
  7872. * @hidden Internal only
  7873. * Set this value to map this bone to a different index in the transform matrices
  7874. * Set this value to -1 to exclude the bone from the transform matrices
  7875. */ index: Nullable<number>;
  7876. private _skeleton;
  7877. private _localMatrix;
  7878. private _restPose;
  7879. private _baseMatrix;
  7880. private _absoluteTransform;
  7881. private _invertedAbsoluteTransform;
  7882. private _parent;
  7883. private _scalingDeterminant;
  7884. private _worldTransform;
  7885. private _localScaling;
  7886. private _localRotation;
  7887. private _localPosition;
  7888. private _needToDecompose;
  7889. private _needToCompose;
  7890. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7891. /** @hidden */
  7892. /** @hidden */ matrix: Matrix;
  7893. /**
  7894. * Create a new bone
  7895. * @param name defines the bone name
  7896. * @param skeleton defines the parent skeleton
  7897. * @param parentBone defines the parent (can be null if the bone is the root)
  7898. * @param localMatrix defines the local matrix
  7899. * @param restPose defines the rest pose matrix
  7900. * @param baseMatrix defines the base matrix
  7901. * @param index defines index of the bone in the hiearchy
  7902. */
  7903. constructor(
  7904. /**
  7905. * defines the bone name
  7906. */
  7907. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7908. /**
  7909. * Gets the current object class name.
  7910. * @return the class name
  7911. */
  7912. getClassName(): string;
  7913. /**
  7914. * Gets the parent skeleton
  7915. * @returns a skeleton
  7916. */
  7917. getSkeleton(): Skeleton;
  7918. /**
  7919. * Gets parent bone
  7920. * @returns a bone or null if the bone is the root of the bone hierarchy
  7921. */
  7922. getParent(): Nullable<Bone>;
  7923. /**
  7924. * Returns an array containing the root bones
  7925. * @returns an array containing the root bones
  7926. */
  7927. getChildren(): Array<Bone>;
  7928. /**
  7929. * Sets the parent bone
  7930. * @param parent defines the parent (can be null if the bone is the root)
  7931. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7932. */
  7933. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7934. /**
  7935. * Gets the local matrix
  7936. * @returns a matrix
  7937. */
  7938. getLocalMatrix(): Matrix;
  7939. /**
  7940. * Gets the base matrix (initial matrix which remains unchanged)
  7941. * @returns a matrix
  7942. */
  7943. getBaseMatrix(): Matrix;
  7944. /**
  7945. * Gets the rest pose matrix
  7946. * @returns a matrix
  7947. */
  7948. getRestPose(): Matrix;
  7949. /**
  7950. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7951. */
  7952. getWorldMatrix(): Matrix;
  7953. /**
  7954. * Sets the local matrix to rest pose matrix
  7955. */
  7956. returnToRest(): void;
  7957. /**
  7958. * Gets the inverse of the absolute transform matrix.
  7959. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7960. * @returns a matrix
  7961. */
  7962. getInvertedAbsoluteTransform(): Matrix;
  7963. /**
  7964. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7965. * @returns a matrix
  7966. */
  7967. getAbsoluteTransform(): Matrix;
  7968. /**
  7969. * Links with the given transform node.
  7970. * The local matrix of this bone is copied from the transform node every frame.
  7971. * @param transformNode defines the transform node to link to
  7972. */
  7973. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7974. /** Gets or sets current position (in local space) */
  7975. position: Vector3;
  7976. /** Gets or sets current rotation (in local space) */
  7977. rotation: Vector3;
  7978. /** Gets or sets current rotation quaternion (in local space) */
  7979. rotationQuaternion: Quaternion;
  7980. /** Gets or sets current scaling (in local space) */
  7981. scaling: Vector3;
  7982. /**
  7983. * Gets the animation properties override
  7984. */
  7985. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7986. private _decompose;
  7987. private _compose;
  7988. /**
  7989. * Update the base and local matrices
  7990. * @param matrix defines the new base or local matrix
  7991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7992. * @param updateLocalMatrix defines if the local matrix should be updated
  7993. */
  7994. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7995. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7996. /**
  7997. * Flag the bone as dirty (Forcing it to update everything)
  7998. */
  7999. markAsDirty(): void;
  8000. private _markAsDirtyAndCompose;
  8001. private _markAsDirtyAndDecompose;
  8002. /**
  8003. * Translate the bone in local or world space
  8004. * @param vec The amount to translate the bone
  8005. * @param space The space that the translation is in
  8006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8007. */
  8008. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8009. /**
  8010. * Set the postion of the bone in local or world space
  8011. * @param position The position to set the bone
  8012. * @param space The space that the position is in
  8013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8014. */
  8015. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8016. /**
  8017. * Set the absolute position of the bone (world space)
  8018. * @param position The position to set the bone
  8019. * @param mesh The mesh that this bone is attached to
  8020. */
  8021. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8022. /**
  8023. * Scale the bone on the x, y and z axes (in local space)
  8024. * @param x The amount to scale the bone on the x axis
  8025. * @param y The amount to scale the bone on the y axis
  8026. * @param z The amount to scale the bone on the z axis
  8027. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8028. */
  8029. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8030. /**
  8031. * Set the bone scaling in local space
  8032. * @param scale defines the scaling vector
  8033. */
  8034. setScale(scale: Vector3): void;
  8035. /**
  8036. * Gets the current scaling in local space
  8037. * @returns the current scaling vector
  8038. */
  8039. getScale(): Vector3;
  8040. /**
  8041. * Gets the current scaling in local space and stores it in a target vector
  8042. * @param result defines the target vector
  8043. */
  8044. getScaleToRef(result: Vector3): void;
  8045. /**
  8046. * Set the yaw, pitch, and roll of the bone in local or world space
  8047. * @param yaw The rotation of the bone on the y axis
  8048. * @param pitch The rotation of the bone on the x axis
  8049. * @param roll The rotation of the bone on the z axis
  8050. * @param space The space that the axes of rotation are in
  8051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8052. */
  8053. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8054. /**
  8055. * Add a rotation to the bone on an axis in local or world space
  8056. * @param axis The axis to rotate the bone on
  8057. * @param amount The amount to rotate the bone
  8058. * @param space The space that the axis is in
  8059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8060. */
  8061. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8062. /**
  8063. * Set the rotation of the bone to a particular axis angle in local or world space
  8064. * @param axis The axis to rotate the bone on
  8065. * @param angle The angle that the bone should be rotated to
  8066. * @param space The space that the axis is in
  8067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8068. */
  8069. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8070. /**
  8071. * Set the euler rotation of the bone in local of world space
  8072. * @param rotation The euler rotation that the bone should be set to
  8073. * @param space The space that the rotation is in
  8074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8075. */
  8076. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8077. /**
  8078. * Set the quaternion rotation of the bone in local of world space
  8079. * @param quat The quaternion rotation that the bone should be set to
  8080. * @param space The space that the rotation is in
  8081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8082. */
  8083. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8084. /**
  8085. * Set the rotation matrix of the bone in local of world space
  8086. * @param rotMat The rotation matrix that the bone should be set to
  8087. * @param space The space that the rotation is in
  8088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8089. */
  8090. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8091. private _rotateWithMatrix;
  8092. private _getNegativeRotationToRef;
  8093. /**
  8094. * Get the position of the bone in local or world space
  8095. * @param space The space that the returned position is in
  8096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8097. * @returns The position of the bone
  8098. */
  8099. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8100. /**
  8101. * Copy the position of the bone to a vector3 in local or world space
  8102. * @param space The space that the returned position is in
  8103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8104. * @param result The vector3 to copy the position to
  8105. */
  8106. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8107. /**
  8108. * Get the absolute position of the bone (world space)
  8109. * @param mesh The mesh that this bone is attached to
  8110. * @returns The absolute position of the bone
  8111. */
  8112. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8113. /**
  8114. * Copy the absolute position of the bone (world space) to the result param
  8115. * @param mesh The mesh that this bone is attached to
  8116. * @param result The vector3 to copy the absolute position to
  8117. */
  8118. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8119. /**
  8120. * Compute the absolute transforms of this bone and its children
  8121. */
  8122. computeAbsoluteTransforms(): void;
  8123. /**
  8124. * Get the world direction from an axis that is in the local space of the bone
  8125. * @param localAxis The local direction that is used to compute the world direction
  8126. * @param mesh The mesh that this bone is attached to
  8127. * @returns The world direction
  8128. */
  8129. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8130. /**
  8131. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8132. * @param localAxis The local direction that is used to compute the world direction
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @param result The vector3 that the world direction will be copied to
  8135. */
  8136. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8137. /**
  8138. * Get the euler rotation of the bone in local or world space
  8139. * @param space The space that the rotation should be in
  8140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8141. * @returns The euler rotation
  8142. */
  8143. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8144. /**
  8145. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8146. * @param space The space that the rotation should be in
  8147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8148. * @param result The vector3 that the rotation should be copied to
  8149. */
  8150. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8151. /**
  8152. * Get the quaternion rotation of the bone in either local or world space
  8153. * @param space The space that the rotation should be in
  8154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8155. * @returns The quaternion rotation
  8156. */
  8157. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8158. /**
  8159. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8160. * @param space The space that the rotation should be in
  8161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8162. * @param result The quaternion that the rotation should be copied to
  8163. */
  8164. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8165. /**
  8166. * Get the rotation matrix of the bone in local or world space
  8167. * @param space The space that the rotation should be in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. * @returns The rotation matrix
  8170. */
  8171. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8172. /**
  8173. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8174. * @param space The space that the rotation should be in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @param result The quaternion that the rotation should be copied to
  8177. */
  8178. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8179. /**
  8180. * Get the world position of a point that is in the local space of the bone
  8181. * @param position The local position
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @returns The world position
  8184. */
  8185. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8186. /**
  8187. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8188. * @param position The local position
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @param result The vector3 that the world position should be copied to
  8191. */
  8192. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8193. /**
  8194. * Get the local position of a point that is in world space
  8195. * @param position The world position
  8196. * @param mesh The mesh that this bone is attached to
  8197. * @returns The local position
  8198. */
  8199. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8200. /**
  8201. * Get the local position of a point that is in world space and copy it to the result param
  8202. * @param position The world position
  8203. * @param mesh The mesh that this bone is attached to
  8204. * @param result The vector3 that the local position should be copied to
  8205. */
  8206. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8207. }
  8208. }
  8209. declare module BABYLON {
  8210. /**
  8211. * Enum that determines the text-wrapping mode to use.
  8212. */
  8213. export enum InspectableType {
  8214. /**
  8215. * Checkbox for booleans
  8216. */
  8217. Checkbox = 0,
  8218. /**
  8219. * Sliders for numbers
  8220. */
  8221. Slider = 1,
  8222. /**
  8223. * Vector3
  8224. */
  8225. Vector3 = 2,
  8226. /**
  8227. * Quaternions
  8228. */
  8229. Quaternion = 3,
  8230. /**
  8231. * Color3
  8232. */
  8233. Color3 = 4
  8234. }
  8235. /**
  8236. * Interface used to define custom inspectable properties.
  8237. * This interface is used by the inspector to display custom property grids
  8238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8239. */
  8240. export interface IInspectable {
  8241. /**
  8242. * Gets the label to display
  8243. */
  8244. label: string;
  8245. /**
  8246. * Gets the name of the property to edit
  8247. */
  8248. propertyName: string;
  8249. /**
  8250. * Gets the type of the editor to use
  8251. */
  8252. type: InspectableType;
  8253. /**
  8254. * Gets the minimum value of the property when using in "slider" mode
  8255. */
  8256. min?: number;
  8257. /**
  8258. * Gets the maximum value of the property when using in "slider" mode
  8259. */
  8260. max?: number;
  8261. /**
  8262. * Gets the setp to use when using in "slider" mode
  8263. */
  8264. step?: number;
  8265. }
  8266. }
  8267. declare module BABYLON {
  8268. /**
  8269. * This represents the required contract to create a new type of texture loader.
  8270. */
  8271. export interface IInternalTextureLoader {
  8272. /**
  8273. * Defines wether the loader supports cascade loading the different faces.
  8274. */
  8275. supportCascades: boolean;
  8276. /**
  8277. * This returns if the loader support the current file information.
  8278. * @param extension defines the file extension of the file being loaded
  8279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8280. * @param fallback defines the fallback internal texture if any
  8281. * @param isBase64 defines whether the texture is encoded as a base64
  8282. * @param isBuffer defines whether the texture data are stored as a buffer
  8283. * @returns true if the loader can load the specified file
  8284. */
  8285. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8286. /**
  8287. * Transform the url before loading if required.
  8288. * @param rootUrl the url of the texture
  8289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8290. * @returns the transformed texture
  8291. */
  8292. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8293. /**
  8294. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8295. * @param rootUrl the url of the texture
  8296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8297. * @returns the fallback texture
  8298. */
  8299. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8300. /**
  8301. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8302. * @param data contains the texture data
  8303. * @param texture defines the BabylonJS internal texture
  8304. * @param createPolynomials will be true if polynomials have been requested
  8305. * @param onLoad defines the callback to trigger once the texture is ready
  8306. * @param onError defines the callback to trigger in case of error
  8307. */
  8308. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8309. /**
  8310. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8311. * @param data contains the texture data
  8312. * @param texture defines the BabylonJS internal texture
  8313. * @param callback defines the method to call once ready to upload
  8314. */
  8315. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8316. }
  8317. }
  8318. declare module BABYLON {
  8319. interface Engine {
  8320. /**
  8321. * Creates a depth stencil cube texture.
  8322. * This is only available in WebGL 2.
  8323. * @param size The size of face edge in the cube texture.
  8324. * @param options The options defining the cube texture.
  8325. * @returns The cube texture
  8326. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8327. /**
  8328. * Creates a cube texture
  8329. * @param rootUrl defines the url where the files to load is located
  8330. * @param scene defines the current scene
  8331. * @param files defines the list of files to load (1 per face)
  8332. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8333. * @param onLoad defines an optional callback raised when the texture is loaded
  8334. * @param onError defines an optional callback raised if there is an issue to load the texture
  8335. * @param format defines the format of the data
  8336. * @param forcedExtension defines the extension to use to pick the right loader
  8337. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8338. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8339. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8340. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8341. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8342. * @returns the cube texture as an InternalTexture
  8343. */
  8344. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8345. /**
  8346. * Creates a cube texture
  8347. * @param rootUrl defines the url where the files to load is located
  8348. * @param scene defines the current scene
  8349. * @param files defines the list of files to load (1 per face)
  8350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8351. * @param onLoad defines an optional callback raised when the texture is loaded
  8352. * @param onError defines an optional callback raised if there is an issue to load the texture
  8353. * @param format defines the format of the data
  8354. * @param forcedExtension defines the extension to use to pick the right loader
  8355. * @returns the cube texture as an InternalTexture
  8356. */
  8357. 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 | undefined, forcedExtension: any): InternalTexture;
  8358. /**
  8359. * Creates a cube texture
  8360. * @param rootUrl defines the url where the files to load is located
  8361. * @param scene defines the current scene
  8362. * @param files defines the list of files to load (1 per face)
  8363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8364. * @param onLoad defines an optional callback raised when the texture is loaded
  8365. * @param onError defines an optional callback raised if there is an issue to load the texture
  8366. * @param format defines the format of the data
  8367. * @param forcedExtension defines the extension to use to pick the right loader
  8368. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8371. * @returns the cube texture as an InternalTexture
  8372. */
  8373. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8374. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8375. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8376. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8377. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8378. }
  8379. }
  8380. declare module BABYLON {
  8381. /**
  8382. * Class for creating a cube texture
  8383. */
  8384. export class CubeTexture extends BaseTexture {
  8385. private _delayedOnLoad;
  8386. /**
  8387. * The url of the texture
  8388. */
  8389. url: string;
  8390. /**
  8391. * Gets or sets the center of the bounding box associated with the cube texture.
  8392. * It must define where the camera used to render the texture was set
  8393. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8394. */
  8395. boundingBoxPosition: Vector3;
  8396. private _boundingBoxSize;
  8397. /**
  8398. * Gets or sets the size of the bounding box associated with the cube texture
  8399. * When defined, the cubemap will switch to local mode
  8400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8401. * @example https://www.babylonjs-playground.com/#RNASML
  8402. */
  8403. /**
  8404. * Returns the bounding box size
  8405. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8406. */
  8407. boundingBoxSize: Vector3;
  8408. protected _rotationY: number;
  8409. /**
  8410. * Sets texture matrix rotation angle around Y axis in radians.
  8411. */
  8412. /**
  8413. * Gets texture matrix rotation angle around Y axis radians.
  8414. */
  8415. rotationY: number;
  8416. /**
  8417. * Are mip maps generated for this texture or not.
  8418. */
  8419. readonly noMipmap: boolean;
  8420. private _noMipmap;
  8421. private _files;
  8422. private _extensions;
  8423. private _textureMatrix;
  8424. private _format;
  8425. private _createPolynomials;
  8426. /** @hidden */ prefiltered: boolean;
  8427. /**
  8428. * Creates a cube texture from an array of image urls
  8429. * @param files defines an array of image urls
  8430. * @param scene defines the hosting scene
  8431. * @param noMipmap specifies if mip maps are not used
  8432. * @returns a cube texture
  8433. */
  8434. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8435. /**
  8436. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8437. * @param url defines the url of the prefiltered texture
  8438. * @param scene defines the scene the texture is attached to
  8439. * @param forcedExtension defines the extension of the file if different from the url
  8440. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8441. * @return the prefiltered texture
  8442. */
  8443. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8444. /**
  8445. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8446. * as prefiltered data.
  8447. * @param rootUrl defines the url of the texture or the root name of the six images
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8450. * @param noMipmap defines if mipmaps should be created or not
  8451. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8452. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8453. * @param onError defines a callback triggered in case of error during load
  8454. * @param format defines the internal format to use for the texture once loaded
  8455. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8456. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8457. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8458. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8459. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8460. * @return the cube texture
  8461. */
  8462. 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);
  8463. /**
  8464. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8465. */
  8466. readonly isPrefiltered: boolean;
  8467. /**
  8468. * Get the current class name of the texture useful for serialization or dynamic coding.
  8469. * @returns "CubeTexture"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Update the url (and optional buffer) of this texture if url was null during construction.
  8474. * @param url the url of the texture
  8475. * @param forcedExtension defines the extension to use
  8476. * @param onLoad callback called when the texture is loaded (defaults to null)
  8477. */
  8478. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8479. /**
  8480. * Delays loading of the cube texture
  8481. * @param forcedExtension defines the extension to use
  8482. */
  8483. delayLoad(forcedExtension?: string): void;
  8484. /**
  8485. * Returns the reflection texture matrix
  8486. * @returns the reflection texture matrix
  8487. */
  8488. getReflectionTextureMatrix(): Matrix;
  8489. /**
  8490. * Sets the reflection texture matrix
  8491. * @param value Reflection texture matrix
  8492. */
  8493. setReflectionTextureMatrix(value: Matrix): void;
  8494. /**
  8495. * Parses text to create a cube texture
  8496. * @param parsedTexture define the serialized text to read from
  8497. * @param scene defines the hosting scene
  8498. * @param rootUrl defines the root url of the cube texture
  8499. * @returns a cube texture
  8500. */
  8501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8502. /**
  8503. * Makes a clone, or deep copy, of the cube texture
  8504. * @returns a new cube texture
  8505. */
  8506. clone(): CubeTexture;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /** @hidden */
  8511. export var postprocessVertexShader: {
  8512. name: string;
  8513. shader: string;
  8514. };
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8519. * This is the base of the follow, arc rotate cameras and Free camera
  8520. * @see http://doc.babylonjs.com/features/cameras
  8521. */
  8522. export class TargetCamera extends Camera {
  8523. private static _RigCamTransformMatrix;
  8524. private static _TargetTransformMatrix;
  8525. private static _TargetFocalPoint;
  8526. /**
  8527. * Define the current direction the camera is moving to
  8528. */
  8529. cameraDirection: Vector3;
  8530. /**
  8531. * Define the current rotation the camera is rotating to
  8532. */
  8533. cameraRotation: Vector2;
  8534. /**
  8535. * When set, the up vector of the camera will be updated by the rotation of the camera
  8536. */
  8537. updateUpVectorFromRotation: boolean;
  8538. private _tmpQuaternion;
  8539. /**
  8540. * Define the current rotation of the camera
  8541. */
  8542. rotation: Vector3;
  8543. /**
  8544. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8545. */
  8546. rotationQuaternion: Quaternion;
  8547. /**
  8548. * Define the current speed of the camera
  8549. */
  8550. speed: number;
  8551. /**
  8552. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8553. * around all axis.
  8554. */
  8555. noRotationConstraint: boolean;
  8556. /**
  8557. * Define the current target of the camera as an object or a position.
  8558. */
  8559. lockedTarget: any;
  8560. /** @hidden */ currentTarget: Vector3;
  8561. /** @hidden */ initialFocalDistance: number;
  8562. /** @hidden */ viewMatrix: Matrix;
  8563. /** @hidden */ camMatrix: Matrix;
  8564. /** @hidden */ cameraTransformMatrix: Matrix;
  8565. /** @hidden */ cameraRotationMatrix: Matrix;
  8566. /** @hidden */ referencePoint: Vector3;
  8567. /** @hidden */ transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */ reset: () => void;
  8571. private _defaultUp;
  8572. /**
  8573. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8574. * This is the base of the follow, arc rotate cameras and Free camera
  8575. * @see http://doc.babylonjs.com/features/cameras
  8576. * @param name Defines the name of the camera in the scene
  8577. * @param position Defines the start position of the camera in the scene
  8578. * @param scene Defines the scene the camera belongs to
  8579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8580. */
  8581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8582. /**
  8583. * Gets the position in front of the camera at a given distance.
  8584. * @param distance The distance from the camera we want the position to be
  8585. * @returns the position
  8586. */
  8587. getFrontPosition(distance: number): Vector3;
  8588. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8589. private _storedPosition;
  8590. private _storedRotation;
  8591. private _storedRotationQuaternion;
  8592. /**
  8593. * Store current camera state of the camera (fov, position, rotation, etc..)
  8594. * @returns the camera
  8595. */
  8596. storeState(): Camera;
  8597. /**
  8598. * Restored camera state. You must call storeState() first
  8599. * @returns whether it was successful or not
  8600. * @hidden
  8601. */ restoreStateValues(): boolean;
  8602. /** @hidden */ initCache(): void;
  8603. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8604. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */ computeLocalCameraSpeed(): number;
  8606. /**
  8607. * Defines the target the camera should look at.
  8608. * This will automatically adapt alpha beta and radius to fit within the new target.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */ decideIfNeedsToMove(): boolean;
  8618. /** @hidden */ updatePosition(): void;
  8619. /** @hidden */ checkInputs(): void;
  8620. protected _updateCameraRotationMatrix(): void;
  8621. /**
  8622. * 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)
  8623. * @returns the current camera
  8624. */
  8625. private _rotateUpVectorWithCameraRotationMatrix;
  8626. private _cachedRotationZ;
  8627. private _cachedQuaternionRotationZ;
  8628. /** @hidden */ getViewMatrix(): Matrix;
  8629. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8630. /**
  8631. * @hidden
  8632. */
  8633. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8634. /**
  8635. * @hidden
  8636. */ updateRigCameras(): void;
  8637. private _getRigCamPositionAndTarget;
  8638. /**
  8639. * Gets the current object class name.
  8640. * @return the class name
  8641. */
  8642. getClassName(): string;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * @ignore
  8648. * This is a list of all the different input types that are available in the application.
  8649. * Fo instance: ArcRotateCameraGamepadInput...
  8650. */
  8651. export var CameraInputTypes: {};
  8652. /**
  8653. * This is the contract to implement in order to create a new input class.
  8654. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8655. */
  8656. export interface ICameraInput<TCamera extends Camera> {
  8657. /**
  8658. * Defines the camera the input is attached to.
  8659. */
  8660. camera: Nullable<TCamera>;
  8661. /**
  8662. * Gets the class name of the current intput.
  8663. * @returns the class name
  8664. */
  8665. getClassName(): string;
  8666. /**
  8667. * Get the friendly name associated with the input class.
  8668. * @returns the input friendly name
  8669. */
  8670. getSimpleName(): string;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs?: () => void;
  8687. }
  8688. /**
  8689. * Represents a map of input types to input instance or input index to input instance.
  8690. */
  8691. export interface CameraInputsMap<TCamera extends Camera> {
  8692. /**
  8693. * Accessor to the input by input type.
  8694. */
  8695. [name: string]: ICameraInput<TCamera>;
  8696. /**
  8697. * Accessor to the input by input index.
  8698. */
  8699. [idx: number]: ICameraInput<TCamera>;
  8700. }
  8701. /**
  8702. * This represents the input manager used within a camera.
  8703. * It helps dealing with all the different kind of input attached to a camera.
  8704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8705. */
  8706. export class CameraInputsManager<TCamera extends Camera> {
  8707. /**
  8708. * Defines the list of inputs attahed to the camera.
  8709. */
  8710. attached: CameraInputsMap<TCamera>;
  8711. /**
  8712. * Defines the dom element the camera is collecting inputs from.
  8713. * This is null if the controls have not been attached.
  8714. */
  8715. attachedElement: Nullable<HTMLElement>;
  8716. /**
  8717. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. noPreventDefault: boolean;
  8720. /**
  8721. * Defined the camera the input manager belongs to.
  8722. */
  8723. camera: TCamera;
  8724. /**
  8725. * Update the current camera state depending on the inputs that have been used this frame.
  8726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8727. */
  8728. checkInputs: () => void;
  8729. /**
  8730. * Instantiate a new Camera Input Manager.
  8731. * @param camera Defines the camera the input manager blongs to
  8732. */
  8733. constructor(camera: TCamera);
  8734. /**
  8735. * Add an input method to a camera
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. * @param input camera input method
  8738. */
  8739. add(input: ICameraInput<TCamera>): void;
  8740. /**
  8741. * Remove a specific input method from a camera
  8742. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8743. * @param inputToRemove camera input method
  8744. */
  8745. remove(inputToRemove: ICameraInput<TCamera>): void;
  8746. /**
  8747. * Remove a specific input type from a camera
  8748. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8749. * @param inputType the type of the input to remove
  8750. */
  8751. removeByType(inputType: string): void;
  8752. private _addCheckInputs;
  8753. /**
  8754. * Attach the input controls to the currently attached dom element to listen the events from.
  8755. * @param input Defines the input to attach
  8756. */
  8757. attachInput(input: ICameraInput<TCamera>): void;
  8758. /**
  8759. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8760. * @param element Defines the dom element to collect the events from
  8761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8762. */
  8763. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8764. /**
  8765. * Detach the current manager inputs controls from a specific dom element.
  8766. * @param element Defines the dom element to collect the events from
  8767. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8768. */
  8769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8770. /**
  8771. * Rebuild the dynamic inputCheck function from the current list of
  8772. * defined inputs in the manager.
  8773. */
  8774. rebuildInputCheck(): void;
  8775. /**
  8776. * Remove all attached input methods from a camera
  8777. */
  8778. clear(): void;
  8779. /**
  8780. * Serialize the current input manager attached to a camera.
  8781. * This ensures than once parsed,
  8782. * the input associated to the camera will be identical to the current ones
  8783. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8784. */
  8785. serialize(serializedCamera: any): void;
  8786. /**
  8787. * Parses an input manager serialized JSON to restore the previous list of inputs
  8788. * and states associated to a camera.
  8789. * @param parsedCamera Defines the JSON to parse
  8790. */
  8791. parse(parsedCamera: any): void;
  8792. }
  8793. }
  8794. declare module BABYLON {
  8795. /**
  8796. * Gather the list of keyboard event types as constants.
  8797. */
  8798. export class KeyboardEventTypes {
  8799. /**
  8800. * The keydown event is fired when a key becomes active (pressed).
  8801. */
  8802. static readonly KEYDOWN: number;
  8803. /**
  8804. * The keyup event is fired when a key has been released.
  8805. */
  8806. static readonly KEYUP: number;
  8807. }
  8808. /**
  8809. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8810. */
  8811. export class KeyboardInfo {
  8812. /**
  8813. * Defines the type of event (KeyboardEventTypes)
  8814. */
  8815. type: number;
  8816. /**
  8817. * Defines the related dom event
  8818. */
  8819. event: KeyboardEvent;
  8820. /**
  8821. * Instantiates a new keyboard info.
  8822. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8823. * @param type Defines the type of event (KeyboardEventTypes)
  8824. * @param event Defines the related dom event
  8825. */
  8826. constructor(
  8827. /**
  8828. * Defines the type of event (KeyboardEventTypes)
  8829. */
  8830. type: number,
  8831. /**
  8832. * Defines the related dom event
  8833. */
  8834. event: KeyboardEvent);
  8835. }
  8836. /**
  8837. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8838. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8839. */
  8840. export class KeyboardInfoPre extends KeyboardInfo {
  8841. /**
  8842. * Defines the type of event (KeyboardEventTypes)
  8843. */
  8844. type: number;
  8845. /**
  8846. * Defines the related dom event
  8847. */
  8848. event: KeyboardEvent;
  8849. /**
  8850. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8851. */
  8852. skipOnPointerObservable: boolean;
  8853. /**
  8854. * Instantiates a new keyboard pre info.
  8855. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8856. * @param type Defines the type of event (KeyboardEventTypes)
  8857. * @param event Defines the related dom event
  8858. */
  8859. constructor(
  8860. /**
  8861. * Defines the type of event (KeyboardEventTypes)
  8862. */
  8863. type: number,
  8864. /**
  8865. * Defines the related dom event
  8866. */
  8867. event: KeyboardEvent);
  8868. }
  8869. }
  8870. declare module BABYLON {
  8871. /**
  8872. * Manage the keyboard inputs to control the movement of a free camera.
  8873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8874. */
  8875. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: FreeCamera;
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8882. */
  8883. keysUp: number[];
  8884. /**
  8885. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8886. */
  8887. keysDown: number[];
  8888. /**
  8889. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8890. */
  8891. keysLeft: number[];
  8892. /**
  8893. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8894. */
  8895. keysRight: number[];
  8896. private _keys;
  8897. private _onCanvasBlurObserver;
  8898. private _onKeyboardObserver;
  8899. private _engine;
  8900. private _scene;
  8901. /**
  8902. * Attach the input controls to a specific dom element to get the input from.
  8903. * @param element Defines the element the controls should be listened from
  8904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8905. */
  8906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8907. /**
  8908. * Detach the current controls from the specified dom element.
  8909. * @param element Defines the element to stop listening the inputs from
  8910. */
  8911. detachControl(element: Nullable<HTMLElement>): void;
  8912. /**
  8913. * Update the current camera state depending on the inputs that have been used this frame.
  8914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8915. */
  8916. checkInputs(): void;
  8917. /**
  8918. * Gets the class name of the current intput.
  8919. * @returns the class name
  8920. */
  8921. getClassName(): string;
  8922. /** @hidden */ onLostFocus(): void;
  8923. /**
  8924. * Get the friendly name associated with the input class.
  8925. * @returns the input friendly name
  8926. */
  8927. getSimpleName(): string;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Interface describing all the common properties and methods a shadow light needs to implement.
  8933. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8934. * as well as binding the different shadow properties to the effects.
  8935. */
  8936. export interface IShadowLight extends Light {
  8937. /**
  8938. * The light id in the scene (used in scene.findLighById for instance)
  8939. */
  8940. id: string;
  8941. /**
  8942. * The position the shdow will be casted from.
  8943. */
  8944. position: Vector3;
  8945. /**
  8946. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8947. */
  8948. direction: Vector3;
  8949. /**
  8950. * The transformed position. Position of the light in world space taking parenting in account.
  8951. */
  8952. transformedPosition: Vector3;
  8953. /**
  8954. * The transformed direction. Direction of the light in world space taking parenting in account.
  8955. */
  8956. transformedDirection: Vector3;
  8957. /**
  8958. * The friendly name of the light in the scene.
  8959. */
  8960. name: string;
  8961. /**
  8962. * Defines the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. /**
  8966. * Defines the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8971. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8972. */
  8973. computeTransformedInformation(): boolean;
  8974. /**
  8975. * Gets the scene the light belongs to.
  8976. * @returns The scene
  8977. */
  8978. getScene(): Scene;
  8979. /**
  8980. * Callback defining a custom Projection Matrix Builder.
  8981. * This can be used to override the default projection matrix computation.
  8982. */
  8983. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8984. /**
  8985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8986. * @param matrix The materix to updated with the projection information
  8987. * @param viewMatrix The transform matrix of the light
  8988. * @param renderList The list of mesh to render in the map
  8989. * @returns The current light
  8990. */
  8991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8992. /**
  8993. * Gets the current depth scale used in ESM.
  8994. * @returns The scale
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Gets the minZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the min for
  9020. * @returns the depth min z
  9021. */
  9022. getDepthMinZ(activeCamera: Camera): number;
  9023. /**
  9024. * Gets the maxZ used for shadow according to both the scene and the light.
  9025. * @param activeCamera The camera we are returning the max for
  9026. * @returns the depth max z
  9027. */
  9028. getDepthMaxZ(activeCamera: Camera): number;
  9029. }
  9030. /**
  9031. * Base implementation IShadowLight
  9032. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9033. */
  9034. export abstract class ShadowLight extends Light implements IShadowLight {
  9035. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9036. protected _position: Vector3;
  9037. protected _setPosition(value: Vector3): void;
  9038. /**
  9039. * Sets the position the shadow will be casted from. Also use as the light position for both
  9040. * point and spot lights.
  9041. */
  9042. /**
  9043. * Sets the position the shadow will be casted from. Also use as the light position for both
  9044. * point and spot lights.
  9045. */
  9046. position: Vector3;
  9047. protected _direction: Vector3;
  9048. protected _setDirection(value: Vector3): void;
  9049. /**
  9050. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9051. * Also use as the light direction on spot and directional lights.
  9052. */
  9053. /**
  9054. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9055. * Also use as the light direction on spot and directional lights.
  9056. */
  9057. direction: Vector3;
  9058. private _shadowMinZ;
  9059. /**
  9060. * Gets the shadow projection clipping minimum z value.
  9061. */
  9062. /**
  9063. * Sets the shadow projection clipping minimum z value.
  9064. */
  9065. shadowMinZ: number;
  9066. private _shadowMaxZ;
  9067. /**
  9068. * Sets the shadow projection clipping maximum z value.
  9069. */
  9070. /**
  9071. * Gets the shadow projection clipping maximum z value.
  9072. */
  9073. shadowMaxZ: number;
  9074. /**
  9075. * Callback defining a custom Projection Matrix Builder.
  9076. * This can be used to override the default projection matrix computation.
  9077. */
  9078. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9079. /**
  9080. * The transformed position. Position of the light in world space taking parenting in account.
  9081. */
  9082. transformedPosition: Vector3;
  9083. /**
  9084. * The transformed direction. Direction of the light in world space taking parenting in account.
  9085. */
  9086. transformedDirection: Vector3;
  9087. private _needProjectionMatrixCompute;
  9088. /**
  9089. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9090. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9091. */
  9092. computeTransformedInformation(): boolean;
  9093. /**
  9094. * Return the depth scale used for the shadow map.
  9095. * @returns the depth scale.
  9096. */
  9097. getDepthScale(): number;
  9098. /**
  9099. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9100. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9101. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9102. */
  9103. getShadowDirection(faceIndex?: number): Vector3;
  9104. /**
  9105. * Returns the ShadowLight absolute position in the World.
  9106. * @returns the position vector in world space
  9107. */
  9108. getAbsolutePosition(): Vector3;
  9109. /**
  9110. * Sets the ShadowLight direction toward the passed target.
  9111. * @param target The point to target in local space
  9112. * @returns the updated ShadowLight direction
  9113. */
  9114. setDirectionToTarget(target: Vector3): Vector3;
  9115. /**
  9116. * Returns the light rotation in euler definition.
  9117. * @returns the x y z rotation in local space.
  9118. */
  9119. getRotation(): Vector3;
  9120. /**
  9121. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9122. * @returns true if a cube texture needs to be use
  9123. */
  9124. needCube(): boolean;
  9125. /**
  9126. * Detects if the projection matrix requires to be recomputed this frame.
  9127. * @returns true if it requires to be recomputed otherwise, false.
  9128. */
  9129. needProjectionMatrixCompute(): boolean;
  9130. /**
  9131. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9132. */
  9133. forceProjectionMatrixCompute(): void;
  9134. /** @hidden */ initCache(): void;
  9135. /** @hidden */ isSynchronized(): boolean;
  9136. /**
  9137. * Computes the world matrix of the node
  9138. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9139. * @returns the world matrix
  9140. */
  9141. computeWorldMatrix(force?: boolean): Matrix;
  9142. /**
  9143. * Gets the minZ used for shadow according to both the scene and the light.
  9144. * @param activeCamera The camera we are returning the min for
  9145. * @returns the depth min z
  9146. */
  9147. getDepthMinZ(activeCamera: Camera): number;
  9148. /**
  9149. * Gets the maxZ used for shadow according to both the scene and the light.
  9150. * @param activeCamera The camera we are returning the max for
  9151. * @returns the depth max z
  9152. */
  9153. getDepthMaxZ(activeCamera: Camera): number;
  9154. /**
  9155. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9156. * @param matrix The materix to updated with the projection information
  9157. * @param viewMatrix The transform matrix of the light
  9158. * @param renderList The list of mesh to render in the map
  9159. * @returns The current light
  9160. */
  9161. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9162. }
  9163. }
  9164. declare module BABYLON {
  9165. /**
  9166. * "Static Class" containing the most commonly used helper while dealing with material for
  9167. * rendering purpose.
  9168. *
  9169. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9170. *
  9171. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9172. */
  9173. export class MaterialHelper {
  9174. /**
  9175. * Bind the current view position to an effect.
  9176. * @param effect The effect to be bound
  9177. * @param scene The scene the eyes position is used from
  9178. */
  9179. static BindEyePosition(effect: Effect, scene: Scene): void;
  9180. /**
  9181. * Helps preparing the defines values about the UVs in used in the effect.
  9182. * UVs are shared as much as we can accross channels in the shaders.
  9183. * @param texture The texture we are preparing the UVs for
  9184. * @param defines The defines to update
  9185. * @param key The channel key "diffuse", "specular"... used in the shader
  9186. */
  9187. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9188. /**
  9189. * Binds a texture matrix value to its corrsponding uniform
  9190. * @param texture The texture to bind the matrix for
  9191. * @param uniformBuffer The uniform buffer receivin the data
  9192. * @param key The channel key "diffuse", "specular"... used in the shader
  9193. */
  9194. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9195. /**
  9196. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9197. * @param mesh defines the current mesh
  9198. * @param scene defines the current scene
  9199. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9200. * @param pointsCloud defines if point cloud rendering has to be turned on
  9201. * @param fogEnabled defines if fog has to be turned on
  9202. * @param alphaTest defines if alpha testing has to be turned on
  9203. * @param defines defines the current list of defines
  9204. */
  9205. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9206. /**
  9207. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9208. * @param scene defines the current scene
  9209. * @param engine defines the current engine
  9210. * @param defines specifies the list of active defines
  9211. * @param useInstances defines if instances have to be turned on
  9212. * @param useClipPlane defines if clip plane have to be turned on
  9213. */
  9214. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9215. /**
  9216. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9217. * @param mesh The mesh containing the geometry data we will draw
  9218. * @param defines The defines to update
  9219. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9220. * @param useBones Precise whether bones should be used or not (override mesh info)
  9221. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9222. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9223. * @returns false if defines are considered not dirty and have not been checked
  9224. */
  9225. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9226. /**
  9227. * Prepares the defines related to multiview
  9228. * @param scene The scene we are intending to draw
  9229. * @param defines The defines to update
  9230. */
  9231. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9232. /**
  9233. * Prepares the defines related to the light information passed in parameter
  9234. * @param scene The scene we are intending to draw
  9235. * @param mesh The mesh the effect is compiling for
  9236. * @param defines The defines to update
  9237. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9238. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9239. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9240. * @returns true if normals will be required for the rest of the effect
  9241. */
  9242. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9243. /**
  9244. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9245. * that won t be acctive due to defines being turned off.
  9246. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9247. * @param samplersList The samplers list
  9248. * @param defines The defines helping in the list generation
  9249. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9250. */
  9251. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9252. /**
  9253. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9254. * @param defines The defines to update while falling back
  9255. * @param fallbacks The authorized effect fallbacks
  9256. * @param maxSimultaneousLights The maximum number of lights allowed
  9257. * @param rank the current rank of the Effect
  9258. * @returns The newly affected rank
  9259. */
  9260. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9261. /**
  9262. * Prepares the list of attributes required for morph targets according to the effect defines.
  9263. * @param attribs The current list of supported attribs
  9264. * @param mesh The mesh to prepare the morph targets attributes for
  9265. * @param defines The current Defines of the effect
  9266. */
  9267. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9268. /**
  9269. * Prepares the list of attributes required for bones according to the effect defines.
  9270. * @param attribs The current list of supported attribs
  9271. * @param mesh The mesh to prepare the bones attributes for
  9272. * @param defines The current Defines of the effect
  9273. * @param fallbacks The current efffect fallback strategy
  9274. */
  9275. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9276. /**
  9277. * Prepares the list of attributes required for instances according to the effect defines.
  9278. * @param attribs The current list of supported attribs
  9279. * @param defines The current Defines of the effect
  9280. */
  9281. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9282. /**
  9283. * Binds the light shadow information to the effect for the given mesh.
  9284. * @param light The light containing the generator
  9285. * @param scene The scene the lights belongs to
  9286. * @param mesh The mesh we are binding the information to render
  9287. * @param lightIndex The light index in the effect used to render the mesh
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9291. /**
  9292. * Binds the light information to the effect.
  9293. * @param light The light containing the generator
  9294. * @param effect The effect we are binding the data to
  9295. * @param lightIndex The light index in the effect used to render
  9296. */
  9297. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9298. /**
  9299. * Binds the lights information from the scene to the effect for the given mesh.
  9300. * @param scene The scene the lights belongs to
  9301. * @param mesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. * @param defines The generated defines for the effect
  9304. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9305. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9306. */
  9307. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9308. private static _tempFogColor;
  9309. /**
  9310. * Binds the fog information from the scene to the effect for the given mesh.
  9311. * @param scene The scene the lights belongs to
  9312. * @param mesh The mesh we are binding the information to render
  9313. * @param effect The effect we are binding the data to
  9314. * @param linearSpace Defines if the fog effect is applied in linear space
  9315. */
  9316. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9317. /**
  9318. * Binds the bones information from the mesh to the effect.
  9319. * @param mesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9323. /**
  9324. * Binds the morph targets information from the mesh to the effect.
  9325. * @param abstractMesh The mesh we are binding the information to render
  9326. * @param effect The effect we are binding the data to
  9327. */
  9328. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9329. /**
  9330. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9331. * @param defines The generated defines used in the effect
  9332. * @param effect The effect we are binding the data to
  9333. * @param scene The scene we are willing to render with logarithmic scale for
  9334. */
  9335. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9336. /**
  9337. * Binds the clip plane information from the scene to the effect.
  9338. * @param scene The scene the clip plane information are extracted from
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindClipPlane(effect: Effect, scene: Scene): void;
  9342. }
  9343. }
  9344. declare module BABYLON {
  9345. /** @hidden */
  9346. export var kernelBlurVaryingDeclaration: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module BABYLON {
  9352. /** @hidden */
  9353. export var kernelBlurFragment: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module BABYLON {
  9359. /** @hidden */
  9360. export var kernelBlurFragment2: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module BABYLON {
  9366. /** @hidden */
  9367. export var kernelBlurPixelShader: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module BABYLON {
  9373. /** @hidden */
  9374. export var kernelBlurVertex: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module BABYLON {
  9380. /** @hidden */
  9381. export var kernelBlurVertexShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module BABYLON {
  9387. /**
  9388. * The Blur Post Process which blurs an image based on a kernel and direction.
  9389. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9390. */
  9391. export class BlurPostProcess extends PostProcess {
  9392. /** The direction in which to blur the image. */
  9393. direction: Vector2;
  9394. private blockCompilation;
  9395. protected _kernel: number;
  9396. protected _idealKernel: number;
  9397. protected _packedFloat: boolean;
  9398. private _staticDefines;
  9399. /**
  9400. * Sets the length in pixels of the blur sample region
  9401. */
  9402. /**
  9403. * Gets the length in pixels of the blur sample region
  9404. */
  9405. kernel: number;
  9406. /**
  9407. * Sets wether or not the blur needs to unpack/repack floats
  9408. */
  9409. /**
  9410. * Gets wether or not the blur is unpacking/repacking floats
  9411. */
  9412. packedFloat: boolean;
  9413. /**
  9414. * Creates a new instance BlurPostProcess
  9415. * @param name The name of the effect.
  9416. * @param direction The direction in which to blur the image.
  9417. * @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.
  9418. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9419. * @param camera The camera to apply the render pass to.
  9420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9421. * @param engine The engine which the post process will be applied. (default: current engine)
  9422. * @param reusable If the post process can be reused on the same frame. (default: false)
  9423. * @param textureType Type of textures used when performing the post process. (default: 0)
  9424. * @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)
  9425. */
  9426. constructor(name: string,
  9427. /** The direction in which to blur the image. */
  9428. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9429. /**
  9430. * Updates the effect with the current post process compile time values and recompiles the shader.
  9431. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9432. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9433. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9434. * @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
  9435. * @param onCompiled Called when the shader has been compiled.
  9436. * @param onError Called if there is an error when compiling a shader.
  9437. */
  9438. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9439. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9440. /**
  9441. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9442. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9443. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9444. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9445. * The gaps between physical kernels are compensated for in the weighting of the samples
  9446. * @param idealKernel Ideal blur kernel.
  9447. * @return Nearest best kernel.
  9448. */
  9449. protected _nearestBestKernel(idealKernel: number): number;
  9450. /**
  9451. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9452. * @param x The point on the Gaussian distribution to sample.
  9453. * @return the value of the Gaussian function at x.
  9454. */
  9455. protected _gaussianWeight(x: number): number;
  9456. /**
  9457. * Generates a string that can be used as a floating point number in GLSL.
  9458. * @param x Value to print.
  9459. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9460. * @return GLSL float string.
  9461. */
  9462. protected _glslFloat(x: number, decimalFigures?: number): string;
  9463. }
  9464. }
  9465. declare module BABYLON {
  9466. /** @hidden */
  9467. export var shadowMapPixelShader: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module BABYLON {
  9473. /** @hidden */
  9474. export var bonesDeclaration: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module BABYLON {
  9480. /** @hidden */
  9481. export var morphTargetsVertexGlobalDeclaration: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module BABYLON {
  9487. /** @hidden */
  9488. export var morphTargetsVertexDeclaration: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module BABYLON {
  9494. /** @hidden */
  9495. export var instancesDeclaration: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module BABYLON {
  9501. /** @hidden */
  9502. export var helperFunctions: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module BABYLON {
  9508. /** @hidden */
  9509. export var morphTargetsVertex: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module BABYLON {
  9515. /** @hidden */
  9516. export var instancesVertex: {
  9517. name: string;
  9518. shader: string;
  9519. };
  9520. }
  9521. declare module BABYLON {
  9522. /** @hidden */
  9523. export var bonesVertex: {
  9524. name: string;
  9525. shader: string;
  9526. };
  9527. }
  9528. declare module BABYLON {
  9529. /** @hidden */
  9530. export var shadowMapVertexShader: {
  9531. name: string;
  9532. shader: string;
  9533. };
  9534. }
  9535. declare module BABYLON {
  9536. /** @hidden */
  9537. export var depthBoxBlurPixelShader: {
  9538. name: string;
  9539. shader: string;
  9540. };
  9541. }
  9542. declare module BABYLON {
  9543. /**
  9544. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9545. */
  9546. export interface ICustomShaderOptions {
  9547. /**
  9548. * Gets or sets the custom shader name to use
  9549. */
  9550. shaderName: string;
  9551. /**
  9552. * The list of attribute names used in the shader
  9553. */
  9554. attributes?: string[];
  9555. /**
  9556. * The list of unifrom names used in the shader
  9557. */
  9558. uniforms?: string[];
  9559. /**
  9560. * The list of sampler names used in the shader
  9561. */
  9562. samplers?: string[];
  9563. /**
  9564. * The list of defines used in the shader
  9565. */
  9566. defines?: string[];
  9567. }
  9568. /**
  9569. * Interface to implement to create a shadow generator compatible with BJS.
  9570. */
  9571. export interface IShadowGenerator {
  9572. /**
  9573. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9574. * @returns The render target texture if present otherwise, null
  9575. */
  9576. getShadowMap(): Nullable<RenderTargetTexture>;
  9577. /**
  9578. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9579. * @returns The render target texture if the shadow map is present otherwise, null
  9580. */
  9581. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9582. /**
  9583. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9584. * @param subMesh The submesh we want to render in the shadow map
  9585. * @param useInstances Defines wether will draw in the map using instances
  9586. * @returns true if ready otherwise, false
  9587. */
  9588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9589. /**
  9590. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9591. * @param defines Defines of the material we want to update
  9592. * @param lightIndex Index of the light in the enabled light list of the material
  9593. */
  9594. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9595. /**
  9596. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9597. * defined in the generator but impacting the effect).
  9598. * It implies the unifroms available on the materials are the standard BJS ones.
  9599. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9600. * @param effect The effect we are binfing the information for
  9601. */
  9602. bindShadowLight(lightIndex: string, effect: Effect): void;
  9603. /**
  9604. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9605. * (eq to shadow prjection matrix * light transform matrix)
  9606. * @returns The transform matrix used to create the shadow map
  9607. */
  9608. getTransformMatrix(): Matrix;
  9609. /**
  9610. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9611. * Cube and 2D textures for instance.
  9612. */
  9613. recreateShadowMap(): void;
  9614. /**
  9615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9616. * @param onCompiled Callback triggered at the and of the effects compilation
  9617. * @param options Sets of optional options forcing the compilation with different modes
  9618. */
  9619. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9620. useInstances: boolean;
  9621. }>): void;
  9622. /**
  9623. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9624. * @param options Sets of optional options forcing the compilation with different modes
  9625. * @returns A promise that resolves when the compilation completes
  9626. */
  9627. forceCompilationAsync(options?: Partial<{
  9628. useInstances: boolean;
  9629. }>): Promise<void>;
  9630. /**
  9631. * Serializes the shadow generator setup to a json object.
  9632. * @returns The serialized JSON object
  9633. */
  9634. serialize(): any;
  9635. /**
  9636. * Disposes the Shadow map and related Textures and effects.
  9637. */
  9638. dispose(): void;
  9639. }
  9640. /**
  9641. * Default implementation IShadowGenerator.
  9642. * This is the main object responsible of generating shadows in the framework.
  9643. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9644. */
  9645. export class ShadowGenerator implements IShadowGenerator {
  9646. /**
  9647. * Shadow generator mode None: no filtering applied.
  9648. */
  9649. static readonly FILTER_NONE: number;
  9650. /**
  9651. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9653. */
  9654. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9655. /**
  9656. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9657. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9658. */
  9659. static readonly FILTER_POISSONSAMPLING: number;
  9660. /**
  9661. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9663. */
  9664. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9665. /**
  9666. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9667. * edge artifacts on steep falloff.
  9668. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9669. */
  9670. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9673. * edge artifacts on steep falloff.
  9674. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9675. */
  9676. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9677. /**
  9678. * Shadow generator mode PCF: Percentage Closer Filtering
  9679. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9680. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9681. */
  9682. static readonly FILTER_PCF: number;
  9683. /**
  9684. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9685. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9686. * Contact Hardening
  9687. */
  9688. static readonly FILTER_PCSS: number;
  9689. /**
  9690. * Reserved for PCF and PCSS
  9691. * Highest Quality.
  9692. *
  9693. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9694. *
  9695. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9696. */
  9697. static readonly QUALITY_HIGH: number;
  9698. /**
  9699. * Reserved for PCF and PCSS
  9700. * Good tradeoff for quality/perf cross devices
  9701. *
  9702. * Execute PCF on a 3*3 kernel.
  9703. *
  9704. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9705. */
  9706. static readonly QUALITY_MEDIUM: number;
  9707. /**
  9708. * Reserved for PCF and PCSS
  9709. * The lowest quality but the fastest.
  9710. *
  9711. * Execute PCF on a 1*1 kernel.
  9712. *
  9713. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9714. */
  9715. static readonly QUALITY_LOW: number;
  9716. /** Gets or sets the custom shader name to use */
  9717. customShaderOptions: ICustomShaderOptions;
  9718. /**
  9719. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9720. */
  9721. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9722. /**
  9723. * Observable triggered before a mesh is rendered in the shadow map.
  9724. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9725. */
  9726. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9727. private _bias;
  9728. /**
  9729. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9730. */
  9731. /**
  9732. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9733. */
  9734. bias: number;
  9735. private _normalBias;
  9736. /**
  9737. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9738. */
  9739. /**
  9740. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9741. */
  9742. normalBias: number;
  9743. private _blurBoxOffset;
  9744. /**
  9745. * Gets the blur box offset: offset applied during the blur pass.
  9746. * Only useful if useKernelBlur = false
  9747. */
  9748. /**
  9749. * Sets the blur box offset: offset applied during the blur pass.
  9750. * Only useful if useKernelBlur = false
  9751. */
  9752. blurBoxOffset: number;
  9753. private _blurScale;
  9754. /**
  9755. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9756. * 2 means half of the size.
  9757. */
  9758. /**
  9759. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9760. * 2 means half of the size.
  9761. */
  9762. blurScale: number;
  9763. private _blurKernel;
  9764. /**
  9765. * Gets the blur kernel: kernel size of the blur pass.
  9766. * Only useful if useKernelBlur = true
  9767. */
  9768. /**
  9769. * Sets the blur kernel: kernel size of the blur pass.
  9770. * Only useful if useKernelBlur = true
  9771. */
  9772. blurKernel: number;
  9773. private _useKernelBlur;
  9774. /**
  9775. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9776. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9777. */
  9778. /**
  9779. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9780. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9781. */
  9782. useKernelBlur: boolean;
  9783. private _depthScale;
  9784. /**
  9785. * Gets the depth scale used in ESM mode.
  9786. */
  9787. /**
  9788. * Sets the depth scale used in ESM mode.
  9789. * This can override the scale stored on the light.
  9790. */
  9791. depthScale: number;
  9792. private _filter;
  9793. /**
  9794. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9795. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9796. */
  9797. /**
  9798. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9800. */
  9801. filter: number;
  9802. /**
  9803. * Gets if the current filter is set to Poisson Sampling.
  9804. */
  9805. /**
  9806. * Sets the current filter to Poisson Sampling.
  9807. */
  9808. usePoissonSampling: boolean;
  9809. /**
  9810. * Gets if the current filter is set to ESM.
  9811. */
  9812. /**
  9813. * Sets the current filter is to ESM.
  9814. */
  9815. useExponentialShadowMap: boolean;
  9816. /**
  9817. * Gets if the current filter is set to filtered ESM.
  9818. */
  9819. /**
  9820. * Gets if the current filter is set to filtered ESM.
  9821. */
  9822. useBlurExponentialShadowMap: boolean;
  9823. /**
  9824. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9825. * exponential to prevent steep falloff artifacts).
  9826. */
  9827. /**
  9828. * Sets the current filter to "close ESM" (using the inverse of the
  9829. * exponential to prevent steep falloff artifacts).
  9830. */
  9831. useCloseExponentialShadowMap: boolean;
  9832. /**
  9833. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. /**
  9837. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9838. * exponential to prevent steep falloff artifacts).
  9839. */
  9840. useBlurCloseExponentialShadowMap: boolean;
  9841. /**
  9842. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9843. */
  9844. /**
  9845. * Sets the current filter to "PCF" (percentage closer filtering).
  9846. */
  9847. usePercentageCloserFiltering: boolean;
  9848. private _filteringQuality;
  9849. /**
  9850. * Gets the PCF or PCSS Quality.
  9851. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9852. */
  9853. /**
  9854. * Sets the PCF or PCSS Quality.
  9855. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9856. */
  9857. filteringQuality: number;
  9858. /**
  9859. * Gets if the current filter is set to "PCSS" (contact hardening).
  9860. */
  9861. /**
  9862. * Sets the current filter to "PCSS" (contact hardening).
  9863. */
  9864. useContactHardeningShadow: boolean;
  9865. private _contactHardeningLightSizeUVRatio;
  9866. /**
  9867. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9868. * Using a ratio helps keeping shape stability independently of the map size.
  9869. *
  9870. * It does not account for the light projection as it was having too much
  9871. * instability during the light setup or during light position changes.
  9872. *
  9873. * Only valid if useContactHardeningShadow is true.
  9874. */
  9875. /**
  9876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9877. * Using a ratio helps keeping shape stability independently of the map size.
  9878. *
  9879. * It does not account for the light projection as it was having too much
  9880. * instability during the light setup or during light position changes.
  9881. *
  9882. * Only valid if useContactHardeningShadow is true.
  9883. */
  9884. contactHardeningLightSizeUVRatio: number;
  9885. private _darkness;
  9886. /**
  9887. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9888. * 0 means strongest and 1 would means no shadow.
  9889. * @returns the darkness.
  9890. */
  9891. getDarkness(): number;
  9892. /**
  9893. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9894. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9895. * @returns the shadow generator allowing fluent coding.
  9896. */
  9897. setDarkness(darkness: number): ShadowGenerator;
  9898. private _transparencyShadow;
  9899. /**
  9900. * Sets the ability to have transparent shadow (boolean).
  9901. * @param transparent True if transparent else False
  9902. * @returns the shadow generator allowing fluent coding
  9903. */
  9904. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9905. private _shadowMap;
  9906. private _shadowMap2;
  9907. /**
  9908. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9909. * @returns The render target texture if present otherwise, null
  9910. */
  9911. getShadowMap(): Nullable<RenderTargetTexture>;
  9912. /**
  9913. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9914. * @returns The render target texture if the shadow map is present otherwise, null
  9915. */
  9916. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9917. /**
  9918. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9919. * @param mesh Mesh to add
  9920. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9921. * @returns the Shadow Generator itself
  9922. */
  9923. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9924. /**
  9925. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9926. * @param mesh Mesh to remove
  9927. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9928. * @returns the Shadow Generator itself
  9929. */
  9930. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9931. /**
  9932. * Controls the extent to which the shadows fade out at the edge of the frustum
  9933. * Used only by directionals and spots
  9934. */
  9935. frustumEdgeFalloff: number;
  9936. private _light;
  9937. /**
  9938. * Returns the associated light object.
  9939. * @returns the light generating the shadow
  9940. */
  9941. getLight(): IShadowLight;
  9942. /**
  9943. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9944. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9945. * It might on the other hand introduce peter panning.
  9946. */
  9947. forceBackFacesOnly: boolean;
  9948. private _scene;
  9949. private _lightDirection;
  9950. private _effect;
  9951. private _viewMatrix;
  9952. private _projectionMatrix;
  9953. private _transformMatrix;
  9954. private _cachedPosition;
  9955. private _cachedDirection;
  9956. private _cachedDefines;
  9957. private _currentRenderID;
  9958. private _boxBlurPostprocess;
  9959. private _kernelBlurXPostprocess;
  9960. private _kernelBlurYPostprocess;
  9961. private _blurPostProcesses;
  9962. private _mapSize;
  9963. private _currentFaceIndex;
  9964. private _currentFaceIndexCache;
  9965. private _textureType;
  9966. private _defaultTextureMatrix;
  9967. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9968. /**
  9969. * Creates a ShadowGenerator object.
  9970. * A ShadowGenerator is the required tool to use the shadows.
  9971. * Each light casting shadows needs to use its own ShadowGenerator.
  9972. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9973. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9974. * @param light The light object generating the shadows.
  9975. * @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.
  9976. */
  9977. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9978. private _initializeGenerator;
  9979. private _initializeShadowMap;
  9980. private _initializeBlurRTTAndPostProcesses;
  9981. private _renderForShadowMap;
  9982. private _renderSubMeshForShadowMap;
  9983. private _applyFilterValues;
  9984. /**
  9985. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9986. * @param onCompiled Callback triggered at the and of the effects compilation
  9987. * @param options Sets of optional options forcing the compilation with different modes
  9988. */
  9989. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9990. useInstances: boolean;
  9991. }>): void;
  9992. /**
  9993. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9994. * @param options Sets of optional options forcing the compilation with different modes
  9995. * @returns A promise that resolves when the compilation completes
  9996. */
  9997. forceCompilationAsync(options?: Partial<{
  9998. useInstances: boolean;
  9999. }>): Promise<void>;
  10000. /**
  10001. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10002. * @param subMesh The submesh we want to render in the shadow map
  10003. * @param useInstances Defines wether will draw in the map using instances
  10004. * @returns true if ready otherwise, false
  10005. */
  10006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10007. /**
  10008. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10009. * @param defines Defines of the material we want to update
  10010. * @param lightIndex Index of the light in the enabled light list of the material
  10011. */
  10012. prepareDefines(defines: any, lightIndex: number): void;
  10013. /**
  10014. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10015. * defined in the generator but impacting the effect).
  10016. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10017. * @param effect The effect we are binfing the information for
  10018. */
  10019. bindShadowLight(lightIndex: string, effect: Effect): void;
  10020. /**
  10021. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10022. * (eq to shadow prjection matrix * light transform matrix)
  10023. * @returns The transform matrix used to create the shadow map
  10024. */
  10025. getTransformMatrix(): Matrix;
  10026. /**
  10027. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10028. * Cube and 2D textures for instance.
  10029. */
  10030. recreateShadowMap(): void;
  10031. private _disposeBlurPostProcesses;
  10032. private _disposeRTTandPostProcesses;
  10033. /**
  10034. * Disposes the ShadowGenerator.
  10035. * Returns nothing.
  10036. */
  10037. dispose(): void;
  10038. /**
  10039. * Serializes the shadow generator setup to a json object.
  10040. * @returns The serialized JSON object
  10041. */
  10042. serialize(): any;
  10043. /**
  10044. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10045. * @param parsedShadowGenerator The JSON object to parse
  10046. * @param scene The scene to create the shadow map for
  10047. * @returns The parsed shadow generator
  10048. */
  10049. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10050. }
  10051. }
  10052. declare module BABYLON {
  10053. /**
  10054. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10055. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10056. * 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.
  10057. */
  10058. export abstract class Light extends Node {
  10059. /**
  10060. * Falloff Default: light is falling off following the material specification:
  10061. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10062. */
  10063. static readonly FALLOFF_DEFAULT: number;
  10064. /**
  10065. * Falloff Physical: light is falling off following the inverse squared distance law.
  10066. */
  10067. static readonly FALLOFF_PHYSICAL: number;
  10068. /**
  10069. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10070. * to enhance interoperability with other engines.
  10071. */
  10072. static readonly FALLOFF_GLTF: number;
  10073. /**
  10074. * Falloff Standard: light is falling off like in the standard material
  10075. * to enhance interoperability with other materials.
  10076. */
  10077. static readonly FALLOFF_STANDARD: number;
  10078. /**
  10079. * If every light affecting the material is in this lightmapMode,
  10080. * material.lightmapTexture adds or multiplies
  10081. * (depends on material.useLightmapAsShadowmap)
  10082. * after every other light calculations.
  10083. */
  10084. static readonly LIGHTMAP_DEFAULT: number;
  10085. /**
  10086. * material.lightmapTexture as only diffuse lighting from this light
  10087. * adds only specular lighting from this light
  10088. * adds dynamic shadows
  10089. */
  10090. static readonly LIGHTMAP_SPECULAR: number;
  10091. /**
  10092. * material.lightmapTexture as only lighting
  10093. * no light calculation from this light
  10094. * only adds dynamic shadows from this light
  10095. */
  10096. static readonly LIGHTMAP_SHADOWSONLY: number;
  10097. /**
  10098. * Each light type uses the default quantity according to its type:
  10099. * point/spot lights use luminous intensity
  10100. * directional lights use illuminance
  10101. */
  10102. static readonly INTENSITYMODE_AUTOMATIC: number;
  10103. /**
  10104. * lumen (lm)
  10105. */
  10106. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10107. /**
  10108. * candela (lm/sr)
  10109. */
  10110. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10111. /**
  10112. * lux (lm/m^2)
  10113. */
  10114. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10115. /**
  10116. * nit (cd/m^2)
  10117. */
  10118. static readonly INTENSITYMODE_LUMINANCE: number;
  10119. /**
  10120. * Light type const id of the point light.
  10121. */
  10122. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10123. /**
  10124. * Light type const id of the directional light.
  10125. */
  10126. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10127. /**
  10128. * Light type const id of the spot light.
  10129. */
  10130. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10131. /**
  10132. * Light type const id of the hemispheric light.
  10133. */
  10134. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10135. /**
  10136. * Diffuse gives the basic color to an object.
  10137. */
  10138. diffuse: Color3;
  10139. /**
  10140. * Specular produces a highlight color on an object.
  10141. * Note: This is note affecting PBR materials.
  10142. */
  10143. specular: Color3;
  10144. /**
  10145. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10146. * falling off base on range or angle.
  10147. * This can be set to any values in Light.FALLOFF_x.
  10148. *
  10149. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10150. * other types of materials.
  10151. */
  10152. falloffType: number;
  10153. /**
  10154. * Strength of the light.
  10155. * Note: By default it is define in the framework own unit.
  10156. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10157. */
  10158. intensity: number;
  10159. private _range;
  10160. protected _inverseSquaredRange: number;
  10161. /**
  10162. * Defines how far from the source the light is impacting in scene units.
  10163. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10164. */
  10165. /**
  10166. * Defines how far from the source the light is impacting in scene units.
  10167. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10168. */
  10169. range: number;
  10170. /**
  10171. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10172. * of light.
  10173. */
  10174. private _photometricScale;
  10175. private _intensityMode;
  10176. /**
  10177. * Gets the photometric scale used to interpret the intensity.
  10178. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10179. */
  10180. /**
  10181. * Sets the photometric scale used to interpret the intensity.
  10182. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10183. */
  10184. intensityMode: number;
  10185. private _radius;
  10186. /**
  10187. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10188. */
  10189. /**
  10190. * sets the light radius used by PBR Materials to simulate soft area lights.
  10191. */
  10192. radius: number;
  10193. private _renderPriority;
  10194. /**
  10195. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10196. * exceeding the number allowed of the materials.
  10197. */
  10198. renderPriority: number;
  10199. private _shadowEnabled;
  10200. /**
  10201. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10202. * the current shadow generator.
  10203. */
  10204. /**
  10205. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10206. * the current shadow generator.
  10207. */
  10208. shadowEnabled: boolean;
  10209. private _includedOnlyMeshes;
  10210. /**
  10211. * Gets the only meshes impacted by this light.
  10212. */
  10213. /**
  10214. * Sets the only meshes impacted by this light.
  10215. */
  10216. includedOnlyMeshes: AbstractMesh[];
  10217. private _excludedMeshes;
  10218. /**
  10219. * Gets the meshes not impacted by this light.
  10220. */
  10221. /**
  10222. * Sets the meshes not impacted by this light.
  10223. */
  10224. excludedMeshes: AbstractMesh[];
  10225. private _excludeWithLayerMask;
  10226. /**
  10227. * Gets the layer id use to find what meshes are not impacted by the light.
  10228. * Inactive if 0
  10229. */
  10230. /**
  10231. * Sets the layer id use to find what meshes are not impacted by the light.
  10232. * Inactive if 0
  10233. */
  10234. excludeWithLayerMask: number;
  10235. private _includeOnlyWithLayerMask;
  10236. /**
  10237. * Gets the layer id use to find what meshes are impacted by the light.
  10238. * Inactive if 0
  10239. */
  10240. /**
  10241. * Sets the layer id use to find what meshes are impacted by the light.
  10242. * Inactive if 0
  10243. */
  10244. includeOnlyWithLayerMask: number;
  10245. private _lightmapMode;
  10246. /**
  10247. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10248. */
  10249. /**
  10250. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10251. */
  10252. lightmapMode: number;
  10253. /**
  10254. * Shadow generator associted to the light.
  10255. * @hidden Internal use only.
  10256. */ shadowGenerator: Nullable<IShadowGenerator>;
  10257. /**
  10258. * @hidden Internal use only.
  10259. */ excludedMeshesIds: string[];
  10260. /**
  10261. * @hidden Internal use only.
  10262. */ includedOnlyMeshesIds: string[];
  10263. /**
  10264. * The current light unifom buffer.
  10265. * @hidden Internal use only.
  10266. */ uniformBuffer: UniformBuffer;
  10267. /**
  10268. * Creates a Light object in the scene.
  10269. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10270. * @param name The firendly name of the light
  10271. * @param scene The scene the light belongs too
  10272. */
  10273. constructor(name: string, scene: Scene);
  10274. protected abstract _buildUniformLayout(): void;
  10275. /**
  10276. * Sets the passed Effect "effect" with the Light information.
  10277. * @param effect The effect to update
  10278. * @param lightIndex The index of the light in the effect to update
  10279. * @returns The light
  10280. */
  10281. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10282. /**
  10283. * Returns the string "Light".
  10284. * @returns the class name
  10285. */
  10286. getClassName(): string;
  10287. /** @hidden */ protected readonly _isLight: boolean;
  10288. /**
  10289. * Converts the light information to a readable string for debug purpose.
  10290. * @param fullDetails Supports for multiple levels of logging within scene loading
  10291. * @returns the human readable light info
  10292. */
  10293. toString(fullDetails?: boolean): string;
  10294. /** @hidden */
  10295. protected _syncParentEnabledState(): void;
  10296. /**
  10297. * Set the enabled state of this node.
  10298. * @param value - the new enabled state
  10299. */
  10300. setEnabled(value: boolean): void;
  10301. /**
  10302. * Returns the Light associated shadow generator if any.
  10303. * @return the associated shadow generator.
  10304. */
  10305. getShadowGenerator(): Nullable<IShadowGenerator>;
  10306. /**
  10307. * Returns a Vector3, the absolute light position in the World.
  10308. * @returns the world space position of the light
  10309. */
  10310. getAbsolutePosition(): Vector3;
  10311. /**
  10312. * Specifies if the light will affect the passed mesh.
  10313. * @param mesh The mesh to test against the light
  10314. * @return true the mesh is affected otherwise, false.
  10315. */
  10316. canAffectMesh(mesh: AbstractMesh): boolean;
  10317. /**
  10318. * Sort function to order lights for rendering.
  10319. * @param a First Light object to compare to second.
  10320. * @param b Second Light object to compare first.
  10321. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10322. */
  10323. static CompareLightsPriority(a: Light, b: Light): number;
  10324. /**
  10325. * Releases resources associated with this node.
  10326. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10327. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10328. */
  10329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10330. /**
  10331. * Returns the light type ID (integer).
  10332. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10333. */
  10334. getTypeID(): number;
  10335. /**
  10336. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10337. * @returns the scaled intensity in intensity mode unit
  10338. */
  10339. getScaledIntensity(): number;
  10340. /**
  10341. * Returns a new Light object, named "name", from the current one.
  10342. * @param name The name of the cloned light
  10343. * @returns the new created light
  10344. */
  10345. clone(name: string): Nullable<Light>;
  10346. /**
  10347. * Serializes the current light into a Serialization object.
  10348. * @returns the serialized object.
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10353. * This new light is named "name" and added to the passed scene.
  10354. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10355. * @param name The friendly name of the light
  10356. * @param scene The scene the new light will belong to
  10357. * @returns the constructor function
  10358. */
  10359. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10360. /**
  10361. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10362. * @param parsedLight The JSON representation of the light
  10363. * @param scene The scene to create the parsed light in
  10364. * @returns the created light after parsing
  10365. */
  10366. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10367. private _hookArrayForExcluded;
  10368. private _hookArrayForIncludedOnly;
  10369. private _resyncMeshes;
  10370. /**
  10371. * Forces the meshes to update their light related information in their rendering used effects
  10372. * @hidden Internal Use Only
  10373. */ markMeshesAsLightDirty(): void;
  10374. /**
  10375. * Recomputes the cached photometric scale if needed.
  10376. */
  10377. private _computePhotometricScale;
  10378. /**
  10379. * Returns the Photometric Scale according to the light type and intensity mode.
  10380. */
  10381. private _getPhotometricScale;
  10382. /**
  10383. * Reorder the light in the scene according to their defined priority.
  10384. * @hidden Internal Use Only
  10385. */ reorderLightsInScene(): void;
  10386. /**
  10387. * Prepares the list of defines specific to the light type.
  10388. * @param defines the list of defines
  10389. * @param lightIndex defines the index of the light for the effect
  10390. */
  10391. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10392. }
  10393. }
  10394. declare module BABYLON {
  10395. /**
  10396. * Interface used to define Action
  10397. */
  10398. export interface IAction {
  10399. /**
  10400. * Trigger for the action
  10401. */
  10402. trigger: number;
  10403. /** Options of the trigger */
  10404. triggerOptions: any;
  10405. /**
  10406. * Gets the trigger parameters
  10407. * @returns the trigger parameters
  10408. */
  10409. getTriggerParameter(): any;
  10410. /**
  10411. * Internal only - executes current action event
  10412. * @hidden
  10413. */ executeCurrent(evt?: ActionEvent): void;
  10414. /**
  10415. * Serialize placeholder for child classes
  10416. * @param parent of child
  10417. * @returns the serialized object
  10418. */
  10419. serialize(parent: any): any;
  10420. /**
  10421. * Internal only
  10422. * @hidden
  10423. */ prepare(): void;
  10424. /**
  10425. * Internal only - manager for action
  10426. * @hidden
  10427. */ actionManager: AbstractActionManager;
  10428. }
  10429. /**
  10430. * The action to be carried out following a trigger
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10432. */
  10433. export class Action implements IAction {
  10434. /** the trigger, with or without parameters, for the action */
  10435. triggerOptions: any;
  10436. /**
  10437. * Trigger for the action
  10438. */
  10439. trigger: number;
  10440. /**
  10441. * Internal only - manager for action
  10442. * @hidden
  10443. */ actionManager: ActionManager;
  10444. private _nextActiveAction;
  10445. private _child;
  10446. private _condition?;
  10447. private _triggerParameter;
  10448. /**
  10449. * An event triggered prior to action being executed.
  10450. */
  10451. onBeforeExecuteObservable: Observable<Action>;
  10452. /**
  10453. * Creates a new Action
  10454. * @param triggerOptions the trigger, with or without parameters, for the action
  10455. * @param condition an optional determinant of action
  10456. */
  10457. constructor(
  10458. /** the trigger, with or without parameters, for the action */
  10459. triggerOptions: any, condition?: Condition);
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */ prepare(): void;
  10464. /**
  10465. * Gets the trigger parameters
  10466. * @returns the trigger parameters
  10467. */
  10468. getTriggerParameter(): any;
  10469. /**
  10470. * Internal only - executes current action event
  10471. * @hidden
  10472. */ executeCurrent(evt?: ActionEvent): void;
  10473. /**
  10474. * Execute placeholder for child classes
  10475. * @param evt optional action event
  10476. */
  10477. execute(evt?: ActionEvent): void;
  10478. /**
  10479. * Skips to next active action
  10480. */
  10481. skipToNextActiveAction(): void;
  10482. /**
  10483. * Adds action to chain of actions, may be a DoNothingAction
  10484. * @param action defines the next action to execute
  10485. * @returns The action passed in
  10486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10487. */
  10488. then(action: Action): Action;
  10489. /**
  10490. * Internal only
  10491. * @hidden
  10492. */ getProperty(propertyPath: string): string;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10497. /**
  10498. * Serialize placeholder for child classes
  10499. * @param parent of child
  10500. * @returns the serialized object
  10501. */
  10502. serialize(parent: any): any;
  10503. /**
  10504. * Internal only called by serialize
  10505. * @hidden
  10506. */
  10507. protected _serialize(serializedAction: any, parent?: any): any;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */ private static _SerializeValueAsString: (value: any) => string;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10516. name: string;
  10517. targetType: string;
  10518. value: string;
  10519. };
  10520. }
  10521. }
  10522. declare module BABYLON {
  10523. /**
  10524. * A Condition applied to an Action
  10525. */
  10526. export class Condition {
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */ actionManager: ActionManager;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */ evaluationId: number;
  10535. /**
  10536. * Internal only
  10537. * @hidden
  10538. */ currentResult: boolean;
  10539. /**
  10540. * Creates a new Condition
  10541. * @param actionManager the manager of the action the condition is applied to
  10542. */
  10543. constructor(actionManager: ActionManager);
  10544. /**
  10545. * Check if the current condition is valid
  10546. * @returns a boolean
  10547. */
  10548. isValid(): boolean;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ getProperty(propertyPath: string): string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10557. /**
  10558. * Serialize placeholder for child classes
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. /**
  10563. * Internal only
  10564. * @hidden
  10565. */
  10566. protected _serialize(serializedCondition: any): any;
  10567. }
  10568. /**
  10569. * Defines specific conditional operators as extensions of Condition
  10570. */
  10571. export class ValueCondition extends Condition {
  10572. /** path to specify the property of the target the conditional operator uses */
  10573. propertyPath: string;
  10574. /** the value compared by the conditional operator against the current value of the property */
  10575. value: any;
  10576. /** the conditional operator, default ValueCondition.IsEqual */
  10577. operator: number;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. private static _IsEqual;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private static _IsDifferent;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. private static _IsGreater;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. private static _IsLesser;
  10598. /**
  10599. * returns the number for IsEqual
  10600. */
  10601. static readonly IsEqual: number;
  10602. /**
  10603. * Returns the number for IsDifferent
  10604. */
  10605. static readonly IsDifferent: number;
  10606. /**
  10607. * Returns the number for IsGreater
  10608. */
  10609. static readonly IsGreater: number;
  10610. /**
  10611. * Returns the number for IsLesser
  10612. */
  10613. static readonly IsLesser: number;
  10614. /**
  10615. * Internal only The action manager for the condition
  10616. * @hidden
  10617. */ actionManager: ActionManager;
  10618. /**
  10619. * Internal only
  10620. * @hidden
  10621. */
  10622. private _target;
  10623. /**
  10624. * Internal only
  10625. * @hidden
  10626. */
  10627. private _effectiveTarget;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. private _property;
  10633. /**
  10634. * Creates a new ValueCondition
  10635. * @param actionManager manager for the action the condition applies to
  10636. * @param target for the action
  10637. * @param propertyPath path to specify the property of the target the conditional operator uses
  10638. * @param value the value compared by the conditional operator against the current value of the property
  10639. * @param operator the conditional operator, default ValueCondition.IsEqual
  10640. */
  10641. constructor(actionManager: ActionManager, target: any,
  10642. /** path to specify the property of the target the conditional operator uses */
  10643. propertyPath: string,
  10644. /** the value compared by the conditional operator against the current value of the property */
  10645. value: any,
  10646. /** the conditional operator, default ValueCondition.IsEqual */
  10647. operator?: number);
  10648. /**
  10649. * Compares the given value with the property value for the specified conditional operator
  10650. * @returns the result of the comparison
  10651. */
  10652. isValid(): boolean;
  10653. /**
  10654. * Serialize the ValueCondition into a JSON compatible object
  10655. * @returns serialization object
  10656. */
  10657. serialize(): any;
  10658. /**
  10659. * Gets the name of the conditional operator for the ValueCondition
  10660. * @param operator the conditional operator
  10661. * @returns the name
  10662. */
  10663. static GetOperatorName(operator: number): string;
  10664. }
  10665. /**
  10666. * Defines a predicate condition as an extension of Condition
  10667. */
  10668. export class PredicateCondition extends Condition {
  10669. /** defines the predicate function used to validate the condition */
  10670. predicate: () => boolean;
  10671. /**
  10672. * Internal only - manager for action
  10673. * @hidden
  10674. */ actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */ actionManager: ActionManager;
  10698. /**
  10699. * Internal only
  10700. * @hidden
  10701. */
  10702. private _target;
  10703. /**
  10704. * Creates a new StateCondition
  10705. * @param actionManager manager for the action the condition applies to
  10706. * @param target of the condition
  10707. * @param value to compare with target state
  10708. */
  10709. constructor(actionManager: ActionManager, target: any,
  10710. /** Value to compare with target state */
  10711. value: string);
  10712. /**
  10713. * Gets a boolean indicating if the current condition is met
  10714. * @returns the validity of the state
  10715. */
  10716. isValid(): boolean;
  10717. /**
  10718. * Serialize the StateCondition into a JSON compatible object
  10719. * @returns serialization object
  10720. */
  10721. serialize(): any;
  10722. }
  10723. }
  10724. declare module BABYLON {
  10725. /**
  10726. * This defines an action responsible to toggle a boolean once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class SwitchBooleanAction extends Action {
  10730. /**
  10731. * The path to the boolean property in the target object
  10732. */
  10733. propertyPath: string;
  10734. private _target;
  10735. private _effectiveTarget;
  10736. private _property;
  10737. /**
  10738. * Instantiate the action
  10739. * @param triggerOptions defines the trigger options
  10740. * @param target defines the object containing the boolean
  10741. * @param propertyPath defines the path to the boolean property in the target object
  10742. * @param condition defines the trigger related conditions
  10743. */
  10744. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10745. /** @hidden */ prepare(): void;
  10746. /**
  10747. * Execute the action toggle the boolean value.
  10748. */
  10749. execute(): void;
  10750. /**
  10751. * Serializes the actions and its related information.
  10752. * @param parent defines the object to serialize in
  10753. * @returns the serialized object
  10754. */
  10755. serialize(parent: any): any;
  10756. }
  10757. /**
  10758. * This defines an action responsible to set a the state field of the target
  10759. * to a desired value once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class SetStateAction extends Action {
  10763. /**
  10764. * The value to store in the state field.
  10765. */
  10766. value: string;
  10767. private _target;
  10768. /**
  10769. * Instantiate the action
  10770. * @param triggerOptions defines the trigger options
  10771. * @param target defines the object containing the state property
  10772. * @param value defines the value to store in the state field
  10773. * @param condition defines the trigger related conditions
  10774. */
  10775. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10776. /**
  10777. * Execute the action and store the value on the target state property.
  10778. */
  10779. execute(): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to set a property of the target
  10789. * to a desired value once triggered.
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10791. */
  10792. export class SetValueAction extends Action {
  10793. /**
  10794. * The path of the property to set in the target.
  10795. */
  10796. propertyPath: string;
  10797. /**
  10798. * The value to set in the property
  10799. */
  10800. value: any;
  10801. private _target;
  10802. private _effectiveTarget;
  10803. private _property;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param target defines the object containing the property
  10808. * @param propertyPath defines the path of the property to set in the target
  10809. * @param value defines the value to set in the property
  10810. * @param condition defines the trigger related conditions
  10811. */
  10812. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10813. /** @hidden */ prepare(): void;
  10814. /**
  10815. * Execute the action and set the targetted property to the desired value.
  10816. */
  10817. execute(): void;
  10818. /**
  10819. * Serializes the actions and its related information.
  10820. * @param parent defines the object to serialize in
  10821. * @returns the serialized object
  10822. */
  10823. serialize(parent: any): any;
  10824. }
  10825. /**
  10826. * This defines an action responsible to increment the target value
  10827. * to a desired value once triggered.
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10829. */
  10830. export class IncrementValueAction extends Action {
  10831. /**
  10832. * The path of the property to increment in the target.
  10833. */
  10834. propertyPath: string;
  10835. /**
  10836. * The value we should increment the property by.
  10837. */
  10838. value: any;
  10839. private _target;
  10840. private _effectiveTarget;
  10841. private _property;
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param target defines the object containing the property
  10846. * @param propertyPath defines the path of the property to increment in the target
  10847. * @param value defines the value value we should increment the property by
  10848. * @param condition defines the trigger related conditions
  10849. */
  10850. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10851. /** @hidden */ prepare(): void;
  10852. /**
  10853. * Execute the action and increment the target of the value amount.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. /**
  10864. * This defines an action responsible to start an animation once triggered.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10866. */
  10867. export class PlayAnimationAction extends Action {
  10868. /**
  10869. * Where the animation should start (animation frame)
  10870. */
  10871. from: number;
  10872. /**
  10873. * Where the animation should stop (animation frame)
  10874. */
  10875. to: number;
  10876. /**
  10877. * Define if the animation should loop or stop after the first play.
  10878. */
  10879. loop?: boolean;
  10880. private _target;
  10881. /**
  10882. * Instantiate the action
  10883. * @param triggerOptions defines the trigger options
  10884. * @param target defines the target animation or animation name
  10885. * @param from defines from where the animation should start (animation frame)
  10886. * @param end defines where the animation should stop (animation frame)
  10887. * @param loop defines if the animation should loop or stop after the first play
  10888. * @param condition defines the trigger related conditions
  10889. */
  10890. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10891. /** @hidden */ prepare(): void;
  10892. /**
  10893. * Execute the action and play the animation.
  10894. */
  10895. execute(): void;
  10896. /**
  10897. * Serializes the actions and its related information.
  10898. * @param parent defines the object to serialize in
  10899. * @returns the serialized object
  10900. */
  10901. serialize(parent: any): any;
  10902. }
  10903. /**
  10904. * This defines an action responsible to stop an animation once triggered.
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10906. */
  10907. export class StopAnimationAction extends Action {
  10908. private _target;
  10909. /**
  10910. * Instantiate the action
  10911. * @param triggerOptions defines the trigger options
  10912. * @param target defines the target animation or animation name
  10913. * @param condition defines the trigger related conditions
  10914. */
  10915. constructor(triggerOptions: any, target: any, condition?: Condition);
  10916. /** @hidden */ prepare(): void;
  10917. /**
  10918. * Execute the action and stop the animation.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible that does nothing once triggered.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10931. */
  10932. export class DoNothingAction extends Action {
  10933. /**
  10934. * Instantiate the action
  10935. * @param triggerOptions defines the trigger options
  10936. * @param condition defines the trigger related conditions
  10937. */
  10938. constructor(triggerOptions?: any, condition?: Condition);
  10939. /**
  10940. * Execute the action and do nothing.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to trigger several actions once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class CombineAction extends Action {
  10955. /**
  10956. * The list of aggregated animations to run.
  10957. */
  10958. children: Action[];
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param children defines the list of aggregated animations to run
  10963. * @param condition defines the trigger related conditions
  10964. */
  10965. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10966. /** @hidden */ prepare(): void;
  10967. /**
  10968. * Execute the action and executes all the aggregated actions.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. /**
  10972. * Serializes the actions and its related information.
  10973. * @param parent defines the object to serialize in
  10974. * @returns the serialized object
  10975. */
  10976. serialize(parent: any): any;
  10977. }
  10978. /**
  10979. * This defines an action responsible to run code (external event) once triggered.
  10980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10981. */
  10982. export class ExecuteCodeAction extends Action {
  10983. /**
  10984. * The callback function to run.
  10985. */
  10986. func: (evt: ActionEvent) => void;
  10987. /**
  10988. * Instantiate the action
  10989. * @param triggerOptions defines the trigger options
  10990. * @param func defines the callback function to run
  10991. * @param condition defines the trigger related conditions
  10992. */
  10993. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10994. /**
  10995. * Execute the action and run the attached code.
  10996. */
  10997. execute(evt: ActionEvent): void;
  10998. }
  10999. /**
  11000. * This defines an action responsible to set the parent property of the target once triggered.
  11001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11002. */
  11003. export class SetParentAction extends Action {
  11004. private _parent;
  11005. private _target;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param target defines the target containing the parent property
  11010. * @param parent defines from where the animation should start (animation frame)
  11011. * @param condition defines the trigger related conditions
  11012. */
  11013. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11014. /** @hidden */ prepare(): void;
  11015. /**
  11016. * Execute the action and set the parent property.
  11017. */
  11018. execute(): void;
  11019. /**
  11020. * Serializes the actions and its related information.
  11021. * @param parent defines the object to serialize in
  11022. * @returns the serialized object
  11023. */
  11024. serialize(parent: any): any;
  11025. }
  11026. }
  11027. declare module BABYLON {
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11183. /** @hidden */ getProperty(propertyPath: string): string;
  11184. /**
  11185. * Serialize this manager to a JSON object
  11186. * @param name defines the property name to store this manager
  11187. * @returns a JSON representation of this manager
  11188. */
  11189. serialize(name: string): any;
  11190. /**
  11191. * Creates a new ActionManager from a JSON data
  11192. * @param parsedActions defines the JSON data to read from
  11193. * @param object defines the hosting mesh
  11194. * @param scene defines the hosting scene
  11195. */
  11196. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11197. /**
  11198. * Get a trigger name by index
  11199. * @param trigger defines the trigger index
  11200. * @returns a trigger name
  11201. */
  11202. static GetTriggerName(trigger: number): string;
  11203. }
  11204. }
  11205. declare module BABYLON {
  11206. /**
  11207. * Class representing a ray with position and direction
  11208. */
  11209. export class Ray {
  11210. /** origin point */
  11211. origin: Vector3;
  11212. /** direction */
  11213. direction: Vector3;
  11214. /** length of the ray */
  11215. length: number;
  11216. private static readonly TmpVector3;
  11217. private _tmpRay;
  11218. /**
  11219. * Creates a new ray
  11220. * @param origin origin point
  11221. * @param direction direction
  11222. * @param length length of the ray
  11223. */
  11224. constructor(
  11225. /** origin point */
  11226. origin: Vector3,
  11227. /** direction */
  11228. direction: Vector3,
  11229. /** length of the ray */
  11230. length?: number);
  11231. /**
  11232. * Checks if the ray intersects a box
  11233. * @param minimum bound of the box
  11234. * @param maximum bound of the box
  11235. * @param intersectionTreshold extra extend to be added to the box in all direction
  11236. * @returns if the box was hit
  11237. */
  11238. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11239. /**
  11240. * Checks if the ray intersects a box
  11241. * @param box the bounding box to check
  11242. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11243. * @returns if the box was hit
  11244. */
  11245. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11246. /**
  11247. * If the ray hits a sphere
  11248. * @param sphere the bounding sphere to check
  11249. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11250. * @returns true if it hits the sphere
  11251. */
  11252. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11253. /**
  11254. * If the ray hits a triange
  11255. * @param vertex0 triangle vertex
  11256. * @param vertex1 triangle vertex
  11257. * @param vertex2 triangle vertex
  11258. * @returns intersection information if hit
  11259. */
  11260. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11261. /**
  11262. * Checks if ray intersects a plane
  11263. * @param plane the plane to check
  11264. * @returns the distance away it was hit
  11265. */
  11266. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11267. /**
  11268. * Checks if ray intersects a mesh
  11269. * @param mesh the mesh to check
  11270. * @param fastCheck if only the bounding box should checked
  11271. * @returns picking info of the intersecton
  11272. */
  11273. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11274. /**
  11275. * Checks if ray intersects a mesh
  11276. * @param meshes the meshes to check
  11277. * @param fastCheck if only the bounding box should checked
  11278. * @param results array to store result in
  11279. * @returns Array of picking infos
  11280. */
  11281. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11282. private _comparePickingInfo;
  11283. private static smallnum;
  11284. private static rayl;
  11285. /**
  11286. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11287. * @param sega the first point of the segment to test the intersection against
  11288. * @param segb the second point of the segment to test the intersection against
  11289. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11290. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11291. */
  11292. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11293. /**
  11294. * Update the ray from viewport position
  11295. * @param x position
  11296. * @param y y position
  11297. * @param viewportWidth viewport width
  11298. * @param viewportHeight viewport height
  11299. * @param world world matrix
  11300. * @param view view matrix
  11301. * @param projection projection matrix
  11302. * @returns this ray updated
  11303. */
  11304. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11305. /**
  11306. * Creates a ray with origin and direction of 0,0,0
  11307. * @returns the new ray
  11308. */
  11309. static Zero(): Ray;
  11310. /**
  11311. * Creates a new ray from screen space and viewport
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns new ray
  11320. */
  11321. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * 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
  11324. * transformed to the given world matrix.
  11325. * @param origin The origin point
  11326. * @param end The end point
  11327. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11328. * @returns the new ray
  11329. */
  11330. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11331. /**
  11332. * Transforms a ray by a matrix
  11333. * @param ray ray to transform
  11334. * @param matrix matrix to apply
  11335. * @returns the resulting new ray
  11336. */
  11337. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11338. /**
  11339. * Transforms a ray by a matrix
  11340. * @param ray ray to transform
  11341. * @param matrix matrix to apply
  11342. * @param result ray to store result in
  11343. */
  11344. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11345. /**
  11346. * Unproject a ray from screen space to object space
  11347. * @param sourceX defines the screen space x coordinate to use
  11348. * @param sourceY defines the screen space y coordinate to use
  11349. * @param viewportWidth defines the current width of the viewport
  11350. * @param viewportHeight defines the current height of the viewport
  11351. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11352. * @param view defines the view matrix to use
  11353. * @param projection defines the projection matrix to use
  11354. */
  11355. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11356. }
  11357. /**
  11358. * Type used to define predicate used to select faces when a mesh intersection is detected
  11359. */
  11360. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11361. interface Scene {
  11362. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11363. /** @hidden */ cachedRayForTransform: Ray;
  11364. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11365. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11366. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11367. }
  11368. }
  11369. declare module BABYLON {
  11370. /**
  11371. * Groups all the scene component constants in one place to ease maintenance.
  11372. * @hidden
  11373. */
  11374. export class SceneComponentConstants {
  11375. static readonly NAME_EFFECTLAYER: string;
  11376. static readonly NAME_LAYER: string;
  11377. static readonly NAME_LENSFLARESYSTEM: string;
  11378. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11379. static readonly NAME_PARTICLESYSTEM: string;
  11380. static readonly NAME_GAMEPAD: string;
  11381. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11382. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11383. static readonly NAME_DEPTHRENDERER: string;
  11384. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11385. static readonly NAME_SPRITE: string;
  11386. static readonly NAME_OUTLINERENDERER: string;
  11387. static readonly NAME_PROCEDURALTEXTURE: string;
  11388. static readonly NAME_SHADOWGENERATOR: string;
  11389. static readonly NAME_OCTREE: string;
  11390. static readonly NAME_PHYSICSENGINE: string;
  11391. static readonly NAME_AUDIO: string;
  11392. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11393. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11394. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11395. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11396. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11397. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11398. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11399. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11400. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11401. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11402. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11403. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11404. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11405. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11406. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11407. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11408. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11409. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11410. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11411. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11412. static readonly STEP_AFTERRENDER_AUDIO: number;
  11413. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11414. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11415. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11417. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11418. static readonly STEP_POINTERMOVE_SPRITE: number;
  11419. static readonly STEP_POINTERDOWN_SPRITE: number;
  11420. static readonly STEP_POINTERUP_SPRITE: number;
  11421. }
  11422. /**
  11423. * This represents a scene component.
  11424. *
  11425. * This is used to decouple the dependency the scene is having on the different workloads like
  11426. * layers, post processes...
  11427. */
  11428. export interface ISceneComponent {
  11429. /**
  11430. * The name of the component. Each component must have a unique name.
  11431. */
  11432. name: string;
  11433. /**
  11434. * The scene the component belongs to.
  11435. */
  11436. scene: Scene;
  11437. /**
  11438. * Register the component to one instance of a scene.
  11439. */
  11440. register(): void;
  11441. /**
  11442. * Rebuilds the elements related to this component in case of
  11443. * context lost for instance.
  11444. */
  11445. rebuild(): void;
  11446. /**
  11447. * Disposes the component and the associated ressources.
  11448. */
  11449. dispose(): void;
  11450. }
  11451. /**
  11452. * This represents a SERIALIZABLE scene component.
  11453. *
  11454. * This extends Scene Component to add Serialization methods on top.
  11455. */
  11456. export interface ISceneSerializableComponent extends ISceneComponent {
  11457. /**
  11458. * Adds all the element from the container to the scene
  11459. * @param container the container holding the elements
  11460. */
  11461. addFromContainer(container: AbstractScene): void;
  11462. /**
  11463. * Removes all the elements in the container from the scene
  11464. * @param container contains the elements to remove
  11465. * @param dispose if the removed element should be disposed (default: false)
  11466. */
  11467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11468. /**
  11469. * Serializes the component data to the specified json object
  11470. * @param serializationObject The object to serialize to
  11471. */
  11472. serialize(serializationObject: any): void;
  11473. }
  11474. /**
  11475. * Strong typing of a Mesh related stage step action
  11476. */
  11477. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11478. /**
  11479. * Strong typing of a Evaluate Sub Mesh related stage step action
  11480. */
  11481. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11482. /**
  11483. * Strong typing of a Active Mesh related stage step action
  11484. */
  11485. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11486. /**
  11487. * Strong typing of a Camera related stage step action
  11488. */
  11489. export type CameraStageAction = (camera: Camera) => void;
  11490. /**
  11491. * Strong typing of a Camera Frame buffer related stage step action
  11492. */
  11493. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11494. /**
  11495. * Strong typing of a Render Target related stage step action
  11496. */
  11497. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11498. /**
  11499. * Strong typing of a RenderingGroup related stage step action
  11500. */
  11501. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11502. /**
  11503. * Strong typing of a Mesh Render related stage step action
  11504. */
  11505. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11506. /**
  11507. * Strong typing of a simple stage step action
  11508. */
  11509. export type SimpleStageAction = () => void;
  11510. /**
  11511. * Strong typing of a render target action.
  11512. */
  11513. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11514. /**
  11515. * Strong typing of a pointer move action.
  11516. */
  11517. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11518. /**
  11519. * Strong typing of a pointer up/down action.
  11520. */
  11521. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11522. /**
  11523. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11524. * @hidden
  11525. */
  11526. export class Stage<T extends Function> extends Array<{
  11527. index: number;
  11528. component: ISceneComponent;
  11529. action: T;
  11530. }> {
  11531. /**
  11532. * Hide ctor from the rest of the world.
  11533. * @param items The items to add.
  11534. */
  11535. private constructor();
  11536. /**
  11537. * Creates a new Stage.
  11538. * @returns A new instance of a Stage
  11539. */
  11540. static Create<T extends Function>(): Stage<T>;
  11541. /**
  11542. * Registers a step in an ordered way in the targeted stage.
  11543. * @param index Defines the position to register the step in
  11544. * @param component Defines the component attached to the step
  11545. * @param action Defines the action to launch during the step
  11546. */
  11547. registerStep(index: number, component: ISceneComponent, action: T): void;
  11548. /**
  11549. * Clears all the steps from the stage.
  11550. */
  11551. clear(): void;
  11552. }
  11553. }
  11554. declare module BABYLON {
  11555. interface Scene {
  11556. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11557. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11558. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11559. /**
  11560. * All of the sprite managers added to this scene
  11561. * @see http://doc.babylonjs.com/babylon101/sprites
  11562. */
  11563. spriteManagers: Array<ISpriteManager>;
  11564. /**
  11565. * An event triggered when sprites rendering is about to start
  11566. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11567. */
  11568. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11569. /**
  11570. * An event triggered when sprites rendering is done
  11571. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11572. */
  11573. onAfterSpritesRenderingObservable: Observable<Scene>;
  11574. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11575. /** Launch a ray to try to pick a sprite in the scene
  11576. * @param x position on screen
  11577. * @param y position on screen
  11578. * @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
  11579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11580. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11581. * @returns a PickingInfo
  11582. */
  11583. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11584. /** Use the given ray to pick a sprite in the scene
  11585. * @param ray The ray (in world space) to use to pick meshes
  11586. * @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
  11587. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11588. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11589. * @returns a PickingInfo
  11590. */
  11591. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11592. /**
  11593. * Force the sprite under the pointer
  11594. * @param sprite defines the sprite to use
  11595. */
  11596. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11597. /**
  11598. * Gets the sprite under the pointer
  11599. * @returns a Sprite or null if no sprite is under the pointer
  11600. */
  11601. getPointerOverSprite(): Nullable<Sprite>;
  11602. }
  11603. /**
  11604. * Defines the sprite scene component responsible to manage sprites
  11605. * in a given scene.
  11606. */
  11607. export class SpriteSceneComponent implements ISceneComponent {
  11608. /**
  11609. * The component name helpfull to identify the component in the list of scene components.
  11610. */
  11611. readonly name: string;
  11612. /**
  11613. * The scene the component belongs to.
  11614. */
  11615. scene: Scene;
  11616. /** @hidden */
  11617. private _spritePredicate;
  11618. /**
  11619. * Creates a new instance of the component for the given scene
  11620. * @param scene Defines the scene to register the component in
  11621. */
  11622. constructor(scene: Scene);
  11623. /**
  11624. * Registers the component in a given scene
  11625. */
  11626. register(): void;
  11627. /**
  11628. * Rebuilds the elements related to this component in case of
  11629. * context lost for instance.
  11630. */
  11631. rebuild(): void;
  11632. /**
  11633. * Disposes the component and the associated ressources.
  11634. */
  11635. dispose(): void;
  11636. private _pickSpriteButKeepRay;
  11637. private _pointerMove;
  11638. private _pointerDown;
  11639. private _pointerUp;
  11640. }
  11641. }
  11642. declare module BABYLON {
  11643. /** @hidden */
  11644. export var fogFragmentDeclaration: {
  11645. name: string;
  11646. shader: string;
  11647. };
  11648. }
  11649. declare module BABYLON {
  11650. /** @hidden */
  11651. export var fogFragment: {
  11652. name: string;
  11653. shader: string;
  11654. };
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var spritesPixelShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var fogVertexDeclaration: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /** @hidden */
  11672. export var spritesVertexShader: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11680. */
  11681. export interface ISpriteManager extends IDisposable {
  11682. /**
  11683. * Restricts the camera to viewing objects with the same layerMask.
  11684. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11685. */
  11686. layerMask: number;
  11687. /**
  11688. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11689. */
  11690. isPickable: boolean;
  11691. /**
  11692. * Specifies the rendering group id for this mesh (0 by default)
  11693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11694. */
  11695. renderingGroupId: number;
  11696. /**
  11697. * Defines the list of sprites managed by the manager.
  11698. */
  11699. sprites: Array<Sprite>;
  11700. /**
  11701. * Tests the intersection of a sprite with a specific ray.
  11702. * @param ray The ray we are sending to test the collision
  11703. * @param camera The camera space we are sending rays in
  11704. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11705. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11706. * @returns picking info or null.
  11707. */
  11708. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11709. /**
  11710. * Renders the list of sprites on screen.
  11711. */
  11712. render(): void;
  11713. }
  11714. /**
  11715. * Class used to manage multiple sprites on the same spritesheet
  11716. * @see http://doc.babylonjs.com/babylon101/sprites
  11717. */
  11718. export class SpriteManager implements ISpriteManager {
  11719. /** defines the manager's name */
  11720. name: string;
  11721. /** Gets the list of sprites */
  11722. sprites: Sprite[];
  11723. /** Gets or sets the rendering group id (0 by default) */
  11724. renderingGroupId: number;
  11725. /** Gets or sets camera layer mask */
  11726. layerMask: number;
  11727. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11728. fogEnabled: boolean;
  11729. /** Gets or sets a boolean indicating if the sprites are pickable */
  11730. isPickable: boolean;
  11731. /** Defines the default width of a cell in the spritesheet */
  11732. cellWidth: number;
  11733. /** Defines the default height of a cell in the spritesheet */
  11734. cellHeight: number;
  11735. /**
  11736. * An event triggered when the manager is disposed.
  11737. */
  11738. onDisposeObservable: Observable<SpriteManager>;
  11739. private _onDisposeObserver;
  11740. /**
  11741. * Callback called when the manager is disposed
  11742. */
  11743. onDispose: () => void;
  11744. private _capacity;
  11745. private _spriteTexture;
  11746. private _epsilon;
  11747. private _scene;
  11748. private _vertexData;
  11749. private _buffer;
  11750. private _vertexBuffers;
  11751. private _indexBuffer;
  11752. private _effectBase;
  11753. private _effectFog;
  11754. /**
  11755. * Gets or sets the spritesheet texture
  11756. */
  11757. texture: Texture;
  11758. /**
  11759. * Creates a new sprite manager
  11760. * @param name defines the manager's name
  11761. * @param imgUrl defines the sprite sheet url
  11762. * @param capacity defines the maximum allowed number of sprites
  11763. * @param cellSize defines the size of a sprite cell
  11764. * @param scene defines the hosting scene
  11765. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11766. * @param samplingMode defines the smapling mode to use with spritesheet
  11767. */
  11768. constructor(
  11769. /** defines the manager's name */
  11770. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11771. private _appendSpriteVertex;
  11772. /**
  11773. * Intersects the sprites with a ray
  11774. * @param ray defines the ray to intersect with
  11775. * @param camera defines the current active camera
  11776. * @param predicate defines a predicate used to select candidate sprites
  11777. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11778. * @returns null if no hit or a PickingInfo
  11779. */
  11780. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11781. /**
  11782. * Render all child sprites
  11783. */
  11784. render(): void;
  11785. /**
  11786. * Release associated resources
  11787. */
  11788. dispose(): void;
  11789. }
  11790. }
  11791. declare module BABYLON {
  11792. /**
  11793. * Class used to represent a sprite
  11794. * @see http://doc.babylonjs.com/babylon101/sprites
  11795. */
  11796. export class Sprite {
  11797. /** defines the name */
  11798. name: string;
  11799. /** Gets or sets the current world position */
  11800. position: Vector3;
  11801. /** Gets or sets the main color */
  11802. color: Color4;
  11803. /** Gets or sets the width */
  11804. width: number;
  11805. /** Gets or sets the height */
  11806. height: number;
  11807. /** Gets or sets rotation angle */
  11808. angle: number;
  11809. /** Gets or sets the cell index in the sprite sheet */
  11810. cellIndex: number;
  11811. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11812. invertU: number;
  11813. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11814. invertV: number;
  11815. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11816. disposeWhenFinishedAnimating: boolean;
  11817. /** Gets the list of attached animations */
  11818. animations: Animation[];
  11819. /** Gets or sets a boolean indicating if the sprite can be picked */
  11820. isPickable: boolean;
  11821. /**
  11822. * Gets or sets the associated action manager
  11823. */
  11824. actionManager: Nullable<ActionManager>;
  11825. private _animationStarted;
  11826. private _loopAnimation;
  11827. private _fromIndex;
  11828. private _toIndex;
  11829. private _delay;
  11830. private _direction;
  11831. private _manager;
  11832. private _time;
  11833. private _onAnimationEnd;
  11834. /**
  11835. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11836. */
  11837. isVisible: boolean;
  11838. /**
  11839. * Gets or sets the sprite size
  11840. */
  11841. size: number;
  11842. /**
  11843. * Creates a new Sprite
  11844. * @param name defines the name
  11845. * @param manager defines the manager
  11846. */
  11847. constructor(
  11848. /** defines the name */
  11849. name: string, manager: ISpriteManager);
  11850. /**
  11851. * Starts an animation
  11852. * @param from defines the initial key
  11853. * @param to defines the end key
  11854. * @param loop defines if the animation must loop
  11855. * @param delay defines the start delay (in ms)
  11856. * @param onAnimationEnd defines a callback to call when animation ends
  11857. */
  11858. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11859. /** Stops current animation (if any) */
  11860. stopAnimation(): void;
  11861. /** @hidden */ animate(deltaTime: number): void;
  11862. /** Release associated resources */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * Information about the result of picking within a scene
  11869. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11870. */
  11871. export class PickingInfo {
  11872. /** @hidden */ pickingUnavailable: boolean;
  11873. /**
  11874. * If the pick collided with an object
  11875. */
  11876. hit: boolean;
  11877. /**
  11878. * Distance away where the pick collided
  11879. */
  11880. distance: number;
  11881. /**
  11882. * The location of pick collision
  11883. */
  11884. pickedPoint: Nullable<Vector3>;
  11885. /**
  11886. * The mesh corresponding the the pick collision
  11887. */
  11888. pickedMesh: Nullable<AbstractMesh>;
  11889. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11890. bu: number;
  11891. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11892. bv: number;
  11893. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11894. faceId: number;
  11895. /** Id of the the submesh that was picked */
  11896. subMeshId: number;
  11897. /** If a sprite was picked, this will be the sprite the pick collided with */
  11898. pickedSprite: Nullable<Sprite>;
  11899. /**
  11900. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11901. */
  11902. originMesh: Nullable<AbstractMesh>;
  11903. /**
  11904. * The ray that was used to perform the picking.
  11905. */
  11906. ray: Nullable<Ray>;
  11907. /**
  11908. * Gets the normal correspodning to the face the pick collided with
  11909. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11910. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11911. * @returns The normal correspodning to the face the pick collided with
  11912. */
  11913. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11914. /**
  11915. * Gets the texture coordinates of where the pick occured
  11916. * @returns the vector containing the coordnates of the texture
  11917. */
  11918. getTextureCoordinates(): Nullable<Vector2>;
  11919. }
  11920. }
  11921. declare module BABYLON {
  11922. /**
  11923. * Gather the list of pointer event types as constants.
  11924. */
  11925. export class PointerEventTypes {
  11926. /**
  11927. * 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.
  11928. */
  11929. static readonly POINTERDOWN: number;
  11930. /**
  11931. * The pointerup event is fired when a pointer is no longer active.
  11932. */
  11933. static readonly POINTERUP: number;
  11934. /**
  11935. * The pointermove event is fired when a pointer changes coordinates.
  11936. */
  11937. static readonly POINTERMOVE: number;
  11938. /**
  11939. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11940. */
  11941. static readonly POINTERWHEEL: number;
  11942. /**
  11943. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11944. */
  11945. static readonly POINTERPICK: number;
  11946. /**
  11947. * The pointertap event is fired when a the object has been touched and released without drag.
  11948. */
  11949. static readonly POINTERTAP: number;
  11950. /**
  11951. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11952. */
  11953. static readonly POINTERDOUBLETAP: number;
  11954. }
  11955. /**
  11956. * Base class of pointer info types.
  11957. */
  11958. export class PointerInfoBase {
  11959. /**
  11960. * Defines the type of event (PointerEventTypes)
  11961. */
  11962. type: number;
  11963. /**
  11964. * Defines the related dom event
  11965. */
  11966. event: PointerEvent | MouseWheelEvent;
  11967. /**
  11968. * Instantiates the base class of pointers info.
  11969. * @param type Defines the type of event (PointerEventTypes)
  11970. * @param event Defines the related dom event
  11971. */
  11972. constructor(
  11973. /**
  11974. * Defines the type of event (PointerEventTypes)
  11975. */
  11976. type: number,
  11977. /**
  11978. * Defines the related dom event
  11979. */
  11980. event: PointerEvent | MouseWheelEvent);
  11981. }
  11982. /**
  11983. * This class is used to store pointer related info for the onPrePointerObservable event.
  11984. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11985. */
  11986. export class PointerInfoPre extends PointerInfoBase {
  11987. /**
  11988. * Ray from a pointer if availible (eg. 6dof controller)
  11989. */
  11990. ray: Nullable<Ray>;
  11991. /**
  11992. * Defines the local position of the pointer on the canvas.
  11993. */
  11994. localPosition: Vector2;
  11995. /**
  11996. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11997. */
  11998. skipOnPointerObservable: boolean;
  11999. /**
  12000. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12001. * @param type Defines the type of event (PointerEventTypes)
  12002. * @param event Defines the related dom event
  12003. * @param localX Defines the local x coordinates of the pointer when the event occured
  12004. * @param localY Defines the local y coordinates of the pointer when the event occured
  12005. */
  12006. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12007. }
  12008. /**
  12009. * This type contains all the data related to a pointer event in Babylon.js.
  12010. * 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.
  12011. */
  12012. export class PointerInfo extends PointerInfoBase {
  12013. /**
  12014. * Defines the picking info associated to the info (if any)\
  12015. */
  12016. pickInfo: Nullable<PickingInfo>;
  12017. /**
  12018. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12019. * @param type Defines the type of event (PointerEventTypes)
  12020. * @param event Defines the related dom event
  12021. * @param pickInfo Defines the picking info associated to the info (if any)\
  12022. */
  12023. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12024. /**
  12025. * Defines the picking info associated to the info (if any)\
  12026. */
  12027. pickInfo: Nullable<PickingInfo>);
  12028. }
  12029. /**
  12030. * Data relating to a touch event on the screen.
  12031. */
  12032. export interface PointerTouch {
  12033. /**
  12034. * X coordinate of touch.
  12035. */
  12036. x: number;
  12037. /**
  12038. * Y coordinate of touch.
  12039. */
  12040. y: number;
  12041. /**
  12042. * Id of touch. Unique for each finger.
  12043. */
  12044. pointerId: number;
  12045. /**
  12046. * Event type passed from DOM.
  12047. */
  12048. type: any;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Manage the mouse inputs to control the movement of a free camera.
  12054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12055. */
  12056. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12057. /**
  12058. * Define if touch is enabled in the mouse input
  12059. */
  12060. touchEnabled: boolean;
  12061. /**
  12062. * Defines the camera the input is attached to.
  12063. */
  12064. camera: FreeCamera;
  12065. /**
  12066. * Defines the buttons associated with the input to handle camera move.
  12067. */
  12068. buttons: number[];
  12069. /**
  12070. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12071. */
  12072. angularSensibility: number;
  12073. private _pointerInput;
  12074. private _onMouseMove;
  12075. private _observer;
  12076. private previousPosition;
  12077. /**
  12078. * Observable for when a pointer move event occurs containing the move offset
  12079. */
  12080. onPointerMovedObservable: Observable<{
  12081. offsetX: number;
  12082. offsetY: number;
  12083. }>;
  12084. /**
  12085. * @hidden
  12086. * If the camera should be rotated automatically based on pointer movement
  12087. */ allowCameraRotation: boolean;
  12088. /**
  12089. * Manage the mouse inputs to control the movement of a free camera.
  12090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12091. * @param touchEnabled Defines if touch is enabled or not
  12092. */
  12093. constructor(
  12094. /**
  12095. * Define if touch is enabled in the mouse input
  12096. */
  12097. touchEnabled?: boolean);
  12098. /**
  12099. * Attach the input controls to a specific dom element to get the input from.
  12100. * @param element Defines the element the controls should be listened from
  12101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12102. */
  12103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12104. /**
  12105. * Called on JS contextmenu event.
  12106. * Override this method to provide functionality.
  12107. */
  12108. protected onContextMenu(evt: PointerEvent): void;
  12109. /**
  12110. * Detach the current controls from the specified dom element.
  12111. * @param element Defines the element to stop listening the inputs from
  12112. */
  12113. detachControl(element: Nullable<HTMLElement>): void;
  12114. /**
  12115. * Gets the class name of the current intput.
  12116. * @returns the class name
  12117. */
  12118. getClassName(): string;
  12119. /**
  12120. * Get the friendly name associated with the input class.
  12121. * @returns the input friendly name
  12122. */
  12123. getSimpleName(): string;
  12124. }
  12125. }
  12126. declare module BABYLON {
  12127. /**
  12128. * Manage the touch inputs to control the movement of a free camera.
  12129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12130. */
  12131. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12132. /**
  12133. * Defines the camera the input is attached to.
  12134. */
  12135. camera: FreeCamera;
  12136. /**
  12137. * Defines the touch sensibility for rotation.
  12138. * The higher the faster.
  12139. */
  12140. touchAngularSensibility: number;
  12141. /**
  12142. * Defines the touch sensibility for move.
  12143. * The higher the faster.
  12144. */
  12145. touchMoveSensibility: number;
  12146. private _offsetX;
  12147. private _offsetY;
  12148. private _pointerPressed;
  12149. private _pointerInput;
  12150. private _observer;
  12151. private _onLostFocus;
  12152. /**
  12153. * Attach the input controls to a specific dom element to get the input from.
  12154. * @param element Defines the element the controls should be listened from
  12155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12156. */
  12157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12158. /**
  12159. * Detach the current controls from the specified dom element.
  12160. * @param element Defines the element to stop listening the inputs from
  12161. */
  12162. detachControl(element: Nullable<HTMLElement>): void;
  12163. /**
  12164. * Update the current camera state depending on the inputs that have been used this frame.
  12165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12166. */
  12167. checkInputs(): void;
  12168. /**
  12169. * Gets the class name of the current intput.
  12170. * @returns the class name
  12171. */
  12172. getClassName(): string;
  12173. /**
  12174. * Get the friendly name associated with the input class.
  12175. * @returns the input friendly name
  12176. */
  12177. getSimpleName(): string;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Default Inputs manager for the FreeCamera.
  12183. * It groups all the default supported inputs for ease of use.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12187. /**
  12188. * @hidden
  12189. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12190. /**
  12191. * @hidden
  12192. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12193. /**
  12194. * Instantiates a new FreeCameraInputsManager.
  12195. * @param camera Defines the camera the inputs belong to
  12196. */
  12197. constructor(camera: FreeCamera);
  12198. /**
  12199. * Add keyboard input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addKeyboard(): FreeCameraInputsManager;
  12203. /**
  12204. * Add mouse input support to the input manager.
  12205. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12206. * @returns the current input manager
  12207. */
  12208. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12209. /**
  12210. * Removes the mouse input support from the manager
  12211. * @returns the current input manager
  12212. */
  12213. removeMouse(): FreeCameraInputsManager;
  12214. /**
  12215. * Add touch input support to the input manager.
  12216. * @returns the current input manager
  12217. */
  12218. addTouch(): FreeCameraInputsManager;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12224. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12226. */
  12227. export class FreeCamera extends TargetCamera {
  12228. /**
  12229. * Define the collision ellipsoid of the camera.
  12230. * This is helpful to simulate a camera body like the player body around the camera
  12231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12232. */
  12233. ellipsoid: Vector3;
  12234. /**
  12235. * Define an offset for the position of the ellipsoid around the camera.
  12236. * This can be helpful to determine the center of the body near the gravity center of the body
  12237. * instead of its head.
  12238. */
  12239. ellipsoidOffset: Vector3;
  12240. /**
  12241. * Enable or disable collisions of the camera with the rest of the scene objects.
  12242. */
  12243. checkCollisions: boolean;
  12244. /**
  12245. * Enable or disable gravity on the camera.
  12246. */
  12247. applyGravity: boolean;
  12248. /**
  12249. * Define the input manager associated to the camera.
  12250. */
  12251. inputs: FreeCameraInputsManager;
  12252. /**
  12253. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12254. * Higher values reduce sensitivity.
  12255. */
  12256. /**
  12257. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12258. * Higher values reduce sensitivity.
  12259. */
  12260. angularSensibility: number;
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12263. */
  12264. keysUp: number[];
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12267. */
  12268. keysDown: number[];
  12269. /**
  12270. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12271. */
  12272. keysLeft: number[];
  12273. /**
  12274. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12275. */
  12276. keysRight: number[];
  12277. /**
  12278. * Event raised when the camera collide with a mesh in the scene.
  12279. */
  12280. onCollide: (collidedMesh: AbstractMesh) => void;
  12281. private _collider;
  12282. private _needMoveForGravity;
  12283. private _oldPosition;
  12284. private _diffPosition;
  12285. private _newPosition;
  12286. /** @hidden */ localDirection: Vector3;
  12287. /** @hidden */ transformedDirection: Vector3;
  12288. /**
  12289. * Instantiates a Free Camera.
  12290. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12291. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12293. * @param name Define the name of the camera in the scene
  12294. * @param position Define the start position of the camera in the scene
  12295. * @param scene Define the scene the camera belongs to
  12296. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12297. */
  12298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12299. /**
  12300. * Attached controls to the current camera.
  12301. * @param element Defines the element the controls should be listened from
  12302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12303. */
  12304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12305. /**
  12306. * Detach the current controls from the camera.
  12307. * The camera will stop reacting to inputs.
  12308. * @param element Defines the element to stop listening the inputs from
  12309. */
  12310. detachControl(element: HTMLElement): void;
  12311. private _collisionMask;
  12312. /**
  12313. * Define a collision mask to limit the list of object the camera can collide with
  12314. */
  12315. collisionMask: number;
  12316. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12317. private _onCollisionPositionChange;
  12318. /** @hidden */ checkInputs(): void;
  12319. /** @hidden */ decideIfNeedsToMove(): boolean;
  12320. /** @hidden */ updatePosition(): void;
  12321. /**
  12322. * Destroy the camera and release the current resources hold by it.
  12323. */
  12324. dispose(): void;
  12325. /**
  12326. * Gets the current object class name.
  12327. * @return the class name
  12328. */
  12329. getClassName(): string;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. /**
  12334. * Represents a gamepad control stick position
  12335. */
  12336. export class StickValues {
  12337. /**
  12338. * The x component of the control stick
  12339. */
  12340. x: number;
  12341. /**
  12342. * The y component of the control stick
  12343. */
  12344. y: number;
  12345. /**
  12346. * Initializes the gamepad x and y control stick values
  12347. * @param x The x component of the gamepad control stick value
  12348. * @param y The y component of the gamepad control stick value
  12349. */
  12350. constructor(
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number,
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number);
  12359. }
  12360. /**
  12361. * An interface which manages callbacks for gamepad button changes
  12362. */
  12363. export interface GamepadButtonChanges {
  12364. /**
  12365. * Called when a gamepad has been changed
  12366. */
  12367. changed: boolean;
  12368. /**
  12369. * Called when a gamepad press event has been triggered
  12370. */
  12371. pressChanged: boolean;
  12372. /**
  12373. * Called when a touch event has been triggered
  12374. */
  12375. touchChanged: boolean;
  12376. /**
  12377. * Called when a value has changed
  12378. */
  12379. valueChanged: boolean;
  12380. }
  12381. /**
  12382. * Represents a gamepad
  12383. */
  12384. export class Gamepad {
  12385. /**
  12386. * The id of the gamepad
  12387. */
  12388. id: string;
  12389. /**
  12390. * The index of the gamepad
  12391. */
  12392. index: number;
  12393. /**
  12394. * The browser gamepad
  12395. */
  12396. browserGamepad: any;
  12397. /**
  12398. * Specifies what type of gamepad this represents
  12399. */
  12400. type: number;
  12401. private _leftStick;
  12402. private _rightStick;
  12403. /** @hidden */ isConnected: boolean;
  12404. private _leftStickAxisX;
  12405. private _leftStickAxisY;
  12406. private _rightStickAxisX;
  12407. private _rightStickAxisY;
  12408. /**
  12409. * Triggered when the left control stick has been changed
  12410. */
  12411. private _onleftstickchanged;
  12412. /**
  12413. * Triggered when the right control stick has been changed
  12414. */
  12415. private _onrightstickchanged;
  12416. /**
  12417. * Represents a gamepad controller
  12418. */
  12419. static GAMEPAD: number;
  12420. /**
  12421. * Represents a generic controller
  12422. */
  12423. static GENERIC: number;
  12424. /**
  12425. * Represents an XBox controller
  12426. */
  12427. static XBOX: number;
  12428. /**
  12429. * Represents a pose-enabled controller
  12430. */
  12431. static POSE_ENABLED: number;
  12432. /**
  12433. * Specifies whether the left control stick should be Y-inverted
  12434. */
  12435. protected _invertLeftStickY: boolean;
  12436. /**
  12437. * Specifies if the gamepad has been connected
  12438. */
  12439. readonly isConnected: boolean;
  12440. /**
  12441. * Initializes the gamepad
  12442. * @param id The id of the gamepad
  12443. * @param index The index of the gamepad
  12444. * @param browserGamepad The browser gamepad
  12445. * @param leftStickX The x component of the left joystick
  12446. * @param leftStickY The y component of the left joystick
  12447. * @param rightStickX The x component of the right joystick
  12448. * @param rightStickY The y component of the right joystick
  12449. */
  12450. constructor(
  12451. /**
  12452. * The id of the gamepad
  12453. */
  12454. id: string,
  12455. /**
  12456. * The index of the gamepad
  12457. */
  12458. index: number,
  12459. /**
  12460. * The browser gamepad
  12461. */
  12462. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12463. /**
  12464. * Callback triggered when the left joystick has changed
  12465. * @param callback
  12466. */
  12467. onleftstickchanged(callback: (values: StickValues) => void): void;
  12468. /**
  12469. * Callback triggered when the right joystick has changed
  12470. * @param callback
  12471. */
  12472. onrightstickchanged(callback: (values: StickValues) => void): void;
  12473. /**
  12474. * Gets the left joystick
  12475. */
  12476. /**
  12477. * Sets the left joystick values
  12478. */
  12479. leftStick: StickValues;
  12480. /**
  12481. * Gets the right joystick
  12482. */
  12483. /**
  12484. * Sets the right joystick value
  12485. */
  12486. rightStick: StickValues;
  12487. /**
  12488. * Updates the gamepad joystick positions
  12489. */
  12490. update(): void;
  12491. /**
  12492. * Disposes the gamepad
  12493. */
  12494. dispose(): void;
  12495. }
  12496. /**
  12497. * Represents a generic gamepad
  12498. */
  12499. export class GenericPad extends Gamepad {
  12500. private _buttons;
  12501. private _onbuttondown;
  12502. private _onbuttonup;
  12503. /**
  12504. * Observable triggered when a button has been pressed
  12505. */
  12506. onButtonDownObservable: Observable<number>;
  12507. /**
  12508. * Observable triggered when a button has been released
  12509. */
  12510. onButtonUpObservable: Observable<number>;
  12511. /**
  12512. * Callback triggered when a button has been pressed
  12513. * @param callback Called when a button has been pressed
  12514. */
  12515. onbuttondown(callback: (buttonPressed: number) => void): void;
  12516. /**
  12517. * Callback triggered when a button has been released
  12518. * @param callback Called when a button has been released
  12519. */
  12520. onbuttonup(callback: (buttonReleased: number) => void): void;
  12521. /**
  12522. * Initializes the generic gamepad
  12523. * @param id The id of the generic gamepad
  12524. * @param index The index of the generic gamepad
  12525. * @param browserGamepad The browser gamepad
  12526. */
  12527. constructor(id: string, index: number, browserGamepad: any);
  12528. private _setButtonValue;
  12529. /**
  12530. * Updates the generic gamepad
  12531. */
  12532. update(): void;
  12533. /**
  12534. * Disposes the generic gamepad
  12535. */
  12536. dispose(): void;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * Defines the types of pose enabled controllers that are supported
  12542. */
  12543. export enum PoseEnabledControllerType {
  12544. /**
  12545. * HTC Vive
  12546. */
  12547. VIVE = 0,
  12548. /**
  12549. * Oculus Rift
  12550. */
  12551. OCULUS = 1,
  12552. /**
  12553. * Windows mixed reality
  12554. */
  12555. WINDOWS = 2,
  12556. /**
  12557. * Samsung gear VR
  12558. */
  12559. GEAR_VR = 3,
  12560. /**
  12561. * Google Daydream
  12562. */
  12563. DAYDREAM = 4,
  12564. /**
  12565. * Generic
  12566. */
  12567. GENERIC = 5
  12568. }
  12569. /**
  12570. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12571. */
  12572. export interface MutableGamepadButton {
  12573. /**
  12574. * Value of the button/trigger
  12575. */
  12576. value: number;
  12577. /**
  12578. * If the button/trigger is currently touched
  12579. */
  12580. touched: boolean;
  12581. /**
  12582. * If the button/trigger is currently pressed
  12583. */
  12584. pressed: boolean;
  12585. }
  12586. /**
  12587. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12588. * @hidden
  12589. */
  12590. export interface ExtendedGamepadButton extends GamepadButton {
  12591. /**
  12592. * If the button/trigger is currently pressed
  12593. */
  12594. readonly pressed: boolean;
  12595. /**
  12596. * If the button/trigger is currently touched
  12597. */
  12598. readonly touched: boolean;
  12599. /**
  12600. * Value of the button/trigger
  12601. */
  12602. readonly value: number;
  12603. }
  12604. /** @hidden */
  12605. export interface _GamePadFactory {
  12606. /**
  12607. * Returns wether or not the current gamepad can be created for this type of controller.
  12608. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12609. * @returns true if it can be created, otherwise false
  12610. */
  12611. canCreate(gamepadInfo: any): boolean;
  12612. /**
  12613. * Creates a new instance of the Gamepad.
  12614. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12615. * @returns the new gamepad instance
  12616. */
  12617. create(gamepadInfo: any): Gamepad;
  12618. }
  12619. /**
  12620. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12621. */
  12622. export class PoseEnabledControllerHelper {
  12623. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12624. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12625. /**
  12626. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12627. * @param vrGamepad the gamepad to initialized
  12628. * @returns a vr controller of the type the gamepad identified as
  12629. */
  12630. static InitiateController(vrGamepad: any): Gamepad;
  12631. }
  12632. /**
  12633. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12634. */
  12635. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12636. private _deviceRoomPosition;
  12637. private _deviceRoomRotationQuaternion;
  12638. /**
  12639. * The device position in babylon space
  12640. */
  12641. devicePosition: Vector3;
  12642. /**
  12643. * The device rotation in babylon space
  12644. */
  12645. deviceRotationQuaternion: Quaternion;
  12646. /**
  12647. * The scale factor of the device in babylon space
  12648. */
  12649. deviceScaleFactor: number;
  12650. /**
  12651. * (Likely devicePosition should be used instead) The device position in its room space
  12652. */
  12653. position: Vector3;
  12654. /**
  12655. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12656. */
  12657. rotationQuaternion: Quaternion;
  12658. /**
  12659. * The type of controller (Eg. Windows mixed reality)
  12660. */
  12661. controllerType: PoseEnabledControllerType;
  12662. protected _calculatedPosition: Vector3;
  12663. private _calculatedRotation;
  12664. /**
  12665. * The raw pose from the device
  12666. */
  12667. rawPose: DevicePose;
  12668. private _trackPosition;
  12669. private _maxRotationDistFromHeadset;
  12670. private _draggedRoomRotation;
  12671. /**
  12672. * @hidden
  12673. */ disableTrackPosition(fixedPosition: Vector3): void;
  12674. /**
  12675. * Internal, the mesh attached to the controller
  12676. * @hidden
  12677. */ mesh: Nullable<AbstractMesh>;
  12678. private _poseControlledCamera;
  12679. private _leftHandSystemQuaternion;
  12680. /**
  12681. * Internal, matrix used to convert room space to babylon space
  12682. * @hidden
  12683. */ deviceToWorld: Matrix;
  12684. /**
  12685. * Node to be used when casting a ray from the controller
  12686. * @hidden
  12687. */ pointingPoseNode: Nullable<TransformNode>;
  12688. /**
  12689. * Name of the child mesh that can be used to cast a ray from the controller
  12690. */
  12691. static readonly POINTING_POSE: string;
  12692. /**
  12693. * Creates a new PoseEnabledController from a gamepad
  12694. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12695. */
  12696. constructor(browserGamepad: any);
  12697. private _workingMatrix;
  12698. /**
  12699. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12700. */
  12701. update(): void;
  12702. /**
  12703. * Updates only the pose device and mesh without doing any button event checking
  12704. */
  12705. protected _updatePoseAndMesh(): void;
  12706. /**
  12707. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12708. * @param poseData raw pose fromthe device
  12709. */
  12710. updateFromDevice(poseData: DevicePose): void;
  12711. /**
  12712. * @hidden
  12713. */ meshAttachedObservable: Observable<AbstractMesh>;
  12714. /**
  12715. * Attaches a mesh to the controller
  12716. * @param mesh the mesh to be attached
  12717. */
  12718. attachToMesh(mesh: AbstractMesh): void;
  12719. /**
  12720. * Attaches the controllers mesh to a camera
  12721. * @param camera the camera the mesh should be attached to
  12722. */
  12723. attachToPoseControlledCamera(camera: TargetCamera): void;
  12724. /**
  12725. * Disposes of the controller
  12726. */
  12727. dispose(): void;
  12728. /**
  12729. * The mesh that is attached to the controller
  12730. */
  12731. readonly mesh: Nullable<AbstractMesh>;
  12732. /**
  12733. * Gets the ray of the controller in the direction the controller is pointing
  12734. * @param length the length the resulting ray should be
  12735. * @returns a ray in the direction the controller is pointing
  12736. */
  12737. getForwardRay(length?: number): Ray;
  12738. }
  12739. }
  12740. declare module BABYLON {
  12741. /**
  12742. * Defines the WebVRController object that represents controllers tracked in 3D space
  12743. */
  12744. export abstract class WebVRController extends PoseEnabledController {
  12745. /**
  12746. * Internal, the default controller model for the controller
  12747. */
  12748. protected _defaultModel: AbstractMesh;
  12749. /**
  12750. * Fired when the trigger state has changed
  12751. */
  12752. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12753. /**
  12754. * Fired when the main button state has changed
  12755. */
  12756. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12757. /**
  12758. * Fired when the secondary button state has changed
  12759. */
  12760. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12761. /**
  12762. * Fired when the pad state has changed
  12763. */
  12764. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12765. /**
  12766. * Fired when controllers stick values have changed
  12767. */
  12768. onPadValuesChangedObservable: Observable<StickValues>;
  12769. /**
  12770. * Array of button availible on the controller
  12771. */
  12772. protected _buttons: Array<MutableGamepadButton>;
  12773. private _onButtonStateChange;
  12774. /**
  12775. * Fired when a controller button's state has changed
  12776. * @param callback the callback containing the button that was modified
  12777. */
  12778. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12779. /**
  12780. * X and Y axis corrisponding to the controllers joystick
  12781. */
  12782. pad: StickValues;
  12783. /**
  12784. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12785. */
  12786. hand: string;
  12787. /**
  12788. * The default controller model for the controller
  12789. */
  12790. readonly defaultModel: AbstractMesh;
  12791. /**
  12792. * Creates a new WebVRController from a gamepad
  12793. * @param vrGamepad the gamepad that the WebVRController should be created from
  12794. */
  12795. constructor(vrGamepad: any);
  12796. /**
  12797. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12798. */
  12799. update(): void;
  12800. /**
  12801. * Function to be called when a button is modified
  12802. */
  12803. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12804. /**
  12805. * Loads a mesh and attaches it to the controller
  12806. * @param scene the scene the mesh should be added to
  12807. * @param meshLoaded callback for when the mesh has been loaded
  12808. */
  12809. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12810. private _setButtonValue;
  12811. private _changes;
  12812. private _checkChanges;
  12813. /**
  12814. * Disposes of th webVRCOntroller
  12815. */
  12816. dispose(): void;
  12817. }
  12818. }
  12819. declare module BABYLON {
  12820. /**
  12821. * The HemisphericLight simulates the ambient environment light,
  12822. * so the passed direction is the light reflection direction, not the incoming direction.
  12823. */
  12824. export class HemisphericLight extends Light {
  12825. /**
  12826. * The groundColor is the light in the opposite direction to the one specified during creation.
  12827. * 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.
  12828. */
  12829. groundColor: Color3;
  12830. /**
  12831. * The light reflection direction, not the incoming direction.
  12832. */
  12833. direction: Vector3;
  12834. /**
  12835. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12836. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12837. * The HemisphericLight can't cast shadows.
  12838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12839. * @param name The friendly name of the light
  12840. * @param direction The direction of the light reflection
  12841. * @param scene The scene the light belongs to
  12842. */
  12843. constructor(name: string, direction: Vector3, scene: Scene);
  12844. protected _buildUniformLayout(): void;
  12845. /**
  12846. * Returns the string "HemisphericLight".
  12847. * @return The class name
  12848. */
  12849. getClassName(): string;
  12850. /**
  12851. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12852. * Returns the updated direction.
  12853. * @param target The target the direction should point to
  12854. * @return The computed direction
  12855. */
  12856. setDirectionToTarget(target: Vector3): Vector3;
  12857. /**
  12858. * Returns the shadow generator associated to the light.
  12859. * @returns Always null for hemispheric lights because it does not support shadows.
  12860. */
  12861. getShadowGenerator(): Nullable<IShadowGenerator>;
  12862. /**
  12863. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12864. * @param effect The effect to update
  12865. * @param lightIndex The index of the light in the effect to update
  12866. * @returns The hemispheric light
  12867. */
  12868. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12869. /**
  12870. * Computes the world matrix of the node
  12871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12872. * @param useWasUpdatedFlag defines a reserved property
  12873. * @returns the world matrix
  12874. */
  12875. computeWorldMatrix(): Matrix;
  12876. /**
  12877. * Returns the integer 3.
  12878. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12879. */
  12880. getTypeID(): number;
  12881. /**
  12882. * Prepares the list of defines specific to the light type.
  12883. * @param defines the list of defines
  12884. * @param lightIndex defines the index of the light for the effect
  12885. */
  12886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12887. }
  12888. }
  12889. declare module BABYLON {
  12890. /** @hidden */
  12891. export var vrMultiviewToSingleviewPixelShader: {
  12892. name: string;
  12893. shader: string;
  12894. };
  12895. }
  12896. declare module BABYLON {
  12897. /**
  12898. * Renders to multiple views with a single draw call
  12899. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12900. */
  12901. export class MultiviewRenderTarget extends RenderTargetTexture {
  12902. /**
  12903. * Creates a multiview render target
  12904. * @param scene scene used with the render target
  12905. * @param size the size of the render target (used for each view)
  12906. */
  12907. constructor(scene: Scene, size?: number | {
  12908. width: number;
  12909. height: number;
  12910. } | {
  12911. ratio: number;
  12912. });
  12913. /**
  12914. * @hidden
  12915. * @param faceIndex the face index, if its a cube texture
  12916. */ bindFrameBuffer(faceIndex?: number): void;
  12917. /**
  12918. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12919. * @returns the view count
  12920. */
  12921. getViewCount(): number;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. interface Engine {
  12926. /**
  12927. * Creates a new multiview render target
  12928. * @param width defines the width of the texture
  12929. * @param height defines the height of the texture
  12930. * @returns the created multiview texture
  12931. */
  12932. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12933. /**
  12934. * Binds a multiview framebuffer to be drawn to
  12935. * @param multiviewTexture texture to bind
  12936. */
  12937. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12938. }
  12939. interface Camera {
  12940. /**
  12941. * @hidden
  12942. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12943. */ useMultiviewToSingleView: boolean;
  12944. /**
  12945. * @hidden
  12946. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12947. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12948. /**
  12949. * @hidden
  12950. * ensures the multiview texture of the camera exists and has the specified width/height
  12951. * @param width height to set on the multiview texture
  12952. * @param height width to set on the multiview texture
  12953. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12954. }
  12955. interface Scene {
  12956. /** @hidden */ transformMatrixR: Matrix;
  12957. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12958. /** @hidden */ createMultiviewUbo(): void;
  12959. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12960. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12961. }
  12962. }
  12963. declare module BABYLON {
  12964. /**
  12965. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12966. * This will not be used for webXR as it supports displaying texture arrays directly
  12967. */
  12968. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12969. /**
  12970. * Initializes a VRMultiviewToSingleview
  12971. * @param name name of the post process
  12972. * @param camera camera to be applied to
  12973. * @param scaleFactor scaling factor to the size of the output texture
  12974. */
  12975. constructor(name: string, camera: Camera, scaleFactor: number);
  12976. }
  12977. }
  12978. declare module BABYLON {
  12979. /**
  12980. * Defines the interface used by display changed events
  12981. */
  12982. interface IDisplayChangedEventArgs {
  12983. /** Gets the vrDisplay object (if any) */
  12984. vrDisplay: Nullable<any>;
  12985. /** Gets a boolean indicating if webVR is supported */
  12986. vrSupported: boolean;
  12987. }
  12988. interface Engine {
  12989. /** @hidden */ vrDisplay: any;
  12990. /** @hidden */ vrSupported: boolean;
  12991. /** @hidden */ oldSize: Size;
  12992. /** @hidden */ oldHardwareScaleFactor: number;
  12993. /** @hidden */ vrExclusivePointerMode: boolean;
  12994. /** @hidden */ webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  12995. /** @hidden */ onVRDisplayPointerRestricted: () => void;
  12996. /** @hidden */ onVRDisplayPointerUnrestricted: () => void;
  12997. /** @hidden */ onVrDisplayConnect: Nullable<(display: any) => void>;
  12998. /** @hidden */ onVrDisplayDisconnect: Nullable<() => void>;
  12999. /** @hidden */ onVrDisplayPresentChange: Nullable<() => void>;
  13000. /**
  13001. * Observable signaled when VR display mode changes
  13002. */
  13003. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13004. /**
  13005. * Observable signaled when VR request present is complete
  13006. */
  13007. onVRRequestPresentComplete: Observable<boolean>;
  13008. /**
  13009. * Observable signaled when VR request present starts
  13010. */
  13011. onVRRequestPresentStart: Observable<Engine>;
  13012. /**
  13013. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13014. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13015. */
  13016. isInVRExclusivePointerMode: boolean;
  13017. /**
  13018. * Gets a boolean indicating if a webVR device was detected
  13019. * @returns true if a webVR device was detected
  13020. */
  13021. isVRDevicePresent(): boolean;
  13022. /**
  13023. * Gets the current webVR device
  13024. * @returns the current webVR device (or null)
  13025. */
  13026. getVRDevice(): any;
  13027. /**
  13028. * Initializes a webVR display and starts listening to display change events
  13029. * The onVRDisplayChangedObservable will be notified upon these changes
  13030. * @returns A promise containing a VRDisplay and if vr is supported
  13031. */
  13032. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13033. /** @hidden */ getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13034. /**
  13035. * Call this function to switch to webVR mode
  13036. * Will do nothing if webVR is not supported or if there is no webVR device
  13037. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13038. */
  13039. enableVR(): void;
  13040. /** @hidden */ onVRFullScreenTriggered(): void;
  13041. }
  13042. }
  13043. declare module BABYLON {
  13044. /**
  13045. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13046. * IMPORTANT!! The data is right-hand data.
  13047. * @export
  13048. * @interface DevicePose
  13049. */
  13050. export interface DevicePose {
  13051. /**
  13052. * The position of the device, values in array are [x,y,z].
  13053. */
  13054. readonly position: Nullable<Float32Array>;
  13055. /**
  13056. * The linearVelocity of the device, values in array are [x,y,z].
  13057. */
  13058. readonly linearVelocity: Nullable<Float32Array>;
  13059. /**
  13060. * The linearAcceleration of the device, values in array are [x,y,z].
  13061. */
  13062. readonly linearAcceleration: Nullable<Float32Array>;
  13063. /**
  13064. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13065. */
  13066. readonly orientation: Nullable<Float32Array>;
  13067. /**
  13068. * The angularVelocity of the device, values in array are [x,y,z].
  13069. */
  13070. readonly angularVelocity: Nullable<Float32Array>;
  13071. /**
  13072. * The angularAcceleration of the device, values in array are [x,y,z].
  13073. */
  13074. readonly angularAcceleration: Nullable<Float32Array>;
  13075. }
  13076. /**
  13077. * Interface representing a pose controlled object in Babylon.
  13078. * A pose controlled object has both regular pose values as well as pose values
  13079. * from an external device such as a VR head mounted display
  13080. */
  13081. export interface PoseControlled {
  13082. /**
  13083. * The position of the object in babylon space.
  13084. */
  13085. position: Vector3;
  13086. /**
  13087. * The rotation quaternion of the object in babylon space.
  13088. */
  13089. rotationQuaternion: Quaternion;
  13090. /**
  13091. * The position of the device in babylon space.
  13092. */
  13093. devicePosition?: Vector3;
  13094. /**
  13095. * The rotation quaternion of the device in babylon space.
  13096. */
  13097. deviceRotationQuaternion: Quaternion;
  13098. /**
  13099. * The raw pose coming from the device.
  13100. */
  13101. rawPose: Nullable<DevicePose>;
  13102. /**
  13103. * The scale of the device to be used when translating from device space to babylon space.
  13104. */
  13105. deviceScaleFactor: number;
  13106. /**
  13107. * Updates the poseControlled values based on the input device pose.
  13108. * @param poseData the pose data to update the object with
  13109. */
  13110. updateFromDevice(poseData: DevicePose): void;
  13111. }
  13112. /**
  13113. * Set of options to customize the webVRCamera
  13114. */
  13115. export interface WebVROptions {
  13116. /**
  13117. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13118. */
  13119. trackPosition?: boolean;
  13120. /**
  13121. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13122. */
  13123. positionScale?: number;
  13124. /**
  13125. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13126. */
  13127. displayName?: string;
  13128. /**
  13129. * Should the native controller meshes be initialized. (default: true)
  13130. */
  13131. controllerMeshes?: boolean;
  13132. /**
  13133. * Creating a default HemiLight only on controllers. (default: true)
  13134. */
  13135. defaultLightingOnControllers?: boolean;
  13136. /**
  13137. * If you don't want to use the default VR button of the helper. (default: false)
  13138. */
  13139. useCustomVRButton?: boolean;
  13140. /**
  13141. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13142. */
  13143. customVRButton?: HTMLButtonElement;
  13144. /**
  13145. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13146. */
  13147. rayLength?: number;
  13148. /**
  13149. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13150. */
  13151. defaultHeight?: number;
  13152. /**
  13153. * If multiview should be used if availible (default: false)
  13154. */
  13155. useMultiview?: boolean;
  13156. }
  13157. /**
  13158. * This represents a WebVR camera.
  13159. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13160. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13161. */
  13162. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13163. private webVROptions;
  13164. /**
  13165. * @hidden
  13166. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13167. */ vrDevice: any;
  13168. /**
  13169. * The rawPose of the vrDevice.
  13170. */
  13171. rawPose: Nullable<DevicePose>;
  13172. private _onVREnabled;
  13173. private _specsVersion;
  13174. private _attached;
  13175. private _frameData;
  13176. protected _descendants: Array<Node>;
  13177. private _deviceRoomPosition;
  13178. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13179. private _standingMatrix;
  13180. /**
  13181. * Represents device position in babylon space.
  13182. */
  13183. devicePosition: Vector3;
  13184. /**
  13185. * Represents device rotation in babylon space.
  13186. */
  13187. deviceRotationQuaternion: Quaternion;
  13188. /**
  13189. * The scale of the device to be used when translating from device space to babylon space.
  13190. */
  13191. deviceScaleFactor: number;
  13192. private _deviceToWorld;
  13193. private _worldToDevice;
  13194. /**
  13195. * References to the webVR controllers for the vrDevice.
  13196. */
  13197. controllers: Array<WebVRController>;
  13198. /**
  13199. * Emits an event when a controller is attached.
  13200. */
  13201. onControllersAttachedObservable: Observable<WebVRController[]>;
  13202. /**
  13203. * Emits an event when a controller's mesh has been loaded;
  13204. */
  13205. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13206. /**
  13207. * Emits an event when the HMD's pose has been updated.
  13208. */
  13209. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13210. private _poseSet;
  13211. /**
  13212. * If the rig cameras be used as parent instead of this camera.
  13213. */
  13214. rigParenting: boolean;
  13215. private _lightOnControllers;
  13216. private _defaultHeight?;
  13217. /**
  13218. * Instantiates a WebVRFreeCamera.
  13219. * @param name The name of the WebVRFreeCamera
  13220. * @param position The starting anchor position for the camera
  13221. * @param scene The scene the camera belongs to
  13222. * @param webVROptions a set of customizable options for the webVRCamera
  13223. */
  13224. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13225. /**
  13226. * Gets the device distance from the ground in meters.
  13227. * @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.
  13228. */
  13229. deviceDistanceToRoomGround(): number;
  13230. /**
  13231. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13232. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13233. */
  13234. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13235. /**
  13236. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13237. * @returns A promise with a boolean set to if the standing matrix is supported.
  13238. */
  13239. useStandingMatrixAsync(): Promise<boolean>;
  13240. /**
  13241. * Disposes the camera
  13242. */
  13243. dispose(): void;
  13244. /**
  13245. * Gets a vrController by name.
  13246. * @param name The name of the controller to retreive
  13247. * @returns the controller matching the name specified or null if not found
  13248. */
  13249. getControllerByName(name: string): Nullable<WebVRController>;
  13250. private _leftController;
  13251. /**
  13252. * The controller corrisponding to the users left hand.
  13253. */
  13254. readonly leftController: Nullable<WebVRController>;
  13255. private _rightController;
  13256. /**
  13257. * The controller corrisponding to the users right hand.
  13258. */
  13259. readonly rightController: Nullable<WebVRController>;
  13260. /**
  13261. * Casts a ray forward from the vrCamera's gaze.
  13262. * @param length Length of the ray (default: 100)
  13263. * @returns the ray corrisponding to the gaze
  13264. */
  13265. getForwardRay(length?: number): Ray;
  13266. /**
  13267. * @hidden
  13268. * Updates the camera based on device's frame data
  13269. */ checkInputs(): void;
  13270. /**
  13271. * Updates the poseControlled values based on the input device pose.
  13272. * @param poseData Pose coming from the device
  13273. */
  13274. updateFromDevice(poseData: DevicePose): void;
  13275. private _htmlElementAttached;
  13276. private _detachIfAttached;
  13277. /**
  13278. * WebVR's attach control will start broadcasting frames to the device.
  13279. * Note that in certain browsers (chrome for example) this function must be called
  13280. * within a user-interaction callback. Example:
  13281. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13282. *
  13283. * @param element html element to attach the vrDevice to
  13284. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13285. */
  13286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13287. /**
  13288. * Detaches the camera from the html element and disables VR
  13289. *
  13290. * @param element html element to detach from
  13291. */
  13292. detachControl(element: HTMLElement): void;
  13293. /**
  13294. * @returns the name of this class
  13295. */
  13296. getClassName(): string;
  13297. /**
  13298. * Calls resetPose on the vrDisplay
  13299. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13300. */
  13301. resetToCurrentRotation(): void;
  13302. /**
  13303. * @hidden
  13304. * Updates the rig cameras (left and right eye)
  13305. */ updateRigCameras(): void;
  13306. private _workingVector;
  13307. private _oneVector;
  13308. private _workingMatrix;
  13309. private updateCacheCalled;
  13310. private _correctPositionIfNotTrackPosition;
  13311. /**
  13312. * @hidden
  13313. * Updates the cached values of the camera
  13314. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13315. */ updateCache(ignoreParentClass?: boolean): void;
  13316. /**
  13317. * @hidden
  13318. * Get current device position in babylon world
  13319. */ computeDevicePosition(): void;
  13320. /**
  13321. * Updates the current device position and rotation in the babylon world
  13322. */
  13323. update(): void;
  13324. /**
  13325. * @hidden
  13326. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13327. * @returns an identity matrix
  13328. */ getViewMatrix(): Matrix;
  13329. private _tmpMatrix;
  13330. /**
  13331. * This function is called by the two RIG cameras.
  13332. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13333. * @hidden
  13334. */ getWebVRViewMatrix(): Matrix;
  13335. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13336. private _onGamepadConnectedObserver;
  13337. private _onGamepadDisconnectedObserver;
  13338. private _updateCacheWhenTrackingDisabledObserver;
  13339. /**
  13340. * Initializes the controllers and their meshes
  13341. */
  13342. initControllers(): void;
  13343. }
  13344. }
  13345. declare module BABYLON {
  13346. /**
  13347. * Size options for a post process
  13348. */
  13349. export type PostProcessOptions = {
  13350. width: number;
  13351. height: number;
  13352. };
  13353. /**
  13354. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13356. */
  13357. export class PostProcess {
  13358. /** Name of the PostProcess. */
  13359. name: string;
  13360. /**
  13361. * Gets or sets the unique id of the post process
  13362. */
  13363. uniqueId: number;
  13364. /**
  13365. * Width of the texture to apply the post process on
  13366. */
  13367. width: number;
  13368. /**
  13369. * Height of the texture to apply the post process on
  13370. */
  13371. height: number;
  13372. /**
  13373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13374. * @hidden
  13375. */ outputTexture: Nullable<InternalTexture>;
  13376. /**
  13377. * Sampling mode used by the shader
  13378. * See https://doc.babylonjs.com/classes/3.1/texture
  13379. */
  13380. renderTargetSamplingMode: number;
  13381. /**
  13382. * Clear color to use when screen clearing
  13383. */
  13384. clearColor: Color4;
  13385. /**
  13386. * If the buffer needs to be cleared before applying the post process. (default: true)
  13387. * Should be set to false if shader will overwrite all previous pixels.
  13388. */
  13389. autoClear: boolean;
  13390. /**
  13391. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13392. */
  13393. alphaMode: number;
  13394. /**
  13395. * Sets the setAlphaBlendConstants of the babylon engine
  13396. */
  13397. alphaConstants: Color4;
  13398. /**
  13399. * Animations to be used for the post processing
  13400. */
  13401. animations: Animation[];
  13402. /**
  13403. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13404. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13405. */
  13406. enablePixelPerfectMode: boolean;
  13407. /**
  13408. * Force the postprocess to be applied without taking in account viewport
  13409. */
  13410. forceFullscreenViewport: boolean;
  13411. /**
  13412. * List of inspectable custom properties (used by the Inspector)
  13413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13414. */
  13415. inspectableCustomProperties: IInspectable[];
  13416. /**
  13417. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13418. *
  13419. * | Value | Type | Description |
  13420. * | ----- | ----------------------------------- | ----------- |
  13421. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13422. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13423. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13424. *
  13425. */
  13426. scaleMode: number;
  13427. /**
  13428. * Force textures to be a power of two (default: false)
  13429. */
  13430. alwaysForcePOT: boolean;
  13431. private _samples;
  13432. /**
  13433. * Number of sample textures (default: 1)
  13434. */
  13435. samples: number;
  13436. /**
  13437. * Modify the scale of the post process to be the same as the viewport (default: false)
  13438. */
  13439. adaptScaleToCurrentViewport: boolean;
  13440. private _camera;
  13441. private _scene;
  13442. private _engine;
  13443. private _options;
  13444. private _reusable;
  13445. private _textureType;
  13446. /**
  13447. * Smart array of input and output textures for the post process.
  13448. * @hidden
  13449. */ textures: SmartArray<InternalTexture>;
  13450. /**
  13451. * The index in _textures that corresponds to the output texture.
  13452. * @hidden
  13453. */ currentRenderTextureInd: number;
  13454. private _effect;
  13455. private _samplers;
  13456. private _fragmentUrl;
  13457. private _vertexUrl;
  13458. private _parameters;
  13459. private _scaleRatio;
  13460. protected _indexParameters: any;
  13461. private _shareOutputWithPostProcess;
  13462. private _texelSize;
  13463. private _forcedOutputTexture;
  13464. /**
  13465. * Returns the fragment url or shader name used in the post process.
  13466. * @returns the fragment url or name in the shader store.
  13467. */
  13468. getEffectName(): string;
  13469. /**
  13470. * An event triggered when the postprocess is activated.
  13471. */
  13472. onActivateObservable: Observable<Camera>;
  13473. private _onActivateObserver;
  13474. /**
  13475. * A function that is added to the onActivateObservable
  13476. */
  13477. onActivate: Nullable<(camera: Camera) => void>;
  13478. /**
  13479. * An event triggered when the postprocess changes its size.
  13480. */
  13481. onSizeChangedObservable: Observable<PostProcess>;
  13482. private _onSizeChangedObserver;
  13483. /**
  13484. * A function that is added to the onSizeChangedObservable
  13485. */
  13486. onSizeChanged: (postProcess: PostProcess) => void;
  13487. /**
  13488. * An event triggered when the postprocess applies its effect.
  13489. */
  13490. onApplyObservable: Observable<Effect>;
  13491. private _onApplyObserver;
  13492. /**
  13493. * A function that is added to the onApplyObservable
  13494. */
  13495. onApply: (effect: Effect) => void;
  13496. /**
  13497. * An event triggered before rendering the postprocess
  13498. */
  13499. onBeforeRenderObservable: Observable<Effect>;
  13500. private _onBeforeRenderObserver;
  13501. /**
  13502. * A function that is added to the onBeforeRenderObservable
  13503. */
  13504. onBeforeRender: (effect: Effect) => void;
  13505. /**
  13506. * An event triggered after rendering the postprocess
  13507. */
  13508. onAfterRenderObservable: Observable<Effect>;
  13509. private _onAfterRenderObserver;
  13510. /**
  13511. * A function that is added to the onAfterRenderObservable
  13512. */
  13513. onAfterRender: (efect: Effect) => void;
  13514. /**
  13515. * 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
  13516. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13517. */
  13518. inputTexture: InternalTexture;
  13519. /**
  13520. * Gets the camera which post process is applied to.
  13521. * @returns The camera the post process is applied to.
  13522. */
  13523. getCamera(): Camera;
  13524. /**
  13525. * Gets the texel size of the postprocess.
  13526. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13527. */
  13528. readonly texelSize: Vector2;
  13529. /**
  13530. * Creates a new instance PostProcess
  13531. * @param name The name of the PostProcess.
  13532. * @param fragmentUrl The url of the fragment shader to be used.
  13533. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13534. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13535. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13536. * @param camera The camera to apply the render pass to.
  13537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13538. * @param engine The engine which the post process will be applied. (default: current engine)
  13539. * @param reusable If the post process can be reused on the same frame. (default: false)
  13540. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13541. * @param textureType Type of textures used when performing the post process. (default: 0)
  13542. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13543. * @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
  13544. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13545. */
  13546. constructor(
  13547. /** Name of the PostProcess. */
  13548. 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);
  13549. /**
  13550. * Gets a string idenfifying the name of the class
  13551. * @returns "PostProcess" string
  13552. */
  13553. getClassName(): string;
  13554. /**
  13555. * Gets the engine which this post process belongs to.
  13556. * @returns The engine the post process was enabled with.
  13557. */
  13558. getEngine(): Engine;
  13559. /**
  13560. * The effect that is created when initializing the post process.
  13561. * @returns The created effect corrisponding the the postprocess.
  13562. */
  13563. getEffect(): Effect;
  13564. /**
  13565. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13566. * @param postProcess The post process to share the output with.
  13567. * @returns This post process.
  13568. */
  13569. shareOutputWith(postProcess: PostProcess): PostProcess;
  13570. /**
  13571. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13572. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13573. */
  13574. useOwnOutput(): void;
  13575. /**
  13576. * Updates the effect with the current post process compile time values and recompiles the shader.
  13577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13580. * @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
  13581. * @param onCompiled Called when the shader has been compiled.
  13582. * @param onError Called if there is an error when compiling a shader.
  13583. */
  13584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13585. /**
  13586. * The post process is reusable if it can be used multiple times within one frame.
  13587. * @returns If the post process is reusable
  13588. */
  13589. isReusable(): boolean;
  13590. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13591. markTextureDirty(): void;
  13592. /**
  13593. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13594. * 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.
  13595. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13596. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13597. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13598. * @returns The target texture that was bound to be written to.
  13599. */
  13600. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13601. /**
  13602. * If the post process is supported.
  13603. */
  13604. readonly isSupported: boolean;
  13605. /**
  13606. * The aspect ratio of the output texture.
  13607. */
  13608. readonly aspectRatio: number;
  13609. /**
  13610. * Get a value indicating if the post-process is ready to be used
  13611. * @returns true if the post-process is ready (shader is compiled)
  13612. */
  13613. isReady(): boolean;
  13614. /**
  13615. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13616. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13617. */
  13618. apply(): Nullable<Effect>;
  13619. private _disposeTextures;
  13620. /**
  13621. * Disposes the post process.
  13622. * @param camera The camera to dispose the post process on.
  13623. */
  13624. dispose(camera?: Camera): void;
  13625. }
  13626. }
  13627. declare module BABYLON {
  13628. /**
  13629. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13630. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13631. */
  13632. export class PostProcessManager {
  13633. private _scene;
  13634. private _indexBuffer;
  13635. private _vertexBuffers;
  13636. /**
  13637. * Creates a new instance PostProcess
  13638. * @param scene The scene that the post process is associated with.
  13639. */
  13640. constructor(scene: Scene);
  13641. private _prepareBuffers;
  13642. private _buildIndexBuffer;
  13643. /**
  13644. * Rebuilds the vertex buffers of the manager.
  13645. * @hidden
  13646. */ rebuild(): void;
  13647. /**
  13648. * Prepares a frame to be run through a post process.
  13649. * @param sourceTexture The input texture to the post procesess. (default: null)
  13650. * @param postProcesses An array of post processes to be run. (default: null)
  13651. * @returns True if the post processes were able to be run.
  13652. * @hidden
  13653. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13654. /**
  13655. * Manually render a set of post processes to a texture.
  13656. * @param postProcesses An array of post processes to be run.
  13657. * @param targetTexture The target texture to render to.
  13658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13659. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13660. * @param lodLevel defines which lod of the texture to render to
  13661. */
  13662. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13663. /**
  13664. * Finalize the result of the output of the postprocesses.
  13665. * @param doNotPresent If true the result will not be displayed to the screen.
  13666. * @param targetTexture The target texture to render to.
  13667. * @param faceIndex The index of the face to bind the target texture to.
  13668. * @param postProcesses The array of post processes to render.
  13669. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13670. * @hidden
  13671. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13672. /**
  13673. * Disposes of the post process manager.
  13674. */
  13675. dispose(): void;
  13676. }
  13677. }
  13678. declare module BABYLON {
  13679. interface AbstractScene {
  13680. /**
  13681. * The list of layers (background and foreground) of the scene
  13682. */
  13683. layers: Array<Layer>;
  13684. }
  13685. /**
  13686. * Defines the layer scene component responsible to manage any layers
  13687. * in a given scene.
  13688. */
  13689. export class LayerSceneComponent implements ISceneComponent {
  13690. /**
  13691. * The component name helpfull to identify the component in the list of scene components.
  13692. */
  13693. readonly name: string;
  13694. /**
  13695. * The scene the component belongs to.
  13696. */
  13697. scene: Scene;
  13698. private _engine;
  13699. /**
  13700. * Creates a new instance of the component for the given scene
  13701. * @param scene Defines the scene to register the component in
  13702. */
  13703. constructor(scene: Scene);
  13704. /**
  13705. * Registers the component in a given scene
  13706. */
  13707. register(): void;
  13708. /**
  13709. * Rebuilds the elements related to this component in case of
  13710. * context lost for instance.
  13711. */
  13712. rebuild(): void;
  13713. /**
  13714. * Disposes the component and the associated ressources.
  13715. */
  13716. dispose(): void;
  13717. private _draw;
  13718. private _drawCameraPredicate;
  13719. private _drawCameraBackground;
  13720. private _drawCameraForeground;
  13721. private _drawRenderTargetPredicate;
  13722. private _drawRenderTargetBackground;
  13723. private _drawRenderTargetForeground;
  13724. }
  13725. }
  13726. declare module BABYLON {
  13727. /** @hidden */
  13728. export var layerPixelShader: {
  13729. name: string;
  13730. shader: string;
  13731. };
  13732. }
  13733. declare module BABYLON {
  13734. /** @hidden */
  13735. export var layerVertexShader: {
  13736. name: string;
  13737. shader: string;
  13738. };
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * This represents a full screen 2d layer.
  13743. * This can be useful to display a picture in the background of your scene for instance.
  13744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13745. */
  13746. export class Layer {
  13747. /**
  13748. * Define the name of the layer.
  13749. */
  13750. name: string;
  13751. /**
  13752. * Define the texture the layer should display.
  13753. */
  13754. texture: Nullable<Texture>;
  13755. /**
  13756. * Is the layer in background or foreground.
  13757. */
  13758. isBackground: boolean;
  13759. /**
  13760. * Define the color of the layer (instead of texture).
  13761. */
  13762. color: Color4;
  13763. /**
  13764. * Define the scale of the layer in order to zoom in out of the texture.
  13765. */
  13766. scale: Vector2;
  13767. /**
  13768. * Define an offset for the layer in order to shift the texture.
  13769. */
  13770. offset: Vector2;
  13771. /**
  13772. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13773. */
  13774. alphaBlendingMode: number;
  13775. /**
  13776. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13777. * Alpha test will not mix with the background color in case of transparency.
  13778. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13779. */
  13780. alphaTest: boolean;
  13781. /**
  13782. * Define a mask to restrict the layer to only some of the scene cameras.
  13783. */
  13784. layerMask: number;
  13785. /**
  13786. * Define the list of render target the layer is visible into.
  13787. */
  13788. renderTargetTextures: RenderTargetTexture[];
  13789. /**
  13790. * Define if the layer is only used in renderTarget or if it also
  13791. * renders in the main frame buffer of the canvas.
  13792. */
  13793. renderOnlyInRenderTargetTextures: boolean;
  13794. private _scene;
  13795. private _vertexBuffers;
  13796. private _indexBuffer;
  13797. private _effect;
  13798. private _alphaTestEffect;
  13799. /**
  13800. * An event triggered when the layer is disposed.
  13801. */
  13802. onDisposeObservable: Observable<Layer>;
  13803. private _onDisposeObserver;
  13804. /**
  13805. * Back compatibility with callback before the onDisposeObservable existed.
  13806. * The set callback will be triggered when the layer has been disposed.
  13807. */
  13808. onDispose: () => void;
  13809. /**
  13810. * An event triggered before rendering the scene
  13811. */
  13812. onBeforeRenderObservable: Observable<Layer>;
  13813. private _onBeforeRenderObserver;
  13814. /**
  13815. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13816. * The set callback will be triggered just before rendering the layer.
  13817. */
  13818. onBeforeRender: () => void;
  13819. /**
  13820. * An event triggered after rendering the scene
  13821. */
  13822. onAfterRenderObservable: Observable<Layer>;
  13823. private _onAfterRenderObserver;
  13824. /**
  13825. * Back compatibility with callback before the onAfterRenderObservable existed.
  13826. * The set callback will be triggered just after rendering the layer.
  13827. */
  13828. onAfterRender: () => void;
  13829. /**
  13830. * Instantiates a new layer.
  13831. * This represents a full screen 2d layer.
  13832. * This can be useful to display a picture in the background of your scene for instance.
  13833. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13834. * @param name Define the name of the layer in the scene
  13835. * @param imgUrl Define the url of the texture to display in the layer
  13836. * @param scene Define the scene the layer belongs to
  13837. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13838. * @param color Defines a color for the layer
  13839. */
  13840. constructor(
  13841. /**
  13842. * Define the name of the layer.
  13843. */
  13844. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13845. private _createIndexBuffer;
  13846. /** @hidden */ rebuild(): void;
  13847. /**
  13848. * Renders the layer in the scene.
  13849. */
  13850. render(): void;
  13851. /**
  13852. * Disposes and releases the associated ressources.
  13853. */
  13854. dispose(): void;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. interface AbstractScene {
  13859. /**
  13860. * The list of procedural textures added to the scene
  13861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13862. */
  13863. proceduralTextures: Array<ProceduralTexture>;
  13864. }
  13865. /**
  13866. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13867. * in a given scene.
  13868. */
  13869. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13870. /**
  13871. * The component name helpfull to identify the component in the list of scene components.
  13872. */
  13873. readonly name: string;
  13874. /**
  13875. * The scene the component belongs to.
  13876. */
  13877. scene: Scene;
  13878. /**
  13879. * Creates a new instance of the component for the given scene
  13880. * @param scene Defines the scene to register the component in
  13881. */
  13882. constructor(scene: Scene);
  13883. /**
  13884. * Registers the component in a given scene
  13885. */
  13886. register(): void;
  13887. /**
  13888. * Rebuilds the elements related to this component in case of
  13889. * context lost for instance.
  13890. */
  13891. rebuild(): void;
  13892. /**
  13893. * Disposes the component and the associated ressources.
  13894. */
  13895. dispose(): void;
  13896. private _beforeClear;
  13897. }
  13898. }
  13899. declare module BABYLON {
  13900. interface Engine {
  13901. /**
  13902. * Creates a new render target cube texture
  13903. * @param size defines the size of the texture
  13904. * @param options defines the options used to create the texture
  13905. * @returns a new render target cube texture stored in an InternalTexture
  13906. */
  13907. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13908. }
  13909. }
  13910. declare module BABYLON {
  13911. /** @hidden */
  13912. export var proceduralVertexShader: {
  13913. name: string;
  13914. shader: string;
  13915. };
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * 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.
  13920. * This is the base class of any Procedural texture and contains most of the shareable code.
  13921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13922. */
  13923. export class ProceduralTexture extends Texture {
  13924. isCube: boolean;
  13925. /**
  13926. * Define if the texture is enabled or not (disabled texture will not render)
  13927. */
  13928. isEnabled: boolean;
  13929. /**
  13930. * Define if the texture must be cleared before rendering (default is true)
  13931. */
  13932. autoClear: boolean;
  13933. /**
  13934. * Callback called when the texture is generated
  13935. */
  13936. onGenerated: () => void;
  13937. /**
  13938. * Event raised when the texture is generated
  13939. */
  13940. onGeneratedObservable: Observable<ProceduralTexture>;
  13941. /** @hidden */ generateMipMaps: boolean;
  13942. /** @hidden **/ effect: Effect;
  13943. /** @hidden */ textures: {
  13944. [key: string]: Texture;
  13945. };
  13946. private _size;
  13947. private _currentRefreshId;
  13948. private _refreshRate;
  13949. private _vertexBuffers;
  13950. private _indexBuffer;
  13951. private _uniforms;
  13952. private _samplers;
  13953. private _fragment;
  13954. private _floats;
  13955. private _ints;
  13956. private _floatsArrays;
  13957. private _colors3;
  13958. private _colors4;
  13959. private _vectors2;
  13960. private _vectors3;
  13961. private _matrices;
  13962. private _fallbackTexture;
  13963. private _fallbackTextureUsed;
  13964. private _engine;
  13965. private _cachedDefines;
  13966. private _contentUpdateId;
  13967. private _contentData;
  13968. /**
  13969. * Instantiates a new procedural texture.
  13970. * 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.
  13971. * This is the base class of any Procedural texture and contains most of the shareable code.
  13972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13973. * @param name Define the name of the texture
  13974. * @param size Define the size of the texture to create
  13975. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13976. * @param scene Define the scene the texture belongs to
  13977. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13978. * @param generateMipMaps Define if the texture should creates mip maps or not
  13979. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13980. */
  13981. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13982. /**
  13983. * The effect that is created when initializing the post process.
  13984. * @returns The created effect corrisponding the the postprocess.
  13985. */
  13986. getEffect(): Effect;
  13987. /**
  13988. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13989. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13990. */
  13991. getContent(): Nullable<ArrayBufferView>;
  13992. private _createIndexBuffer;
  13993. /** @hidden */ rebuild(): void;
  13994. /**
  13995. * Resets the texture in order to recreate its associated resources.
  13996. * This can be called in case of context loss
  13997. */
  13998. reset(): void;
  13999. protected _getDefines(): string;
  14000. /**
  14001. * Is the texture ready to be used ? (rendered at least once)
  14002. * @returns true if ready, otherwise, false.
  14003. */
  14004. isReady(): boolean;
  14005. /**
  14006. * Resets the refresh counter of the texture and start bak from scratch.
  14007. * Could be useful to regenerate the texture if it is setup to render only once.
  14008. */
  14009. resetRefreshCounter(): void;
  14010. /**
  14011. * Set the fragment shader to use in order to render the texture.
  14012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14013. */
  14014. setFragment(fragment: any): void;
  14015. /**
  14016. * Define the refresh rate of the texture or the rendering frequency.
  14017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14018. */
  14019. refreshRate: number;
  14020. /** @hidden */ shouldRender(): boolean;
  14021. /**
  14022. * Get the size the texture is rendering at.
  14023. * @returns the size (texture is always squared)
  14024. */
  14025. getRenderSize(): number;
  14026. /**
  14027. * Resize the texture to new value.
  14028. * @param size Define the new size the texture should have
  14029. * @param generateMipMaps Define whether the new texture should create mip maps
  14030. */
  14031. resize(size: number, generateMipMaps: boolean): void;
  14032. private _checkUniform;
  14033. /**
  14034. * Set a texture in the shader program used to render.
  14035. * @param name Define the name of the uniform samplers as defined in the shader
  14036. * @param texture Define the texture to bind to this sampler
  14037. * @return the texture itself allowing "fluent" like uniform updates
  14038. */
  14039. setTexture(name: string, texture: Texture): ProceduralTexture;
  14040. /**
  14041. * Set a float in the shader.
  14042. * @param name Define the name of the uniform as defined in the shader
  14043. * @param value Define the value to give to the uniform
  14044. * @return the texture itself allowing "fluent" like uniform updates
  14045. */
  14046. setFloat(name: string, value: number): ProceduralTexture;
  14047. /**
  14048. * Set a int in the shader.
  14049. * @param name Define the name of the uniform as defined in the shader
  14050. * @param value Define the value to give to the uniform
  14051. * @return the texture itself allowing "fluent" like uniform updates
  14052. */
  14053. setInt(name: string, value: number): ProceduralTexture;
  14054. /**
  14055. * Set an array of floats in the shader.
  14056. * @param name Define the name of the uniform as defined in the shader
  14057. * @param value Define the value to give to the uniform
  14058. * @return the texture itself allowing "fluent" like uniform updates
  14059. */
  14060. setFloats(name: string, value: number[]): ProceduralTexture;
  14061. /**
  14062. * Set a vec3 in the shader from a Color3.
  14063. * @param name Define the name of the uniform as defined in the shader
  14064. * @param value Define the value to give to the uniform
  14065. * @return the texture itself allowing "fluent" like uniform updates
  14066. */
  14067. setColor3(name: string, value: Color3): ProceduralTexture;
  14068. /**
  14069. * Set a vec4 in the shader from a Color4.
  14070. * @param name Define the name of the uniform as defined in the shader
  14071. * @param value Define the value to give to the uniform
  14072. * @return the texture itself allowing "fluent" like uniform updates
  14073. */
  14074. setColor4(name: string, value: Color4): ProceduralTexture;
  14075. /**
  14076. * Set a vec2 in the shader from a Vector2.
  14077. * @param name Define the name of the uniform as defined in the shader
  14078. * @param value Define the value to give to the uniform
  14079. * @return the texture itself allowing "fluent" like uniform updates
  14080. */
  14081. setVector2(name: string, value: Vector2): ProceduralTexture;
  14082. /**
  14083. * Set a vec3 in the shader from a Vector3.
  14084. * @param name Define the name of the uniform as defined in the shader
  14085. * @param value Define the value to give to the uniform
  14086. * @return the texture itself allowing "fluent" like uniform updates
  14087. */
  14088. setVector3(name: string, value: Vector3): ProceduralTexture;
  14089. /**
  14090. * Set a mat4 in the shader from a MAtrix.
  14091. * @param name Define the name of the uniform as defined in the shader
  14092. * @param value Define the value to give to the uniform
  14093. * @return the texture itself allowing "fluent" like uniform updates
  14094. */
  14095. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14096. /**
  14097. * Render the texture to its associated render target.
  14098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14099. */
  14100. render(useCameraPostProcess?: boolean): void;
  14101. /**
  14102. * Clone the texture.
  14103. * @returns the cloned texture
  14104. */
  14105. clone(): ProceduralTexture;
  14106. /**
  14107. * Dispose the texture and release its asoociated resources.
  14108. */
  14109. dispose(): void;
  14110. }
  14111. }
  14112. declare module BABYLON {
  14113. /**
  14114. * This represents the base class for particle system in Babylon.
  14115. * 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.
  14116. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14117. * @example https://doc.babylonjs.com/babylon101/particles
  14118. */
  14119. export class BaseParticleSystem {
  14120. /**
  14121. * Source color is added to the destination color without alpha affecting the result
  14122. */
  14123. static BLENDMODE_ONEONE: number;
  14124. /**
  14125. * Blend current color and particle color using particle’s alpha
  14126. */
  14127. static BLENDMODE_STANDARD: number;
  14128. /**
  14129. * Add current color and particle color multiplied by particle’s alpha
  14130. */
  14131. static BLENDMODE_ADD: number;
  14132. /**
  14133. * Multiply current color with particle color
  14134. */
  14135. static BLENDMODE_MULTIPLY: number;
  14136. /**
  14137. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14138. */
  14139. static BLENDMODE_MULTIPLYADD: number;
  14140. /**
  14141. * List of animations used by the particle system.
  14142. */
  14143. animations: Animation[];
  14144. /**
  14145. * The id of the Particle system.
  14146. */
  14147. id: string;
  14148. /**
  14149. * The friendly name of the Particle system.
  14150. */
  14151. name: string;
  14152. /**
  14153. * The rendering group used by the Particle system to chose when to render.
  14154. */
  14155. renderingGroupId: number;
  14156. /**
  14157. * The emitter represents the Mesh or position we are attaching the particle system to.
  14158. */
  14159. emitter: Nullable<AbstractMesh | Vector3>;
  14160. /**
  14161. * The maximum number of particles to emit per frame
  14162. */
  14163. emitRate: number;
  14164. /**
  14165. * If you want to launch only a few particles at once, that can be done, as well.
  14166. */
  14167. manualEmitCount: number;
  14168. /**
  14169. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14170. */
  14171. updateSpeed: number;
  14172. /**
  14173. * The amount of time the particle system is running (depends of the overall update speed).
  14174. */
  14175. targetStopDuration: number;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Minimum power of emitting particles.
  14182. */
  14183. minEmitPower: number;
  14184. /**
  14185. * Maximum power of emitting particles.
  14186. */
  14187. maxEmitPower: number;
  14188. /**
  14189. * Minimum life time of emitting particles.
  14190. */
  14191. minLifeTime: number;
  14192. /**
  14193. * Maximum life time of emitting particles.
  14194. */
  14195. maxLifeTime: number;
  14196. /**
  14197. * Minimum Size of emitting particles.
  14198. */
  14199. minSize: number;
  14200. /**
  14201. * Maximum Size of emitting particles.
  14202. */
  14203. maxSize: number;
  14204. /**
  14205. * Minimum scale of emitting particles on X axis.
  14206. */
  14207. minScaleX: number;
  14208. /**
  14209. * Maximum scale of emitting particles on X axis.
  14210. */
  14211. maxScaleX: number;
  14212. /**
  14213. * Minimum scale of emitting particles on Y axis.
  14214. */
  14215. minScaleY: number;
  14216. /**
  14217. * Maximum scale of emitting particles on Y axis.
  14218. */
  14219. maxScaleY: number;
  14220. /**
  14221. * Gets or sets the minimal initial rotation in radians.
  14222. */
  14223. minInitialRotation: number;
  14224. /**
  14225. * Gets or sets the maximal initial rotation in radians.
  14226. */
  14227. maxInitialRotation: number;
  14228. /**
  14229. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14230. */
  14231. minAngularSpeed: number;
  14232. /**
  14233. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14234. */
  14235. maxAngularSpeed: number;
  14236. /**
  14237. * The texture used to render each particle. (this can be a spritesheet)
  14238. */
  14239. particleTexture: Nullable<Texture>;
  14240. /**
  14241. * The layer mask we are rendering the particles through.
  14242. */
  14243. layerMask: number;
  14244. /**
  14245. * This can help using your own shader to render the particle system.
  14246. * The according effect will be created
  14247. */
  14248. customShader: any;
  14249. /**
  14250. * By default particle system starts as soon as they are created. This prevents the
  14251. * automatic start to happen and let you decide when to start emitting particles.
  14252. */
  14253. preventAutoStart: boolean;
  14254. private _noiseTexture;
  14255. /**
  14256. * Gets or sets a texture used to add random noise to particle positions
  14257. */
  14258. noiseTexture: Nullable<ProceduralTexture>;
  14259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14260. noiseStrength: Vector3;
  14261. /**
  14262. * Callback triggered when the particle animation is ending.
  14263. */
  14264. onAnimationEnd: Nullable<() => void>;
  14265. /**
  14266. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14267. */
  14268. blendMode: number;
  14269. /**
  14270. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14271. * to override the particles.
  14272. */
  14273. forceDepthWrite: boolean;
  14274. /** 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 */
  14275. preWarmCycles: number;
  14276. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14277. preWarmStepOffset: number;
  14278. /**
  14279. * 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)
  14280. */
  14281. spriteCellChangeSpeed: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14284. */
  14285. startSpriteCellID: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14288. */
  14289. endSpriteCellID: number;
  14290. /**
  14291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14292. */
  14293. spriteCellWidth: number;
  14294. /**
  14295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14296. */
  14297. spriteCellHeight: number;
  14298. /**
  14299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14300. */
  14301. spriteRandomStartCell: boolean;
  14302. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14303. translationPivot: Vector2;
  14304. /** @hidden */
  14305. protected _isAnimationSheetEnabled: boolean;
  14306. /**
  14307. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14308. */
  14309. beginAnimationOnStart: boolean;
  14310. /**
  14311. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14312. */
  14313. beginAnimationFrom: number;
  14314. /**
  14315. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14316. */
  14317. beginAnimationTo: number;
  14318. /**
  14319. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14320. */
  14321. beginAnimationLoop: boolean;
  14322. /**
  14323. * Gets or sets a world offset applied to all particles
  14324. */
  14325. worldOffset: Vector3;
  14326. /**
  14327. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14328. */
  14329. isAnimationSheetEnabled: boolean;
  14330. /**
  14331. * Get hosting scene
  14332. * @returns the scene
  14333. */
  14334. getScene(): Scene;
  14335. /**
  14336. * You can use gravity if you want to give an orientation to your particles.
  14337. */
  14338. gravity: Vector3;
  14339. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14340. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14341. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14342. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14343. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14344. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14345. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14346. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14347. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14348. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14349. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14350. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14351. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14352. /**
  14353. * Defines the delay in milliseconds before starting the system (0 by default)
  14354. */
  14355. startDelay: number;
  14356. /**
  14357. * Gets the current list of drag gradients.
  14358. * You must use addDragGradient and removeDragGradient to udpate this list
  14359. * @returns the list of drag gradients
  14360. */
  14361. getDragGradients(): Nullable<Array<FactorGradient>>;
  14362. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14363. limitVelocityDamping: number;
  14364. /**
  14365. * Gets the current list of limit velocity gradients.
  14366. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14367. * @returns the list of limit velocity gradients
  14368. */
  14369. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14370. /**
  14371. * Gets the current list of color gradients.
  14372. * You must use addColorGradient and removeColorGradient to udpate this list
  14373. * @returns the list of color gradients
  14374. */
  14375. getColorGradients(): Nullable<Array<ColorGradient>>;
  14376. /**
  14377. * Gets the current list of size gradients.
  14378. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14379. * @returns the list of size gradients
  14380. */
  14381. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of color remap gradients.
  14384. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14385. * @returns the list of color remap gradients
  14386. */
  14387. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Gets the current list of alpha remap gradients.
  14390. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14391. * @returns the list of alpha remap gradients
  14392. */
  14393. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14394. /**
  14395. * Gets the current list of life time gradients.
  14396. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14397. * @returns the list of life time gradients
  14398. */
  14399. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Gets the current list of angular speed gradients.
  14402. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14403. * @returns the list of angular speed gradients
  14404. */
  14405. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14406. /**
  14407. * Gets the current list of velocity gradients.
  14408. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14409. * @returns the list of velocity gradients
  14410. */
  14411. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14412. /**
  14413. * Gets the current list of start size gradients.
  14414. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14415. * @returns the list of start size gradients
  14416. */
  14417. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14418. /**
  14419. * Gets the current list of emit rate gradients.
  14420. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14421. * @returns the list of emit rate gradients
  14422. */
  14423. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14424. /**
  14425. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14426. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14427. */
  14428. direction1: Vector3;
  14429. /**
  14430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14432. */
  14433. direction2: Vector3;
  14434. /**
  14435. * 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.
  14436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14437. */
  14438. minEmitBox: Vector3;
  14439. /**
  14440. * 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.
  14441. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14442. */
  14443. maxEmitBox: Vector3;
  14444. /**
  14445. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14446. */
  14447. color1: Color4;
  14448. /**
  14449. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14450. */
  14451. color2: Color4;
  14452. /**
  14453. * Color the particle will have at the end of its lifetime
  14454. */
  14455. colorDead: Color4;
  14456. /**
  14457. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14458. */
  14459. textureMask: Color4;
  14460. /**
  14461. * The particle emitter type defines the emitter used by the particle system.
  14462. * It can be for example box, sphere, or cone...
  14463. */
  14464. particleEmitterType: IParticleEmitterType;
  14465. /** @hidden */ isSubEmitter: boolean;
  14466. /**
  14467. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14468. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14469. */
  14470. billboardMode: number;
  14471. protected _isBillboardBased: boolean;
  14472. /**
  14473. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14474. */
  14475. isBillboardBased: boolean;
  14476. /**
  14477. * The scene the particle system belongs to.
  14478. */
  14479. protected _scene: Scene;
  14480. /**
  14481. * Local cache of defines for image processing.
  14482. */
  14483. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14484. /**
  14485. * Default configuration related to image processing available in the standard Material.
  14486. */
  14487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14488. /**
  14489. * Gets the image processing configuration used either in this material.
  14490. */
  14491. /**
  14492. * Sets the Default image processing configuration used either in the this material.
  14493. *
  14494. * If sets to null, the scene one is in use.
  14495. */
  14496. imageProcessingConfiguration: ImageProcessingConfiguration;
  14497. /**
  14498. * Attaches a new image processing configuration to the Standard Material.
  14499. * @param configuration
  14500. */
  14501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14502. /** @hidden */
  14503. protected _reset(): void;
  14504. /** @hidden */
  14505. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14506. /**
  14507. * Instantiates a particle system.
  14508. * 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.
  14509. * @param name The name of the particle system
  14510. */
  14511. constructor(name: string);
  14512. /**
  14513. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14516. * @returns the emitter
  14517. */
  14518. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14519. /**
  14520. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14521. * @param radius The radius of the hemisphere to emit from
  14522. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14523. * @returns the emitter
  14524. */
  14525. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14526. /**
  14527. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14528. * @param radius The radius of the sphere to emit from
  14529. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14530. * @returns the emitter
  14531. */
  14532. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14533. /**
  14534. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14535. * @param radius The radius of the sphere to emit from
  14536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14538. * @returns the emitter
  14539. */
  14540. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14541. /**
  14542. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14543. * @param radius The radius of the emission cylinder
  14544. * @param height The height of the emission cylinder
  14545. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14546. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14547. * @returns the emitter
  14548. */
  14549. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14550. /**
  14551. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14552. * @param radius The radius of the cylinder to emit from
  14553. * @param height The height of the emission cylinder
  14554. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14557. * @returns the emitter
  14558. */
  14559. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14560. /**
  14561. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14562. * @param radius The radius of the cone to emit from
  14563. * @param angle The base angle of the cone
  14564. * @returns the emitter
  14565. */
  14566. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14567. /**
  14568. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14571. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14572. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14573. * @returns the emitter
  14574. */
  14575. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * Type of sub emitter
  14581. */
  14582. export enum SubEmitterType {
  14583. /**
  14584. * Attached to the particle over it's lifetime
  14585. */
  14586. ATTACHED = 0,
  14587. /**
  14588. * Created when the particle dies
  14589. */
  14590. END = 1
  14591. }
  14592. /**
  14593. * Sub emitter class used to emit particles from an existing particle
  14594. */
  14595. export class SubEmitter {
  14596. /**
  14597. * the particle system to be used by the sub emitter
  14598. */
  14599. particleSystem: ParticleSystem;
  14600. /**
  14601. * Type of the submitter (Default: END)
  14602. */
  14603. type: SubEmitterType;
  14604. /**
  14605. * 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)
  14606. * Note: This only is supported when using an emitter of type Mesh
  14607. */
  14608. inheritDirection: boolean;
  14609. /**
  14610. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14611. */
  14612. inheritedVelocityAmount: number;
  14613. /**
  14614. * Creates a sub emitter
  14615. * @param particleSystem the particle system to be used by the sub emitter
  14616. */
  14617. constructor(
  14618. /**
  14619. * the particle system to be used by the sub emitter
  14620. */
  14621. particleSystem: ParticleSystem);
  14622. /**
  14623. * Clones the sub emitter
  14624. * @returns the cloned sub emitter
  14625. */
  14626. clone(): SubEmitter;
  14627. /**
  14628. * Serialize current object to a JSON object
  14629. * @returns the serialized object
  14630. */
  14631. serialize(): any;
  14632. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14633. /**
  14634. * Creates a new SubEmitter from a serialized JSON version
  14635. * @param serializationObject defines the JSON object to read from
  14636. * @param scene defines the hosting scene
  14637. * @param rootUrl defines the rootUrl for data loading
  14638. * @returns a new SubEmitter
  14639. */
  14640. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14641. /** Release associated resources */
  14642. dispose(): void;
  14643. }
  14644. }
  14645. declare module BABYLON {
  14646. /** @hidden */
  14647. export var clipPlaneFragmentDeclaration: {
  14648. name: string;
  14649. shader: string;
  14650. };
  14651. }
  14652. declare module BABYLON {
  14653. /** @hidden */
  14654. export var imageProcessingDeclaration: {
  14655. name: string;
  14656. shader: string;
  14657. };
  14658. }
  14659. declare module BABYLON {
  14660. /** @hidden */
  14661. export var imageProcessingFunctions: {
  14662. name: string;
  14663. shader: string;
  14664. };
  14665. }
  14666. declare module BABYLON {
  14667. /** @hidden */
  14668. export var clipPlaneFragment: {
  14669. name: string;
  14670. shader: string;
  14671. };
  14672. }
  14673. declare module BABYLON {
  14674. /** @hidden */
  14675. export var particlesPixelShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module BABYLON {
  14681. /** @hidden */
  14682. export var clipPlaneVertexDeclaration: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module BABYLON {
  14688. /** @hidden */
  14689. export var clipPlaneVertex: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module BABYLON {
  14695. /** @hidden */
  14696. export var particlesVertexShader: {
  14697. name: string;
  14698. shader: string;
  14699. };
  14700. }
  14701. declare module BABYLON {
  14702. /**
  14703. * This represents a particle system in Babylon.
  14704. * 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.
  14705. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14706. * @example https://doc.babylonjs.com/babylon101/particles
  14707. */
  14708. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14709. /**
  14710. * Billboard mode will only apply to Y axis
  14711. */
  14712. static readonly BILLBOARDMODE_Y: number;
  14713. /**
  14714. * Billboard mode will apply to all axes
  14715. */
  14716. static readonly BILLBOARDMODE_ALL: number;
  14717. /**
  14718. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14719. */
  14720. static readonly BILLBOARDMODE_STRETCHED: number;
  14721. /**
  14722. * This function can be defined to provide custom update for active particles.
  14723. * This function will be called instead of regular update (age, position, color, etc.).
  14724. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14725. */
  14726. updateFunction: (particles: Particle[]) => void;
  14727. private _emitterWorldMatrix;
  14728. /**
  14729. * This function can be defined to specify initial direction for every new particle.
  14730. * It by default use the emitterType defined function
  14731. */
  14732. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14733. /**
  14734. * This function can be defined to specify initial position for every new particle.
  14735. * It by default use the emitterType defined function
  14736. */
  14737. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14738. /**
  14739. * @hidden
  14740. */ inheritedVelocityOffset: Vector3;
  14741. /**
  14742. * An event triggered when the system is disposed
  14743. */
  14744. onDisposeObservable: Observable<ParticleSystem>;
  14745. private _onDisposeObserver;
  14746. /**
  14747. * Sets a callback that will be triggered when the system is disposed
  14748. */
  14749. onDispose: () => void;
  14750. private _particles;
  14751. private _epsilon;
  14752. private _capacity;
  14753. private _stockParticles;
  14754. private _newPartsExcess;
  14755. private _vertexData;
  14756. private _vertexBuffer;
  14757. private _vertexBuffers;
  14758. private _spriteBuffer;
  14759. private _indexBuffer;
  14760. private _effect;
  14761. private _customEffect;
  14762. private _cachedDefines;
  14763. private _scaledColorStep;
  14764. private _colorDiff;
  14765. private _scaledDirection;
  14766. private _scaledGravity;
  14767. private _currentRenderId;
  14768. private _alive;
  14769. private _useInstancing;
  14770. private _started;
  14771. private _stopped;
  14772. private _actualFrame;
  14773. private _scaledUpdateSpeed;
  14774. private _vertexBufferSize;
  14775. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14776. /** @hidden */ currentEmitRate1: number;
  14777. /** @hidden */ currentEmitRate2: number;
  14778. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14779. /** @hidden */ currentStartSize1: number;
  14780. /** @hidden */ currentStartSize2: number;
  14781. private readonly _rawTextureWidth;
  14782. private _rampGradientsTexture;
  14783. private _useRampGradients;
  14784. /** Gets or sets a boolean indicating that ramp gradients must be used
  14785. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14786. */
  14787. useRampGradients: boolean;
  14788. /**
  14789. * 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.
  14790. * 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: [])
  14791. */
  14792. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14793. private _subEmitters;
  14794. /**
  14795. * @hidden
  14796. * If the particle systems emitter should be disposed when the particle system is disposed
  14797. */ disposeEmitterOnDispose: boolean;
  14798. /**
  14799. * The current active Sub-systems, this property is used by the root particle system only.
  14800. */
  14801. activeSubSystems: Array<ParticleSystem>;
  14802. private _rootParticleSystem;
  14803. /**
  14804. * Gets the current list of active particles
  14805. */
  14806. readonly particles: Particle[];
  14807. /**
  14808. * Returns the string "ParticleSystem"
  14809. * @returns a string containing the class name
  14810. */
  14811. getClassName(): string;
  14812. /**
  14813. * Instantiates a particle system.
  14814. * 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.
  14815. * @param name The name of the particle system
  14816. * @param capacity The max number of particles alive at the same time
  14817. * @param scene The scene the particle system belongs to
  14818. * @param customEffect a custom effect used to change the way particles are rendered by default
  14819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14820. * @param epsilon Offset used to render the particles
  14821. */
  14822. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14823. private _addFactorGradient;
  14824. private _removeFactorGradient;
  14825. /**
  14826. * Adds a new life time gradient
  14827. * @param gradient defines the gradient to use (between 0 and 1)
  14828. * @param factor defines the life time factor to affect to the specified gradient
  14829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14830. * @returns the current particle system
  14831. */
  14832. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14833. /**
  14834. * Remove a specific life time gradient
  14835. * @param gradient defines the gradient to remove
  14836. * @returns the current particle system
  14837. */
  14838. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14839. /**
  14840. * Adds a new size gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the size factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific size gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeSizeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Adds a new color remap gradient
  14855. * @param gradient defines the gradient to use (between 0 and 1)
  14856. * @param min defines the color remap minimal range
  14857. * @param max defines the color remap maximal range
  14858. * @returns the current particle system
  14859. */
  14860. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14861. /**
  14862. * Remove a specific color remap gradient
  14863. * @param gradient defines the gradient to remove
  14864. * @returns the current particle system
  14865. */
  14866. removeColorRemapGradient(gradient: number): IParticleSystem;
  14867. /**
  14868. * Adds a new alpha remap gradient
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param min defines the alpha remap minimal range
  14871. * @param max defines the alpha remap maximal range
  14872. * @returns the current particle system
  14873. */
  14874. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific alpha remap gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Adds a new angular speed gradient
  14883. * @param gradient defines the gradient to use (between 0 and 1)
  14884. * @param factor defines the angular speed to affect to the specified gradient
  14885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14886. * @returns the current particle system
  14887. */
  14888. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14889. /**
  14890. * Remove a specific angular speed gradient
  14891. * @param gradient defines the gradient to remove
  14892. * @returns the current particle system
  14893. */
  14894. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14895. /**
  14896. * Adds a new velocity gradient
  14897. * @param gradient defines the gradient to use (between 0 and 1)
  14898. * @param factor defines the velocity to affect to the specified gradient
  14899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14900. * @returns the current particle system
  14901. */
  14902. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14903. /**
  14904. * Remove a specific velocity gradient
  14905. * @param gradient defines the gradient to remove
  14906. * @returns the current particle system
  14907. */
  14908. removeVelocityGradient(gradient: number): IParticleSystem;
  14909. /**
  14910. * Adds a new limit velocity gradient
  14911. * @param gradient defines the gradient to use (between 0 and 1)
  14912. * @param factor defines the limit velocity value to affect to the specified gradient
  14913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14914. * @returns the current particle system
  14915. */
  14916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14917. /**
  14918. * Remove a specific limit velocity gradient
  14919. * @param gradient defines the gradient to remove
  14920. * @returns the current particle system
  14921. */
  14922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14923. /**
  14924. * Adds a new drag gradient
  14925. * @param gradient defines the gradient to use (between 0 and 1)
  14926. * @param factor defines the drag value to affect to the specified gradient
  14927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14928. * @returns the current particle system
  14929. */
  14930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14931. /**
  14932. * Remove a specific drag gradient
  14933. * @param gradient defines the gradient to remove
  14934. * @returns the current particle system
  14935. */
  14936. removeDragGradient(gradient: number): IParticleSystem;
  14937. /**
  14938. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14939. * @param gradient defines the gradient to use (between 0 and 1)
  14940. * @param factor defines the emit rate value to affect to the specified gradient
  14941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14942. * @returns the current particle system
  14943. */
  14944. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14945. /**
  14946. * Remove a specific emit rate gradient
  14947. * @param gradient defines the gradient to remove
  14948. * @returns the current particle system
  14949. */
  14950. removeEmitRateGradient(gradient: number): IParticleSystem;
  14951. /**
  14952. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14953. * @param gradient defines the gradient to use (between 0 and 1)
  14954. * @param factor defines the start size value to affect to the specified gradient
  14955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14956. * @returns the current particle system
  14957. */
  14958. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14959. /**
  14960. * Remove a specific start size gradient
  14961. * @param gradient defines the gradient to remove
  14962. * @returns the current particle system
  14963. */
  14964. removeStartSizeGradient(gradient: number): IParticleSystem;
  14965. private _createRampGradientTexture;
  14966. /**
  14967. * Gets the current list of ramp gradients.
  14968. * You must use addRampGradient and removeRampGradient to udpate this list
  14969. * @returns the list of ramp gradients
  14970. */
  14971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14972. /**
  14973. * Adds a new ramp gradient used to remap particle colors
  14974. * @param gradient defines the gradient to use (between 0 and 1)
  14975. * @param color defines the color to affect to the specified gradient
  14976. * @returns the current particle system
  14977. */
  14978. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14979. /**
  14980. * Remove a specific ramp gradient
  14981. * @param gradient defines the gradient to remove
  14982. * @returns the current particle system
  14983. */
  14984. removeRampGradient(gradient: number): ParticleSystem;
  14985. /**
  14986. * Adds a new color gradient
  14987. * @param gradient defines the gradient to use (between 0 and 1)
  14988. * @param color1 defines the color to affect to the specified gradient
  14989. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14990. * @returns this particle system
  14991. */
  14992. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14993. /**
  14994. * Remove a specific color gradient
  14995. * @param gradient defines the gradient to remove
  14996. * @returns this particle system
  14997. */
  14998. removeColorGradient(gradient: number): IParticleSystem;
  14999. private _fetchR;
  15000. protected _reset(): void;
  15001. private _resetEffect;
  15002. private _createVertexBuffers;
  15003. private _createIndexBuffer;
  15004. /**
  15005. * Gets the maximum number of particles active at the same time.
  15006. * @returns The max number of active particles.
  15007. */
  15008. getCapacity(): number;
  15009. /**
  15010. * Gets whether there are still active particles in the system.
  15011. * @returns True if it is alive, otherwise false.
  15012. */
  15013. isAlive(): boolean;
  15014. /**
  15015. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15016. * @returns True if it has been started, otherwise false.
  15017. */
  15018. isStarted(): boolean;
  15019. private _prepareSubEmitterInternalArray;
  15020. /**
  15021. * Starts the particle system and begins to emit
  15022. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15023. */
  15024. start(delay?: number): void;
  15025. /**
  15026. * Stops the particle system.
  15027. * @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.
  15028. */
  15029. stop(stopSubEmitters?: boolean): void;
  15030. /**
  15031. * Remove all active particles
  15032. */
  15033. reset(): void;
  15034. /**
  15035. * @hidden (for internal use only)
  15036. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15037. /**
  15038. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15039. * Its lifetime will start back at 0.
  15040. */
  15041. recycleParticle: (particle: Particle) => void;
  15042. private _stopSubEmitters;
  15043. private _createParticle;
  15044. private _removeFromRoot;
  15045. private _emitFromParticle;
  15046. private _update;
  15047. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15048. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15049. /** @hidden */
  15050. private _getEffect;
  15051. /**
  15052. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15053. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15054. */
  15055. animate(preWarmOnly?: boolean): void;
  15056. private _appendParticleVertices;
  15057. /**
  15058. * Rebuilds the particle system.
  15059. */
  15060. rebuild(): void;
  15061. /**
  15062. * Is this system ready to be used/rendered
  15063. * @return true if the system is ready
  15064. */
  15065. isReady(): boolean;
  15066. private _render;
  15067. /**
  15068. * Renders the particle system in its current state.
  15069. * @returns the current number of particles
  15070. */
  15071. render(): number;
  15072. /**
  15073. * Disposes the particle system and free the associated resources
  15074. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15075. */
  15076. dispose(disposeTexture?: boolean): void;
  15077. /**
  15078. * Clones the particle system.
  15079. * @param name The name of the cloned object
  15080. * @param newEmitter The new emitter to use
  15081. * @returns the cloned particle system
  15082. */
  15083. clone(name: string, newEmitter: any): ParticleSystem;
  15084. /**
  15085. * Serializes the particle system to a JSON object.
  15086. * @returns the JSON object
  15087. */
  15088. serialize(): any;
  15089. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15090. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15091. /**
  15092. * Parses a JSON object to create a particle system.
  15093. * @param parsedParticleSystem The JSON object to parse
  15094. * @param scene The scene to create the particle system in
  15095. * @param rootUrl The root url to use to load external dependencies like texture
  15096. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15097. * @returns the Parsed particle system
  15098. */
  15099. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15100. }
  15101. }
  15102. declare module BABYLON {
  15103. /**
  15104. * A particle represents one of the element emitted by a particle system.
  15105. * This is mainly define by its coordinates, direction, velocity and age.
  15106. */
  15107. export class Particle {
  15108. /**
  15109. * The particle system the particle belongs to.
  15110. */
  15111. particleSystem: ParticleSystem;
  15112. private static _Count;
  15113. /**
  15114. * Unique ID of the particle
  15115. */
  15116. id: number;
  15117. /**
  15118. * The world position of the particle in the scene.
  15119. */
  15120. position: Vector3;
  15121. /**
  15122. * The world direction of the particle in the scene.
  15123. */
  15124. direction: Vector3;
  15125. /**
  15126. * The color of the particle.
  15127. */
  15128. color: Color4;
  15129. /**
  15130. * The color change of the particle per step.
  15131. */
  15132. colorStep: Color4;
  15133. /**
  15134. * Defines how long will the life of the particle be.
  15135. */
  15136. lifeTime: number;
  15137. /**
  15138. * The current age of the particle.
  15139. */
  15140. age: number;
  15141. /**
  15142. * The current size of the particle.
  15143. */
  15144. size: number;
  15145. /**
  15146. * The current scale of the particle.
  15147. */
  15148. scale: Vector2;
  15149. /**
  15150. * The current angle of the particle.
  15151. */
  15152. angle: number;
  15153. /**
  15154. * Defines how fast is the angle changing.
  15155. */
  15156. angularSpeed: number;
  15157. /**
  15158. * Defines the cell index used by the particle to be rendered from a sprite.
  15159. */
  15160. cellIndex: number;
  15161. /**
  15162. * The information required to support color remapping
  15163. */
  15164. remapData: Vector4;
  15165. /** @hidden */ randomCellOffset?: number;
  15166. /** @hidden */ initialDirection: Nullable<Vector3>;
  15167. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15168. /** @hidden */ initialStartSpriteCellID: number;
  15169. /** @hidden */ initialEndSpriteCellID: number;
  15170. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15171. /** @hidden */ currentColor1: Color4;
  15172. /** @hidden */ currentColor2: Color4;
  15173. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15174. /** @hidden */ currentSize1: number;
  15175. /** @hidden */ currentSize2: number;
  15176. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15177. /** @hidden */ currentAngularSpeed1: number;
  15178. /** @hidden */ currentAngularSpeed2: number;
  15179. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15180. /** @hidden */ currentVelocity1: number;
  15181. /** @hidden */ currentVelocity2: number;
  15182. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15183. /** @hidden */ currentLimitVelocity1: number;
  15184. /** @hidden */ currentLimitVelocity2: number;
  15185. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15186. /** @hidden */ currentDrag1: number;
  15187. /** @hidden */ currentDrag2: number;
  15188. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15189. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15190. /**
  15191. * Creates a new instance Particle
  15192. * @param particleSystem the particle system the particle belongs to
  15193. */
  15194. constructor(
  15195. /**
  15196. * The particle system the particle belongs to.
  15197. */
  15198. particleSystem: ParticleSystem);
  15199. private updateCellInfoFromSystem;
  15200. /**
  15201. * Defines how the sprite cell index is updated for the particle
  15202. */
  15203. updateCellIndex(): void;
  15204. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15205. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15206. /** @hidden */ reset(): void;
  15207. /**
  15208. * Copy the properties of particle to another one.
  15209. * @param other the particle to copy the information to.
  15210. */
  15211. copyTo(other: Particle): void;
  15212. }
  15213. }
  15214. declare module BABYLON {
  15215. /**
  15216. * Particle emitter represents a volume emitting particles.
  15217. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15218. */
  15219. export interface IParticleEmitterType {
  15220. /**
  15221. * Called by the particle System when the direction is computed for the created particle.
  15222. * @param worldMatrix is the world matrix of the particle system
  15223. * @param directionToUpdate is the direction vector to update with the result
  15224. * @param particle is the particle we are computed the direction for
  15225. */
  15226. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15227. /**
  15228. * Called by the particle System when the position is computed for the created particle.
  15229. * @param worldMatrix is the world matrix of the particle system
  15230. * @param positionToUpdate is the position vector to update with the result
  15231. * @param particle is the particle we are computed the position for
  15232. */
  15233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15234. /**
  15235. * Clones the current emitter and returns a copy of it
  15236. * @returns the new emitter
  15237. */
  15238. clone(): IParticleEmitterType;
  15239. /**
  15240. * Called by the GPUParticleSystem to setup the update shader
  15241. * @param effect defines the update shader
  15242. */
  15243. applyToShader(effect: Effect): void;
  15244. /**
  15245. * Returns a string to use to update the GPU particles update shader
  15246. * @returns the effect defines string
  15247. */
  15248. getEffectDefines(): string;
  15249. /**
  15250. * Returns a string representing the class name
  15251. * @returns a string containing the class name
  15252. */
  15253. getClassName(): string;
  15254. /**
  15255. * Serializes the particle system to a JSON object.
  15256. * @returns the JSON object
  15257. */
  15258. serialize(): any;
  15259. /**
  15260. * Parse properties from a JSON object
  15261. * @param serializationObject defines the JSON object
  15262. */
  15263. parse(serializationObject: any): void;
  15264. }
  15265. }
  15266. declare module BABYLON {
  15267. /**
  15268. * Particle emitter emitting particles from the inside of a box.
  15269. * It emits the particles randomly between 2 given directions.
  15270. */
  15271. export class BoxParticleEmitter implements IParticleEmitterType {
  15272. /**
  15273. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15274. */
  15275. direction1: Vector3;
  15276. /**
  15277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15278. */
  15279. direction2: Vector3;
  15280. /**
  15281. * 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.
  15282. */
  15283. minEmitBox: Vector3;
  15284. /**
  15285. * 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.
  15286. */
  15287. maxEmitBox: Vector3;
  15288. /**
  15289. * Creates a new instance BoxParticleEmitter
  15290. */
  15291. constructor();
  15292. /**
  15293. * Called by the particle System when the direction is computed for the created particle.
  15294. * @param worldMatrix is the world matrix of the particle system
  15295. * @param directionToUpdate is the direction vector to update with the result
  15296. * @param particle is the particle we are computed the direction for
  15297. */
  15298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15299. /**
  15300. * Called by the particle System when the position is computed for the created particle.
  15301. * @param worldMatrix is the world matrix of the particle system
  15302. * @param positionToUpdate is the position vector to update with the result
  15303. * @param particle is the particle we are computed the position for
  15304. */
  15305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15306. /**
  15307. * Clones the current emitter and returns a copy of it
  15308. * @returns the new emitter
  15309. */
  15310. clone(): BoxParticleEmitter;
  15311. /**
  15312. * Called by the GPUParticleSystem to setup the update shader
  15313. * @param effect defines the update shader
  15314. */
  15315. applyToShader(effect: Effect): void;
  15316. /**
  15317. * Returns a string to use to update the GPU particles update shader
  15318. * @returns a string containng the defines string
  15319. */
  15320. getEffectDefines(): string;
  15321. /**
  15322. * Returns the string "BoxParticleEmitter"
  15323. * @returns a string containing the class name
  15324. */
  15325. getClassName(): string;
  15326. /**
  15327. * Serializes the particle system to a JSON object.
  15328. * @returns the JSON object
  15329. */
  15330. serialize(): any;
  15331. /**
  15332. * Parse properties from a JSON object
  15333. * @param serializationObject defines the JSON object
  15334. */
  15335. parse(serializationObject: any): void;
  15336. }
  15337. }
  15338. declare module BABYLON {
  15339. /**
  15340. * Particle emitter emitting particles from the inside of a cone.
  15341. * It emits the particles alongside the cone volume from the base to the particle.
  15342. * The emission direction might be randomized.
  15343. */
  15344. export class ConeParticleEmitter implements IParticleEmitterType {
  15345. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15346. directionRandomizer: number;
  15347. private _radius;
  15348. private _angle;
  15349. private _height;
  15350. /**
  15351. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15352. */
  15353. radiusRange: number;
  15354. /**
  15355. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15356. */
  15357. heightRange: number;
  15358. /**
  15359. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15360. */
  15361. emitFromSpawnPointOnly: boolean;
  15362. /**
  15363. * Gets or sets the radius of the emission cone
  15364. */
  15365. radius: number;
  15366. /**
  15367. * Gets or sets the angle of the emission cone
  15368. */
  15369. angle: number;
  15370. private _buildHeight;
  15371. /**
  15372. * Creates a new instance ConeParticleEmitter
  15373. * @param radius the radius of the emission cone (1 by default)
  15374. * @param angle the cone base angle (PI by default)
  15375. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15376. */
  15377. constructor(radius?: number, angle?: number,
  15378. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15379. directionRandomizer?: number);
  15380. /**
  15381. * Called by the particle System when the direction is computed for the created particle.
  15382. * @param worldMatrix is the world matrix of the particle system
  15383. * @param directionToUpdate is the direction vector to update with the result
  15384. * @param particle is the particle we are computed the direction for
  15385. */
  15386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15387. /**
  15388. * Called by the particle System when the position is computed for the created particle.
  15389. * @param worldMatrix is the world matrix of the particle system
  15390. * @param positionToUpdate is the position vector to update with the result
  15391. * @param particle is the particle we are computed the position for
  15392. */
  15393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15394. /**
  15395. * Clones the current emitter and returns a copy of it
  15396. * @returns the new emitter
  15397. */
  15398. clone(): ConeParticleEmitter;
  15399. /**
  15400. * Called by the GPUParticleSystem to setup the update shader
  15401. * @param effect defines the update shader
  15402. */
  15403. applyToShader(effect: Effect): void;
  15404. /**
  15405. * Returns a string to use to update the GPU particles update shader
  15406. * @returns a string containng the defines string
  15407. */
  15408. getEffectDefines(): string;
  15409. /**
  15410. * Returns the string "ConeParticleEmitter"
  15411. * @returns a string containing the class name
  15412. */
  15413. getClassName(): string;
  15414. /**
  15415. * Serializes the particle system to a JSON object.
  15416. * @returns the JSON object
  15417. */
  15418. serialize(): any;
  15419. /**
  15420. * Parse properties from a JSON object
  15421. * @param serializationObject defines the JSON object
  15422. */
  15423. parse(serializationObject: any): void;
  15424. }
  15425. }
  15426. declare module BABYLON {
  15427. /**
  15428. * Particle emitter emitting particles from the inside of a cylinder.
  15429. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15430. */
  15431. export class CylinderParticleEmitter implements IParticleEmitterType {
  15432. /**
  15433. * The radius of the emission cylinder.
  15434. */
  15435. radius: number;
  15436. /**
  15437. * The height of the emission cylinder.
  15438. */
  15439. height: number;
  15440. /**
  15441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15442. */
  15443. radiusRange: number;
  15444. /**
  15445. * How much to randomize the particle direction [0-1].
  15446. */
  15447. directionRandomizer: number;
  15448. /**
  15449. * Creates a new instance CylinderParticleEmitter
  15450. * @param radius the radius of the emission cylinder (1 by default)
  15451. * @param height the height of the emission cylinder (1 by default)
  15452. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15453. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15454. */
  15455. constructor(
  15456. /**
  15457. * The radius of the emission cylinder.
  15458. */
  15459. radius?: number,
  15460. /**
  15461. * The height of the emission cylinder.
  15462. */
  15463. height?: number,
  15464. /**
  15465. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15466. */
  15467. radiusRange?: number,
  15468. /**
  15469. * How much to randomize the particle direction [0-1].
  15470. */
  15471. directionRandomizer?: number);
  15472. /**
  15473. * Called by the particle System when the direction is computed for the created particle.
  15474. * @param worldMatrix is the world matrix of the particle system
  15475. * @param directionToUpdate is the direction vector to update with the result
  15476. * @param particle is the particle we are computed the direction for
  15477. */
  15478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15479. /**
  15480. * Called by the particle System when the position is computed for the created particle.
  15481. * @param worldMatrix is the world matrix of the particle system
  15482. * @param positionToUpdate is the position vector to update with the result
  15483. * @param particle is the particle we are computed the position for
  15484. */
  15485. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15486. /**
  15487. * Clones the current emitter and returns a copy of it
  15488. * @returns the new emitter
  15489. */
  15490. clone(): CylinderParticleEmitter;
  15491. /**
  15492. * Called by the GPUParticleSystem to setup the update shader
  15493. * @param effect defines the update shader
  15494. */
  15495. applyToShader(effect: Effect): void;
  15496. /**
  15497. * Returns a string to use to update the GPU particles update shader
  15498. * @returns a string containng the defines string
  15499. */
  15500. getEffectDefines(): string;
  15501. /**
  15502. * Returns the string "CylinderParticleEmitter"
  15503. * @returns a string containing the class name
  15504. */
  15505. getClassName(): string;
  15506. /**
  15507. * Serializes the particle system to a JSON object.
  15508. * @returns the JSON object
  15509. */
  15510. serialize(): any;
  15511. /**
  15512. * Parse properties from a JSON object
  15513. * @param serializationObject defines the JSON object
  15514. */
  15515. parse(serializationObject: any): void;
  15516. }
  15517. /**
  15518. * Particle emitter emitting particles from the inside of a cylinder.
  15519. * It emits the particles randomly between two vectors.
  15520. */
  15521. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15522. /**
  15523. * The min limit of the emission direction.
  15524. */
  15525. direction1: Vector3;
  15526. /**
  15527. * The max limit of the emission direction.
  15528. */
  15529. direction2: Vector3;
  15530. /**
  15531. * Creates a new instance CylinderDirectedParticleEmitter
  15532. * @param radius the radius of the emission cylinder (1 by default)
  15533. * @param height the height of the emission cylinder (1 by default)
  15534. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15535. * @param direction1 the min limit of the emission direction (up vector by default)
  15536. * @param direction2 the max limit of the emission direction (up vector by default)
  15537. */
  15538. constructor(radius?: number, height?: number, radiusRange?: number,
  15539. /**
  15540. * The min limit of the emission direction.
  15541. */
  15542. direction1?: Vector3,
  15543. /**
  15544. * The max limit of the emission direction.
  15545. */
  15546. direction2?: Vector3);
  15547. /**
  15548. * Called by the particle System when the direction is computed for the created particle.
  15549. * @param worldMatrix is the world matrix of the particle system
  15550. * @param directionToUpdate is the direction vector to update with the result
  15551. * @param particle is the particle we are computed the direction for
  15552. */
  15553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15554. /**
  15555. * Clones the current emitter and returns a copy of it
  15556. * @returns the new emitter
  15557. */
  15558. clone(): CylinderDirectedParticleEmitter;
  15559. /**
  15560. * Called by the GPUParticleSystem to setup the update shader
  15561. * @param effect defines the update shader
  15562. */
  15563. applyToShader(effect: Effect): void;
  15564. /**
  15565. * Returns a string to use to update the GPU particles update shader
  15566. * @returns a string containng the defines string
  15567. */
  15568. getEffectDefines(): string;
  15569. /**
  15570. * Returns the string "CylinderDirectedParticleEmitter"
  15571. * @returns a string containing the class name
  15572. */
  15573. getClassName(): string;
  15574. /**
  15575. * Serializes the particle system to a JSON object.
  15576. * @returns the JSON object
  15577. */
  15578. serialize(): any;
  15579. /**
  15580. * Parse properties from a JSON object
  15581. * @param serializationObject defines the JSON object
  15582. */
  15583. parse(serializationObject: any): void;
  15584. }
  15585. }
  15586. declare module BABYLON {
  15587. /**
  15588. * Particle emitter emitting particles from the inside of a hemisphere.
  15589. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15590. */
  15591. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15592. /**
  15593. * The radius of the emission hemisphere.
  15594. */
  15595. radius: number;
  15596. /**
  15597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15598. */
  15599. radiusRange: number;
  15600. /**
  15601. * How much to randomize the particle direction [0-1].
  15602. */
  15603. directionRandomizer: number;
  15604. /**
  15605. * Creates a new instance HemisphericParticleEmitter
  15606. * @param radius the radius of the emission hemisphere (1 by default)
  15607. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15608. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15609. */
  15610. constructor(
  15611. /**
  15612. * The radius of the emission hemisphere.
  15613. */
  15614. radius?: number,
  15615. /**
  15616. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15617. */
  15618. radiusRange?: number,
  15619. /**
  15620. * How much to randomize the particle direction [0-1].
  15621. */
  15622. directionRandomizer?: number);
  15623. /**
  15624. * Called by the particle System when the direction is computed for the created particle.
  15625. * @param worldMatrix is the world matrix of the particle system
  15626. * @param directionToUpdate is the direction vector to update with the result
  15627. * @param particle is the particle we are computed the direction for
  15628. */
  15629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15630. /**
  15631. * Called by the particle System when the position is computed for the created particle.
  15632. * @param worldMatrix is the world matrix of the particle system
  15633. * @param positionToUpdate is the position vector to update with the result
  15634. * @param particle is the particle we are computed the position for
  15635. */
  15636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15637. /**
  15638. * Clones the current emitter and returns a copy of it
  15639. * @returns the new emitter
  15640. */
  15641. clone(): HemisphericParticleEmitter;
  15642. /**
  15643. * Called by the GPUParticleSystem to setup the update shader
  15644. * @param effect defines the update shader
  15645. */
  15646. applyToShader(effect: Effect): void;
  15647. /**
  15648. * Returns a string to use to update the GPU particles update shader
  15649. * @returns a string containng the defines string
  15650. */
  15651. getEffectDefines(): string;
  15652. /**
  15653. * Returns the string "HemisphericParticleEmitter"
  15654. * @returns a string containing the class name
  15655. */
  15656. getClassName(): string;
  15657. /**
  15658. * Serializes the particle system to a JSON object.
  15659. * @returns the JSON object
  15660. */
  15661. serialize(): any;
  15662. /**
  15663. * Parse properties from a JSON object
  15664. * @param serializationObject defines the JSON object
  15665. */
  15666. parse(serializationObject: any): void;
  15667. }
  15668. }
  15669. declare module BABYLON {
  15670. /**
  15671. * Particle emitter emitting particles from a point.
  15672. * It emits the particles randomly between 2 given directions.
  15673. */
  15674. export class PointParticleEmitter implements IParticleEmitterType {
  15675. /**
  15676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15677. */
  15678. direction1: Vector3;
  15679. /**
  15680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15681. */
  15682. direction2: Vector3;
  15683. /**
  15684. * Creates a new instance PointParticleEmitter
  15685. */
  15686. constructor();
  15687. /**
  15688. * Called by the particle System when the direction is computed for the created particle.
  15689. * @param worldMatrix is the world matrix of the particle system
  15690. * @param directionToUpdate is the direction vector to update with the result
  15691. * @param particle is the particle we are computed the direction for
  15692. */
  15693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15694. /**
  15695. * Called by the particle System when the position is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param positionToUpdate is the position vector to update with the result
  15698. * @param particle is the particle we are computed the position for
  15699. */
  15700. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): PointParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "PointParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module BABYLON {
  15734. /**
  15735. * Particle emitter emitting particles from the inside of a sphere.
  15736. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15737. */
  15738. export class SphereParticleEmitter implements IParticleEmitterType {
  15739. /**
  15740. * The radius of the emission sphere.
  15741. */
  15742. radius: number;
  15743. /**
  15744. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15745. */
  15746. radiusRange: number;
  15747. /**
  15748. * How much to randomize the particle direction [0-1].
  15749. */
  15750. directionRandomizer: number;
  15751. /**
  15752. * Creates a new instance SphereParticleEmitter
  15753. * @param radius the radius of the emission sphere (1 by default)
  15754. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15755. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15756. */
  15757. constructor(
  15758. /**
  15759. * The radius of the emission sphere.
  15760. */
  15761. radius?: number,
  15762. /**
  15763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15764. */
  15765. radiusRange?: number,
  15766. /**
  15767. * How much to randomize the particle direction [0-1].
  15768. */
  15769. directionRandomizer?: number);
  15770. /**
  15771. * Called by the particle System when the direction is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param directionToUpdate is the direction vector to update with the result
  15774. * @param particle is the particle we are computed the direction for
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. */
  15783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15784. /**
  15785. * Clones the current emitter and returns a copy of it
  15786. * @returns the new emitter
  15787. */
  15788. clone(): SphereParticleEmitter;
  15789. /**
  15790. * Called by the GPUParticleSystem to setup the update shader
  15791. * @param effect defines the update shader
  15792. */
  15793. applyToShader(effect: Effect): void;
  15794. /**
  15795. * Returns a string to use to update the GPU particles update shader
  15796. * @returns a string containng the defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns the string "SphereParticleEmitter"
  15801. * @returns a string containing the class name
  15802. */
  15803. getClassName(): string;
  15804. /**
  15805. * Serializes the particle system to a JSON object.
  15806. * @returns the JSON object
  15807. */
  15808. serialize(): any;
  15809. /**
  15810. * Parse properties from a JSON object
  15811. * @param serializationObject defines the JSON object
  15812. */
  15813. parse(serializationObject: any): void;
  15814. }
  15815. /**
  15816. * Particle emitter emitting particles from the inside of a sphere.
  15817. * It emits the particles randomly between two vectors.
  15818. */
  15819. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15820. /**
  15821. * The min limit of the emission direction.
  15822. */
  15823. direction1: Vector3;
  15824. /**
  15825. * The max limit of the emission direction.
  15826. */
  15827. direction2: Vector3;
  15828. /**
  15829. * Creates a new instance SphereDirectedParticleEmitter
  15830. * @param radius the radius of the emission sphere (1 by default)
  15831. * @param direction1 the min limit of the emission direction (up vector by default)
  15832. * @param direction2 the max limit of the emission direction (up vector by default)
  15833. */
  15834. constructor(radius?: number,
  15835. /**
  15836. * The min limit of the emission direction.
  15837. */
  15838. direction1?: Vector3,
  15839. /**
  15840. * The max limit of the emission direction.
  15841. */
  15842. direction2?: Vector3);
  15843. /**
  15844. * Called by the particle System when the direction is computed for the created particle.
  15845. * @param worldMatrix is the world matrix of the particle system
  15846. * @param directionToUpdate is the direction vector to update with the result
  15847. * @param particle is the particle we are computed the direction for
  15848. */
  15849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15850. /**
  15851. * Clones the current emitter and returns a copy of it
  15852. * @returns the new emitter
  15853. */
  15854. clone(): SphereDirectedParticleEmitter;
  15855. /**
  15856. * Called by the GPUParticleSystem to setup the update shader
  15857. * @param effect defines the update shader
  15858. */
  15859. applyToShader(effect: Effect): void;
  15860. /**
  15861. * Returns a string to use to update the GPU particles update shader
  15862. * @returns a string containng the defines string
  15863. */
  15864. getEffectDefines(): string;
  15865. /**
  15866. * Returns the string "SphereDirectedParticleEmitter"
  15867. * @returns a string containing the class name
  15868. */
  15869. getClassName(): string;
  15870. /**
  15871. * Serializes the particle system to a JSON object.
  15872. * @returns the JSON object
  15873. */
  15874. serialize(): any;
  15875. /**
  15876. * Parse properties from a JSON object
  15877. * @param serializationObject defines the JSON object
  15878. */
  15879. parse(serializationObject: any): void;
  15880. }
  15881. }
  15882. declare module BABYLON {
  15883. /**
  15884. * Interface representing a particle system in Babylon.js.
  15885. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15886. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15887. */
  15888. export interface IParticleSystem {
  15889. /**
  15890. * List of animations used by the particle system.
  15891. */
  15892. animations: Animation[];
  15893. /**
  15894. * The id of the Particle system.
  15895. */
  15896. id: string;
  15897. /**
  15898. * The name of the Particle system.
  15899. */
  15900. name: string;
  15901. /**
  15902. * The emitter represents the Mesh or position we are attaching the particle system to.
  15903. */
  15904. emitter: Nullable<AbstractMesh | Vector3>;
  15905. /**
  15906. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15907. */
  15908. isBillboardBased: boolean;
  15909. /**
  15910. * The rendering group used by the Particle system to chose when to render.
  15911. */
  15912. renderingGroupId: number;
  15913. /**
  15914. * The layer mask we are rendering the particles through.
  15915. */
  15916. layerMask: number;
  15917. /**
  15918. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15919. */
  15920. updateSpeed: number;
  15921. /**
  15922. * The amount of time the particle system is running (depends of the overall update speed).
  15923. */
  15924. targetStopDuration: number;
  15925. /**
  15926. * The texture used to render each particle. (this can be a spritesheet)
  15927. */
  15928. particleTexture: Nullable<Texture>;
  15929. /**
  15930. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15931. */
  15932. blendMode: number;
  15933. /**
  15934. * Minimum life time of emitting particles.
  15935. */
  15936. minLifeTime: number;
  15937. /**
  15938. * Maximum life time of emitting particles.
  15939. */
  15940. maxLifeTime: number;
  15941. /**
  15942. * Minimum Size of emitting particles.
  15943. */
  15944. minSize: number;
  15945. /**
  15946. * Maximum Size of emitting particles.
  15947. */
  15948. maxSize: number;
  15949. /**
  15950. * Minimum scale of emitting particles on X axis.
  15951. */
  15952. minScaleX: number;
  15953. /**
  15954. * Maximum scale of emitting particles on X axis.
  15955. */
  15956. maxScaleX: number;
  15957. /**
  15958. * Minimum scale of emitting particles on Y axis.
  15959. */
  15960. minScaleY: number;
  15961. /**
  15962. * Maximum scale of emitting particles on Y axis.
  15963. */
  15964. maxScaleY: number;
  15965. /**
  15966. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15967. */
  15968. color1: Color4;
  15969. /**
  15970. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15971. */
  15972. color2: Color4;
  15973. /**
  15974. * Color the particle will have at the end of its lifetime.
  15975. */
  15976. colorDead: Color4;
  15977. /**
  15978. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15979. */
  15980. emitRate: number;
  15981. /**
  15982. * You can use gravity if you want to give an orientation to your particles.
  15983. */
  15984. gravity: Vector3;
  15985. /**
  15986. * Minimum power of emitting particles.
  15987. */
  15988. minEmitPower: number;
  15989. /**
  15990. * Maximum power of emitting particles.
  15991. */
  15992. maxEmitPower: number;
  15993. /**
  15994. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15995. */
  15996. minAngularSpeed: number;
  15997. /**
  15998. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15999. */
  16000. maxAngularSpeed: number;
  16001. /**
  16002. * Gets or sets the minimal initial rotation in radians.
  16003. */
  16004. minInitialRotation: number;
  16005. /**
  16006. * Gets or sets the maximal initial rotation in radians.
  16007. */
  16008. maxInitialRotation: number;
  16009. /**
  16010. * The particle emitter type defines the emitter used by the particle system.
  16011. * It can be for example box, sphere, or cone...
  16012. */
  16013. particleEmitterType: Nullable<IParticleEmitterType>;
  16014. /**
  16015. * Defines the delay in milliseconds before starting the system (0 by default)
  16016. */
  16017. startDelay: number;
  16018. /**
  16019. * 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
  16020. */
  16021. preWarmCycles: number;
  16022. /**
  16023. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16024. */
  16025. preWarmStepOffset: number;
  16026. /**
  16027. * 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)
  16028. */
  16029. spriteCellChangeSpeed: number;
  16030. /**
  16031. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16032. */
  16033. startSpriteCellID: number;
  16034. /**
  16035. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16036. */
  16037. endSpriteCellID: number;
  16038. /**
  16039. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16040. */
  16041. spriteCellWidth: number;
  16042. /**
  16043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16044. */
  16045. spriteCellHeight: number;
  16046. /**
  16047. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16048. */
  16049. spriteRandomStartCell: boolean;
  16050. /**
  16051. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16052. */
  16053. isAnimationSheetEnabled: boolean;
  16054. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16055. translationPivot: Vector2;
  16056. /**
  16057. * Gets or sets a texture used to add random noise to particle positions
  16058. */
  16059. noiseTexture: Nullable<BaseTexture>;
  16060. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16061. noiseStrength: Vector3;
  16062. /**
  16063. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16064. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16065. */
  16066. billboardMode: number;
  16067. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16068. limitVelocityDamping: number;
  16069. /**
  16070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16071. */
  16072. beginAnimationOnStart: boolean;
  16073. /**
  16074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16075. */
  16076. beginAnimationFrom: number;
  16077. /**
  16078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16079. */
  16080. beginAnimationTo: number;
  16081. /**
  16082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16083. */
  16084. beginAnimationLoop: boolean;
  16085. /**
  16086. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16087. */
  16088. disposeOnStop: boolean;
  16089. /**
  16090. * Gets the maximum number of particles active at the same time.
  16091. * @returns The max number of active particles.
  16092. */
  16093. getCapacity(): number;
  16094. /**
  16095. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16096. * @returns True if it has been started, otherwise false.
  16097. */
  16098. isStarted(): boolean;
  16099. /**
  16100. * Animates the particle system for this frame.
  16101. */
  16102. animate(): void;
  16103. /**
  16104. * Renders the particle system in its current state.
  16105. * @returns the current number of particles
  16106. */
  16107. render(): number;
  16108. /**
  16109. * Dispose the particle system and frees its associated resources.
  16110. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16111. */
  16112. dispose(disposeTexture?: boolean): void;
  16113. /**
  16114. * Clones the particle system.
  16115. * @param name The name of the cloned object
  16116. * @param newEmitter The new emitter to use
  16117. * @returns the cloned particle system
  16118. */
  16119. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16120. /**
  16121. * Serializes the particle system to a JSON object.
  16122. * @returns the JSON object
  16123. */
  16124. serialize(): any;
  16125. /**
  16126. * Rebuild the particle system
  16127. */
  16128. rebuild(): void;
  16129. /**
  16130. * Starts the particle system and begins to emit
  16131. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16132. */
  16133. start(delay?: number): void;
  16134. /**
  16135. * Stops the particle system.
  16136. */
  16137. stop(): void;
  16138. /**
  16139. * Remove all active particles
  16140. */
  16141. reset(): void;
  16142. /**
  16143. * Is this system ready to be used/rendered
  16144. * @return true if the system is ready
  16145. */
  16146. isReady(): boolean;
  16147. /**
  16148. * Adds a new color gradient
  16149. * @param gradient defines the gradient to use (between 0 and 1)
  16150. * @param color1 defines the color to affect to the specified gradient
  16151. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16152. * @returns the current particle system
  16153. */
  16154. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16155. /**
  16156. * Remove a specific color gradient
  16157. * @param gradient defines the gradient to remove
  16158. * @returns the current particle system
  16159. */
  16160. removeColorGradient(gradient: number): IParticleSystem;
  16161. /**
  16162. * Adds a new size gradient
  16163. * @param gradient defines the gradient to use (between 0 and 1)
  16164. * @param factor defines the size factor to affect to the specified gradient
  16165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16166. * @returns the current particle system
  16167. */
  16168. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16169. /**
  16170. * Remove a specific size gradient
  16171. * @param gradient defines the gradient to remove
  16172. * @returns the current particle system
  16173. */
  16174. removeSizeGradient(gradient: number): IParticleSystem;
  16175. /**
  16176. * Gets the current list of color gradients.
  16177. * You must use addColorGradient and removeColorGradient to udpate this list
  16178. * @returns the list of color gradients
  16179. */
  16180. getColorGradients(): Nullable<Array<ColorGradient>>;
  16181. /**
  16182. * Gets the current list of size gradients.
  16183. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16184. * @returns the list of size gradients
  16185. */
  16186. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16187. /**
  16188. * Gets the current list of angular speed gradients.
  16189. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16190. * @returns the list of angular speed gradients
  16191. */
  16192. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16193. /**
  16194. * Adds a new angular speed gradient
  16195. * @param gradient defines the gradient to use (between 0 and 1)
  16196. * @param factor defines the angular speed to affect to the specified gradient
  16197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16198. * @returns the current particle system
  16199. */
  16200. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16201. /**
  16202. * Remove a specific angular speed gradient
  16203. * @param gradient defines the gradient to remove
  16204. * @returns the current particle system
  16205. */
  16206. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16207. /**
  16208. * Gets the current list of velocity gradients.
  16209. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16210. * @returns the list of velocity gradients
  16211. */
  16212. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16213. /**
  16214. * Adds a new velocity gradient
  16215. * @param gradient defines the gradient to use (between 0 and 1)
  16216. * @param factor defines the velocity to affect to the specified gradient
  16217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16218. * @returns the current particle system
  16219. */
  16220. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16221. /**
  16222. * Remove a specific velocity gradient
  16223. * @param gradient defines the gradient to remove
  16224. * @returns the current particle system
  16225. */
  16226. removeVelocityGradient(gradient: number): IParticleSystem;
  16227. /**
  16228. * Gets the current list of limit velocity gradients.
  16229. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16230. * @returns the list of limit velocity gradients
  16231. */
  16232. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16233. /**
  16234. * Adds a new limit velocity gradient
  16235. * @param gradient defines the gradient to use (between 0 and 1)
  16236. * @param factor defines the limit velocity to affect to the specified gradient
  16237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16238. * @returns the current particle system
  16239. */
  16240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16241. /**
  16242. * Remove a specific limit velocity gradient
  16243. * @param gradient defines the gradient to remove
  16244. * @returns the current particle system
  16245. */
  16246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16247. /**
  16248. * Adds a new drag gradient
  16249. * @param gradient defines the gradient to use (between 0 and 1)
  16250. * @param factor defines the drag to affect to the specified gradient
  16251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16252. * @returns the current particle system
  16253. */
  16254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16255. /**
  16256. * Remove a specific drag gradient
  16257. * @param gradient defines the gradient to remove
  16258. * @returns the current particle system
  16259. */
  16260. removeDragGradient(gradient: number): IParticleSystem;
  16261. /**
  16262. * Gets the current list of drag gradients.
  16263. * You must use addDragGradient and removeDragGradient to udpate this list
  16264. * @returns the list of drag gradients
  16265. */
  16266. getDragGradients(): Nullable<Array<FactorGradient>>;
  16267. /**
  16268. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the emit rate to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific emit rate gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeEmitRateGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Gets the current list of emit rate gradients.
  16283. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16284. * @returns the list of emit rate gradients
  16285. */
  16286. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16287. /**
  16288. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16289. * @param gradient defines the gradient to use (between 0 and 1)
  16290. * @param factor defines the start size to affect to the specified gradient
  16291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16292. * @returns the current particle system
  16293. */
  16294. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16295. /**
  16296. * Remove a specific start size gradient
  16297. * @param gradient defines the gradient to remove
  16298. * @returns the current particle system
  16299. */
  16300. removeStartSizeGradient(gradient: number): IParticleSystem;
  16301. /**
  16302. * Gets the current list of start size gradients.
  16303. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16304. * @returns the list of start size gradients
  16305. */
  16306. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16307. /**
  16308. * Adds a new life time gradient
  16309. * @param gradient defines the gradient to use (between 0 and 1)
  16310. * @param factor defines the life time factor to affect to the specified gradient
  16311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16312. * @returns the current particle system
  16313. */
  16314. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16315. /**
  16316. * Remove a specific life time gradient
  16317. * @param gradient defines the gradient to remove
  16318. * @returns the current particle system
  16319. */
  16320. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16321. /**
  16322. * Gets the current list of life time gradients.
  16323. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16324. * @returns the list of life time gradients
  16325. */
  16326. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16327. /**
  16328. * Gets the current list of color gradients.
  16329. * You must use addColorGradient and removeColorGradient to udpate this list
  16330. * @returns the list of color gradients
  16331. */
  16332. getColorGradients(): Nullable<Array<ColorGradient>>;
  16333. /**
  16334. * Adds a new ramp gradient used to remap particle colors
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param color defines the color to affect to the specified gradient
  16337. * @returns the current particle system
  16338. */
  16339. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16340. /**
  16341. * Gets the current list of ramp gradients.
  16342. * You must use addRampGradient and removeRampGradient to udpate this list
  16343. * @returns the list of ramp gradients
  16344. */
  16345. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16346. /** Gets or sets a boolean indicating that ramp gradients must be used
  16347. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16348. */
  16349. useRampGradients: boolean;
  16350. /**
  16351. * Adds a new color remap gradient
  16352. * @param gradient defines the gradient to use (between 0 and 1)
  16353. * @param min defines the color remap minimal range
  16354. * @param max defines the color remap maximal range
  16355. * @returns the current particle system
  16356. */
  16357. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16358. /**
  16359. * Gets the current list of color remap gradients.
  16360. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16361. * @returns the list of color remap gradients
  16362. */
  16363. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Adds a new alpha remap gradient
  16366. * @param gradient defines the gradient to use (between 0 and 1)
  16367. * @param min defines the alpha remap minimal range
  16368. * @param max defines the alpha remap maximal range
  16369. * @returns the current particle system
  16370. */
  16371. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16372. /**
  16373. * Gets the current list of alpha remap gradients.
  16374. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16375. * @returns the list of alpha remap gradients
  16376. */
  16377. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16378. /**
  16379. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16382. * @returns the emitter
  16383. */
  16384. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16385. /**
  16386. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16387. * @param radius The radius of the hemisphere to emit from
  16388. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16389. * @returns the emitter
  16390. */
  16391. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16392. /**
  16393. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16394. * @param radius The radius of the sphere to emit from
  16395. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16396. * @returns the emitter
  16397. */
  16398. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16399. /**
  16400. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16401. * @param radius The radius of the sphere to emit from
  16402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16404. * @returns the emitter
  16405. */
  16406. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16407. /**
  16408. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16409. * @param radius The radius of the emission cylinder
  16410. * @param height The height of the emission cylinder
  16411. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16412. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16413. * @returns the emitter
  16414. */
  16415. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16416. /**
  16417. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16418. * @param radius The radius of the cylinder to emit from
  16419. * @param height The height of the emission cylinder
  16420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16423. * @returns the emitter
  16424. */
  16425. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16426. /**
  16427. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16428. * @param radius The radius of the cone to emit from
  16429. * @param angle The base angle of the cone
  16430. * @returns the emitter
  16431. */
  16432. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16433. /**
  16434. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16437. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16438. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16439. * @returns the emitter
  16440. */
  16441. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16442. /**
  16443. * Get hosting scene
  16444. * @returns the scene
  16445. */
  16446. getScene(): Scene;
  16447. }
  16448. }
  16449. declare module BABYLON {
  16450. /**
  16451. * Creates an instance based on a source mesh.
  16452. */
  16453. export class InstancedMesh extends AbstractMesh {
  16454. private _sourceMesh;
  16455. private _currentLOD;
  16456. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16457. constructor(name: string, source: Mesh);
  16458. /**
  16459. * Returns the string "InstancedMesh".
  16460. */
  16461. getClassName(): string;
  16462. /**
  16463. * If the source mesh receives shadows
  16464. */
  16465. readonly receiveShadows: boolean;
  16466. /**
  16467. * The material of the source mesh
  16468. */
  16469. readonly material: Nullable<Material>;
  16470. /**
  16471. * Visibility of the source mesh
  16472. */
  16473. readonly visibility: number;
  16474. /**
  16475. * Skeleton of the source mesh
  16476. */
  16477. readonly skeleton: Nullable<Skeleton>;
  16478. /**
  16479. * Rendering ground id of the source mesh
  16480. */
  16481. renderingGroupId: number;
  16482. /**
  16483. * Returns the total number of vertices (integer).
  16484. */
  16485. getTotalVertices(): number;
  16486. /**
  16487. * Returns a positive integer : the total number of indices in this mesh geometry.
  16488. * @returns the numner of indices or zero if the mesh has no geometry.
  16489. */
  16490. getTotalIndices(): number;
  16491. /**
  16492. * The source mesh of the instance
  16493. */
  16494. readonly sourceMesh: Mesh;
  16495. /**
  16496. * Is this node ready to be used/rendered
  16497. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16498. * @return {boolean} is it ready
  16499. */
  16500. isReady(completeCheck?: boolean): boolean;
  16501. /**
  16502. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16503. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16504. * @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.
  16505. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16506. */
  16507. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16508. /**
  16509. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16510. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16511. * The `data` are either a numeric array either a Float32Array.
  16512. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16513. * 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).
  16514. * Note that a new underlying VertexBuffer object is created each call.
  16515. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16516. *
  16517. * Possible `kind` values :
  16518. * - VertexBuffer.PositionKind
  16519. * - VertexBuffer.UVKind
  16520. * - VertexBuffer.UV2Kind
  16521. * - VertexBuffer.UV3Kind
  16522. * - VertexBuffer.UV4Kind
  16523. * - VertexBuffer.UV5Kind
  16524. * - VertexBuffer.UV6Kind
  16525. * - VertexBuffer.ColorKind
  16526. * - VertexBuffer.MatricesIndicesKind
  16527. * - VertexBuffer.MatricesIndicesExtraKind
  16528. * - VertexBuffer.MatricesWeightsKind
  16529. * - VertexBuffer.MatricesWeightsExtraKind
  16530. *
  16531. * Returns the Mesh.
  16532. */
  16533. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16534. /**
  16535. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16536. * If the mesh has no geometry, it is simply returned as it is.
  16537. * The `data` are either a numeric array either a Float32Array.
  16538. * No new underlying VertexBuffer object is created.
  16539. * 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.
  16540. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16541. *
  16542. * Possible `kind` values :
  16543. * - VertexBuffer.PositionKind
  16544. * - VertexBuffer.UVKind
  16545. * - VertexBuffer.UV2Kind
  16546. * - VertexBuffer.UV3Kind
  16547. * - VertexBuffer.UV4Kind
  16548. * - VertexBuffer.UV5Kind
  16549. * - VertexBuffer.UV6Kind
  16550. * - VertexBuffer.ColorKind
  16551. * - VertexBuffer.MatricesIndicesKind
  16552. * - VertexBuffer.MatricesIndicesExtraKind
  16553. * - VertexBuffer.MatricesWeightsKind
  16554. * - VertexBuffer.MatricesWeightsExtraKind
  16555. *
  16556. * Returns the Mesh.
  16557. */
  16558. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16559. /**
  16560. * Sets the mesh indices.
  16561. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16562. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16563. * This method creates a new index buffer each call.
  16564. * Returns the Mesh.
  16565. */
  16566. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16567. /**
  16568. * Boolean : True if the mesh owns the requested kind of data.
  16569. */
  16570. isVerticesDataPresent(kind: string): boolean;
  16571. /**
  16572. * Returns an array of indices (IndicesArray).
  16573. */
  16574. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16575. /**
  16576. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16577. * This means the mesh underlying bounding box and sphere are recomputed.
  16578. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16579. * @returns the current mesh
  16580. */
  16581. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16582. /** @hidden */ preActivate(): InstancedMesh;
  16583. /** @hidden */ activate(renderId: number): boolean;
  16584. getWorldMatrix(): Matrix;
  16585. /**
  16586. * Returns the current associated LOD AbstractMesh.
  16587. */
  16588. getLOD(camera: Camera): AbstractMesh;
  16589. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16590. /** @hidden */ generatePointsArray(): boolean;
  16591. /**
  16592. * Creates a new InstancedMesh from the current mesh.
  16593. * - name (string) : the cloned mesh name
  16594. * - newParent (optional Node) : the optional Node to parent the clone to.
  16595. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16596. *
  16597. * Returns the clone.
  16598. */
  16599. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16600. /**
  16601. * Disposes the InstancedMesh.
  16602. * Returns nothing.
  16603. */
  16604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16605. }
  16606. }
  16607. declare module BABYLON {
  16608. /**
  16609. * Defines the options associated with the creation of a shader material.
  16610. */
  16611. export interface IShaderMaterialOptions {
  16612. /**
  16613. * Does the material work in alpha blend mode
  16614. */
  16615. needAlphaBlending: boolean;
  16616. /**
  16617. * Does the material work in alpha test mode
  16618. */
  16619. needAlphaTesting: boolean;
  16620. /**
  16621. * The list of attribute names used in the shader
  16622. */
  16623. attributes: string[];
  16624. /**
  16625. * The list of unifrom names used in the shader
  16626. */
  16627. uniforms: string[];
  16628. /**
  16629. * The list of UBO names used in the shader
  16630. */
  16631. uniformBuffers: string[];
  16632. /**
  16633. * The list of sampler names used in the shader
  16634. */
  16635. samplers: string[];
  16636. /**
  16637. * The list of defines used in the shader
  16638. */
  16639. defines: string[];
  16640. }
  16641. /**
  16642. * 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.
  16643. *
  16644. * This returned material effects how the mesh will look based on the code in the shaders.
  16645. *
  16646. * @see http://doc.babylonjs.com/how_to/shader_material
  16647. */
  16648. export class ShaderMaterial extends Material {
  16649. private _shaderPath;
  16650. private _options;
  16651. private _textures;
  16652. private _textureArrays;
  16653. private _floats;
  16654. private _ints;
  16655. private _floatsArrays;
  16656. private _colors3;
  16657. private _colors3Arrays;
  16658. private _colors4;
  16659. private _vectors2;
  16660. private _vectors3;
  16661. private _vectors4;
  16662. private _matrices;
  16663. private _matrices3x3;
  16664. private _matrices2x2;
  16665. private _vectors2Arrays;
  16666. private _vectors3Arrays;
  16667. private _cachedWorldViewMatrix;
  16668. private _renderId;
  16669. /**
  16670. * Instantiate a new shader material.
  16671. * 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.
  16672. * This returned material effects how the mesh will look based on the code in the shaders.
  16673. * @see http://doc.babylonjs.com/how_to/shader_material
  16674. * @param name Define the name of the material in the scene
  16675. * @param scene Define the scene the material belongs to
  16676. * @param shaderPath Defines the route to the shader code in one of three ways:
  16677. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16678. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16679. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16680. * @param options Define the options used to create the shader
  16681. */
  16682. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16683. /**
  16684. * Gets the options used to compile the shader.
  16685. * They can be modified to trigger a new compilation
  16686. */
  16687. readonly options: IShaderMaterialOptions;
  16688. /**
  16689. * Gets the current class name of the material e.g. "ShaderMaterial"
  16690. * Mainly use in serialization.
  16691. * @returns the class name
  16692. */
  16693. getClassName(): string;
  16694. /**
  16695. * Specifies if the material will require alpha blending
  16696. * @returns a boolean specifying if alpha blending is needed
  16697. */
  16698. needAlphaBlending(): boolean;
  16699. /**
  16700. * Specifies if this material should be rendered in alpha test mode
  16701. * @returns a boolean specifying if an alpha test is needed.
  16702. */
  16703. needAlphaTesting(): boolean;
  16704. private _checkUniform;
  16705. /**
  16706. * Set a texture in the shader.
  16707. * @param name Define the name of the uniform samplers as defined in the shader
  16708. * @param texture Define the texture to bind to this sampler
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setTexture(name: string, texture: Texture): ShaderMaterial;
  16712. /**
  16713. * Set a texture array in the shader.
  16714. * @param name Define the name of the uniform sampler array as defined in the shader
  16715. * @param textures Define the list of textures to bind to this sampler
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16719. /**
  16720. * Set a float in the shader.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setFloat(name: string, value: number): ShaderMaterial;
  16726. /**
  16727. * Set a int in the shader.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setInt(name: string, value: number): ShaderMaterial;
  16733. /**
  16734. * Set an array of floats in the shader.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setFloats(name: string, value: number[]): ShaderMaterial;
  16740. /**
  16741. * Set a vec3 in the shader from a Color3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setColor3(name: string, value: Color3): ShaderMaterial;
  16747. /**
  16748. * Set a vec3 array in the shader from a Color3 array.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16754. /**
  16755. * Set a vec4 in the shader from a Color4.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setColor4(name: string, value: Color4): ShaderMaterial;
  16761. /**
  16762. * Set a vec2 in the shader from a Vector2.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setVector2(name: string, value: Vector2): ShaderMaterial;
  16768. /**
  16769. * Set a vec3 in the shader from a Vector3.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setVector3(name: string, value: Vector3): ShaderMaterial;
  16775. /**
  16776. * Set a vec4 in the shader from a Vector4.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setVector4(name: string, value: Vector4): ShaderMaterial;
  16782. /**
  16783. * Set a mat4 in the shader from a Matrix.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the material itself allowing "fluent" like uniform updates
  16787. */
  16788. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16789. /**
  16790. * Set a mat3 in the shader from a Float32Array.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the material itself allowing "fluent" like uniform updates
  16794. */
  16795. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16796. /**
  16797. * Set a mat2 in the shader from a Float32Array.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the material itself allowing "fluent" like uniform updates
  16801. */
  16802. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16803. /**
  16804. * Set a vec2 array in the shader from a number array.
  16805. * @param name Define the name of the uniform as defined in the shader
  16806. * @param value Define the value to give to the uniform
  16807. * @return the material itself allowing "fluent" like uniform updates
  16808. */
  16809. setArray2(name: string, value: number[]): ShaderMaterial;
  16810. /**
  16811. * Set a vec3 array in the shader from a number array.
  16812. * @param name Define the name of the uniform as defined in the shader
  16813. * @param value Define the value to give to the uniform
  16814. * @return the material itself allowing "fluent" like uniform updates
  16815. */
  16816. setArray3(name: string, value: number[]): ShaderMaterial;
  16817. private _checkCache;
  16818. /**
  16819. * Specifies that the submesh is ready to be used
  16820. * @param mesh defines the mesh to check
  16821. * @param subMesh defines which submesh to check
  16822. * @param useInstances specifies that instances should be used
  16823. * @returns a boolean indicating that the submesh is ready or not
  16824. */
  16825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16826. /**
  16827. * Checks if the material is ready to render the requested mesh
  16828. * @param mesh Define the mesh to render
  16829. * @param useInstances Define whether or not the material is used with instances
  16830. * @returns true if ready, otherwise false
  16831. */
  16832. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16833. /**
  16834. * Binds the world matrix to the material
  16835. * @param world defines the world transformation matrix
  16836. */
  16837. bindOnlyWorldMatrix(world: Matrix): void;
  16838. /**
  16839. * Binds the material to the mesh
  16840. * @param world defines the world transformation matrix
  16841. * @param mesh defines the mesh to bind the material to
  16842. */
  16843. bind(world: Matrix, mesh?: Mesh): void;
  16844. /**
  16845. * Gets the active textures from the material
  16846. * @returns an array of textures
  16847. */
  16848. getActiveTextures(): BaseTexture[];
  16849. /**
  16850. * Specifies if the material uses a texture
  16851. * @param texture defines the texture to check against the material
  16852. * @returns a boolean specifying if the material uses the texture
  16853. */
  16854. hasTexture(texture: BaseTexture): boolean;
  16855. /**
  16856. * Makes a duplicate of the material, and gives it a new name
  16857. * @param name defines the new name for the duplicated material
  16858. * @returns the cloned material
  16859. */
  16860. clone(name: string): ShaderMaterial;
  16861. /**
  16862. * Disposes the material
  16863. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16864. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16865. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16866. */
  16867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16868. /**
  16869. * Serializes this material in a JSON representation
  16870. * @returns the serialized material object
  16871. */
  16872. serialize(): any;
  16873. /**
  16874. * Creates a shader material from parsed shader material data
  16875. * @param source defines the JSON represnetation of the material
  16876. * @param scene defines the hosting scene
  16877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16878. * @returns a new material
  16879. */
  16880. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16881. }
  16882. }
  16883. declare module BABYLON {
  16884. /** @hidden */
  16885. export var colorPixelShader: {
  16886. name: string;
  16887. shader: string;
  16888. };
  16889. }
  16890. declare module BABYLON {
  16891. /** @hidden */
  16892. export var colorVertexShader: {
  16893. name: string;
  16894. shader: string;
  16895. };
  16896. }
  16897. declare module BABYLON {
  16898. /**
  16899. * Line mesh
  16900. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16901. */
  16902. export class LinesMesh extends Mesh {
  16903. /**
  16904. * If vertex color should be applied to the mesh
  16905. */
  16906. useVertexColor?: boolean | undefined;
  16907. /**
  16908. * If vertex alpha should be applied to the mesh
  16909. */
  16910. useVertexAlpha?: boolean | undefined;
  16911. /**
  16912. * Color of the line (Default: White)
  16913. */
  16914. color: Color3;
  16915. /**
  16916. * Alpha of the line (Default: 1)
  16917. */
  16918. alpha: number;
  16919. /**
  16920. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16921. * This margin is expressed in world space coordinates, so its value may vary.
  16922. * Default value is 0.1
  16923. */
  16924. intersectionThreshold: number;
  16925. private _colorShader;
  16926. /**
  16927. * Creates a new LinesMesh
  16928. * @param name defines the name
  16929. * @param scene defines the hosting scene
  16930. * @param parent defines the parent mesh if any
  16931. * @param source defines the optional source LinesMesh used to clone data from
  16932. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16933. * When false, achieved by calling a clone(), also passing False.
  16934. * This will make creation of children, recursive.
  16935. * @param useVertexColor defines if this LinesMesh supports vertex color
  16936. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16937. */
  16938. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16939. /**
  16940. * If vertex color should be applied to the mesh
  16941. */
  16942. useVertexColor?: boolean | undefined,
  16943. /**
  16944. * If vertex alpha should be applied to the mesh
  16945. */
  16946. useVertexAlpha?: boolean | undefined);
  16947. private _addClipPlaneDefine;
  16948. private _removeClipPlaneDefine;
  16949. isReady(): boolean;
  16950. /**
  16951. * Returns the string "LineMesh"
  16952. */
  16953. getClassName(): string;
  16954. /**
  16955. * @hidden
  16956. */
  16957. /**
  16958. * @hidden
  16959. */
  16960. material: Material;
  16961. /**
  16962. * @hidden
  16963. */
  16964. readonly checkCollisions: boolean;
  16965. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16966. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16967. /**
  16968. * Disposes of the line mesh
  16969. * @param doNotRecurse If children should be disposed
  16970. */
  16971. dispose(doNotRecurse?: boolean): void;
  16972. /**
  16973. * Returns a new LineMesh object cloned from the current one.
  16974. */
  16975. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16976. /**
  16977. * Creates a new InstancedLinesMesh object from the mesh model.
  16978. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16979. * @param name defines the name of the new instance
  16980. * @returns a new InstancedLinesMesh
  16981. */
  16982. createInstance(name: string): InstancedLinesMesh;
  16983. }
  16984. /**
  16985. * Creates an instance based on a source LinesMesh
  16986. */
  16987. export class InstancedLinesMesh extends InstancedMesh {
  16988. /**
  16989. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16990. * This margin is expressed in world space coordinates, so its value may vary.
  16991. * Initilized with the intersectionThreshold value of the source LinesMesh
  16992. */
  16993. intersectionThreshold: number;
  16994. constructor(name: string, source: LinesMesh);
  16995. /**
  16996. * Returns the string "InstancedLinesMesh".
  16997. */
  16998. getClassName(): string;
  16999. }
  17000. }
  17001. declare module BABYLON {
  17002. /** @hidden */
  17003. export var linePixelShader: {
  17004. name: string;
  17005. shader: string;
  17006. };
  17007. }
  17008. declare module BABYLON {
  17009. /** @hidden */
  17010. export var lineVertexShader: {
  17011. name: string;
  17012. shader: string;
  17013. };
  17014. }
  17015. declare module BABYLON {
  17016. interface AbstractMesh {
  17017. /**
  17018. * Disables the mesh edge rendering mode
  17019. * @returns the currentAbstractMesh
  17020. */
  17021. disableEdgesRendering(): AbstractMesh;
  17022. /**
  17023. * Enables the edge rendering mode on the mesh.
  17024. * This mode makes the mesh edges visible
  17025. * @param epsilon defines the maximal distance between two angles to detect a face
  17026. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17027. * @returns the currentAbstractMesh
  17028. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17029. */
  17030. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17031. /**
  17032. * Gets the edgesRenderer associated with the mesh
  17033. */
  17034. edgesRenderer: Nullable<EdgesRenderer>;
  17035. }
  17036. interface LinesMesh {
  17037. /**
  17038. * Enables the edge rendering mode on the mesh.
  17039. * This mode makes the mesh edges visible
  17040. * @param epsilon defines the maximal distance between two angles to detect a face
  17041. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17042. * @returns the currentAbstractMesh
  17043. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17044. */
  17045. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17046. }
  17047. interface InstancedLinesMesh {
  17048. /**
  17049. * Enables the edge rendering mode on the mesh.
  17050. * This mode makes the mesh edges visible
  17051. * @param epsilon defines the maximal distance between two angles to detect a face
  17052. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17053. * @returns the current InstancedLinesMesh
  17054. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17055. */
  17056. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17057. }
  17058. /**
  17059. * Defines the minimum contract an Edges renderer should follow.
  17060. */
  17061. export interface IEdgesRenderer extends IDisposable {
  17062. /**
  17063. * Gets or sets a boolean indicating if the edgesRenderer is active
  17064. */
  17065. isEnabled: boolean;
  17066. /**
  17067. * Renders the edges of the attached mesh,
  17068. */
  17069. render(): void;
  17070. /**
  17071. * Checks wether or not the edges renderer is ready to render.
  17072. * @return true if ready, otherwise false.
  17073. */
  17074. isReady(): boolean;
  17075. }
  17076. /**
  17077. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17078. */
  17079. export class EdgesRenderer implements IEdgesRenderer {
  17080. /**
  17081. * Define the size of the edges with an orthographic camera
  17082. */
  17083. edgesWidthScalerForOrthographic: number;
  17084. /**
  17085. * Define the size of the edges with a perspective camera
  17086. */
  17087. edgesWidthScalerForPerspective: number;
  17088. protected _source: AbstractMesh;
  17089. protected _linesPositions: number[];
  17090. protected _linesNormals: number[];
  17091. protected _linesIndices: number[];
  17092. protected _epsilon: number;
  17093. protected _indicesCount: number;
  17094. protected _lineShader: ShaderMaterial;
  17095. protected _ib: DataBuffer;
  17096. protected _buffers: {
  17097. [key: string]: Nullable<VertexBuffer>;
  17098. };
  17099. protected _checkVerticesInsteadOfIndices: boolean;
  17100. private _meshRebuildObserver;
  17101. private _meshDisposeObserver;
  17102. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17103. isEnabled: boolean;
  17104. /**
  17105. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17106. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17107. * @param source Mesh used to create edges
  17108. * @param epsilon sum of angles in adjacency to check for edge
  17109. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17110. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17111. */
  17112. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17113. protected _prepareRessources(): void;
  17114. /** @hidden */ rebuild(): void;
  17115. /**
  17116. * Releases the required resources for the edges renderer
  17117. */
  17118. dispose(): void;
  17119. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17120. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17121. /**
  17122. * Checks if the pair of p0 and p1 is en edge
  17123. * @param faceIndex
  17124. * @param edge
  17125. * @param faceNormals
  17126. * @param p0
  17127. * @param p1
  17128. * @private
  17129. */
  17130. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17131. /**
  17132. * push line into the position, normal and index buffer
  17133. * @protected
  17134. */
  17135. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17136. /**
  17137. * Generates lines edges from adjacencjes
  17138. * @private
  17139. */ generateEdgesLines(): void;
  17140. /**
  17141. * Checks wether or not the edges renderer is ready to render.
  17142. * @return true if ready, otherwise false.
  17143. */
  17144. isReady(): boolean;
  17145. /**
  17146. * Renders the edges of the attached mesh,
  17147. */
  17148. render(): void;
  17149. }
  17150. /**
  17151. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17152. */
  17153. export class LineEdgesRenderer extends EdgesRenderer {
  17154. /**
  17155. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17156. * @param source LineMesh used to generate edges
  17157. * @param epsilon not important (specified angle for edge detection)
  17158. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17159. */
  17160. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17161. /**
  17162. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17163. */ generateEdgesLines(): void;
  17164. }
  17165. }
  17166. declare module BABYLON {
  17167. /**
  17168. * This represents the object necessary to create a rendering group.
  17169. * This is exclusively used and created by the rendering manager.
  17170. * To modify the behavior, you use the available helpers in your scene or meshes.
  17171. * @hidden
  17172. */
  17173. export class RenderingGroup {
  17174. index: number;
  17175. private _scene;
  17176. private _opaqueSubMeshes;
  17177. private _transparentSubMeshes;
  17178. private _alphaTestSubMeshes;
  17179. private _depthOnlySubMeshes;
  17180. private _particleSystems;
  17181. private _spriteManagers;
  17182. private _opaqueSortCompareFn;
  17183. private _alphaTestSortCompareFn;
  17184. private _transparentSortCompareFn;
  17185. private _renderOpaque;
  17186. private _renderAlphaTest;
  17187. private _renderTransparent;
  17188. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17189. onBeforeTransparentRendering: () => void;
  17190. /**
  17191. * Set the opaque sort comparison function.
  17192. * If null the sub meshes will be render in the order they were created
  17193. */
  17194. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17195. /**
  17196. * Set the alpha test sort comparison function.
  17197. * If null the sub meshes will be render in the order they were created
  17198. */
  17199. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17200. /**
  17201. * Set the transparent sort comparison function.
  17202. * If null the sub meshes will be render in the order they were created
  17203. */
  17204. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17205. /**
  17206. * Creates a new rendering group.
  17207. * @param index The rendering group index
  17208. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17209. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17210. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17211. */
  17212. 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>);
  17213. /**
  17214. * Render all the sub meshes contained in the group.
  17215. * @param customRenderFunction Used to override the default render behaviour of the group.
  17216. * @returns true if rendered some submeshes.
  17217. */
  17218. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17219. /**
  17220. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17221. * @param subMeshes The submeshes to render
  17222. */
  17223. private renderOpaqueSorted;
  17224. /**
  17225. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17226. * @param subMeshes The submeshes to render
  17227. */
  17228. private renderAlphaTestSorted;
  17229. /**
  17230. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17231. * @param subMeshes The submeshes to render
  17232. */
  17233. private renderTransparentSorted;
  17234. /**
  17235. * Renders the submeshes in a specified order.
  17236. * @param subMeshes The submeshes to sort before render
  17237. * @param sortCompareFn The comparison function use to sort
  17238. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17239. * @param transparent Specifies to activate blending if true
  17240. */
  17241. private static renderSorted;
  17242. /**
  17243. * Renders the submeshes in the order they were dispatched (no sort applied).
  17244. * @param subMeshes The submeshes to render
  17245. */
  17246. private static renderUnsorted;
  17247. /**
  17248. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17249. * are rendered back to front if in the same alpha index.
  17250. *
  17251. * @param a The first submesh
  17252. * @param b The second submesh
  17253. * @returns The result of the comparison
  17254. */
  17255. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17256. /**
  17257. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17258. * are rendered back to front.
  17259. *
  17260. * @param a The first submesh
  17261. * @param b The second submesh
  17262. * @returns The result of the comparison
  17263. */
  17264. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17265. /**
  17266. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17267. * are rendered front to back (prevent overdraw).
  17268. *
  17269. * @param a The first submesh
  17270. * @param b The second submesh
  17271. * @returns The result of the comparison
  17272. */
  17273. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17274. /**
  17275. * Resets the different lists of submeshes to prepare a new frame.
  17276. */
  17277. prepare(): void;
  17278. dispose(): void;
  17279. /**
  17280. * Inserts the submesh in its correct queue depending on its material.
  17281. * @param subMesh The submesh to dispatch
  17282. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17283. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17284. */
  17285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17286. dispatchSprites(spriteManager: ISpriteManager): void;
  17287. dispatchParticles(particleSystem: IParticleSystem): void;
  17288. private _renderParticles;
  17289. private _renderSprites;
  17290. }
  17291. }
  17292. declare module BABYLON {
  17293. /**
  17294. * Interface describing the different options available in the rendering manager
  17295. * regarding Auto Clear between groups.
  17296. */
  17297. export interface IRenderingManagerAutoClearSetup {
  17298. /**
  17299. * Defines whether or not autoclear is enable.
  17300. */
  17301. autoClear: boolean;
  17302. /**
  17303. * Defines whether or not to autoclear the depth buffer.
  17304. */
  17305. depth: boolean;
  17306. /**
  17307. * Defines whether or not to autoclear the stencil buffer.
  17308. */
  17309. stencil: boolean;
  17310. }
  17311. /**
  17312. * This class is used by the onRenderingGroupObservable
  17313. */
  17314. export class RenderingGroupInfo {
  17315. /**
  17316. * The Scene that being rendered
  17317. */
  17318. scene: Scene;
  17319. /**
  17320. * The camera currently used for the rendering pass
  17321. */
  17322. camera: Nullable<Camera>;
  17323. /**
  17324. * The ID of the renderingGroup being processed
  17325. */
  17326. renderingGroupId: number;
  17327. }
  17328. /**
  17329. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17330. * It is enable to manage the different groups as well as the different necessary sort functions.
  17331. * This should not be used directly aside of the few static configurations
  17332. */
  17333. export class RenderingManager {
  17334. /**
  17335. * The max id used for rendering groups (not included)
  17336. */
  17337. static MAX_RENDERINGGROUPS: number;
  17338. /**
  17339. * The min id used for rendering groups (included)
  17340. */
  17341. static MIN_RENDERINGGROUPS: number;
  17342. /**
  17343. * Used to globally prevent autoclearing scenes.
  17344. */
  17345. static AUTOCLEAR: boolean;
  17346. /**
  17347. * @hidden
  17348. */ useSceneAutoClearSetup: boolean;
  17349. private _scene;
  17350. private _renderingGroups;
  17351. private _depthStencilBufferAlreadyCleaned;
  17352. private _autoClearDepthStencil;
  17353. private _customOpaqueSortCompareFn;
  17354. private _customAlphaTestSortCompareFn;
  17355. private _customTransparentSortCompareFn;
  17356. private _renderingGroupInfo;
  17357. /**
  17358. * Instantiates a new rendering group for a particular scene
  17359. * @param scene Defines the scene the groups belongs to
  17360. */
  17361. constructor(scene: Scene);
  17362. private _clearDepthStencilBuffer;
  17363. /**
  17364. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17365. * @hidden
  17366. */
  17367. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17368. /**
  17369. * Resets the different information of the group to prepare a new frame
  17370. * @hidden
  17371. */
  17372. reset(): void;
  17373. /**
  17374. * Dispose and release the group and its associated resources.
  17375. * @hidden
  17376. */
  17377. dispose(): void;
  17378. /**
  17379. * Clear the info related to rendering groups preventing retention points during dispose.
  17380. */
  17381. freeRenderingGroups(): void;
  17382. private _prepareRenderingGroup;
  17383. /**
  17384. * Add a sprite manager to the rendering manager in order to render it this frame.
  17385. * @param spriteManager Define the sprite manager to render
  17386. */
  17387. dispatchSprites(spriteManager: ISpriteManager): void;
  17388. /**
  17389. * Add a particle system to the rendering manager in order to render it this frame.
  17390. * @param particleSystem Define the particle system to render
  17391. */
  17392. dispatchParticles(particleSystem: IParticleSystem): void;
  17393. /**
  17394. * Add a submesh to the manager in order to render it this frame
  17395. * @param subMesh The submesh to dispatch
  17396. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17397. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17398. */
  17399. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17400. /**
  17401. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17402. * This allowed control for front to back rendering or reversly depending of the special needs.
  17403. *
  17404. * @param renderingGroupId The rendering group id corresponding to its index
  17405. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17406. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17407. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17408. */
  17409. 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;
  17410. /**
  17411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17412. *
  17413. * @param renderingGroupId The rendering group id corresponding to its index
  17414. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17415. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17416. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17417. */
  17418. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17419. /**
  17420. * Gets the current auto clear configuration for one rendering group of the rendering
  17421. * manager.
  17422. * @param index the rendering group index to get the information for
  17423. * @returns The auto clear setup for the requested rendering group
  17424. */
  17425. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * This Helps creating a texture that will be created from a camera in your scene.
  17431. * It is basically a dynamic texture that could be used to create special effects for instance.
  17432. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17433. */
  17434. export class RenderTargetTexture extends Texture {
  17435. isCube: boolean;
  17436. /**
  17437. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17438. */
  17439. static readonly REFRESHRATE_RENDER_ONCE: number;
  17440. /**
  17441. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17442. */
  17443. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17444. /**
  17445. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17446. * the central point of your effect and can save a lot of performances.
  17447. */
  17448. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17449. /**
  17450. * Use this predicate to dynamically define the list of mesh you want to render.
  17451. * If set, the renderList property will be overwritten.
  17452. */
  17453. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17454. private _renderList;
  17455. /**
  17456. * Use this list to define the list of mesh you want to render.
  17457. */
  17458. renderList: Nullable<Array<AbstractMesh>>;
  17459. private _hookArray;
  17460. /**
  17461. * Define if particles should be rendered in your texture.
  17462. */
  17463. renderParticles: boolean;
  17464. /**
  17465. * Define if sprites should be rendered in your texture.
  17466. */
  17467. renderSprites: boolean;
  17468. /**
  17469. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17470. */
  17471. coordinatesMode: number;
  17472. /**
  17473. * Define the camera used to render the texture.
  17474. */
  17475. activeCamera: Nullable<Camera>;
  17476. /**
  17477. * Override the render function of the texture with your own one.
  17478. */
  17479. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17480. /**
  17481. * Define if camera post processes should be use while rendering the texture.
  17482. */
  17483. useCameraPostProcesses: boolean;
  17484. /**
  17485. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17486. */
  17487. ignoreCameraViewport: boolean;
  17488. private _postProcessManager;
  17489. private _postProcesses;
  17490. private _resizeObserver;
  17491. /**
  17492. * An event triggered when the texture is unbind.
  17493. */
  17494. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17495. /**
  17496. * An event triggered when the texture is unbind.
  17497. */
  17498. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17499. private _onAfterUnbindObserver;
  17500. /**
  17501. * Set a after unbind callback in the texture.
  17502. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17503. */
  17504. onAfterUnbind: () => void;
  17505. /**
  17506. * An event triggered before rendering the texture
  17507. */
  17508. onBeforeRenderObservable: Observable<number>;
  17509. private _onBeforeRenderObserver;
  17510. /**
  17511. * Set a before render callback in the texture.
  17512. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17513. */
  17514. onBeforeRender: (faceIndex: number) => void;
  17515. /**
  17516. * An event triggered after rendering the texture
  17517. */
  17518. onAfterRenderObservable: Observable<number>;
  17519. private _onAfterRenderObserver;
  17520. /**
  17521. * Set a after render callback in the texture.
  17522. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17523. */
  17524. onAfterRender: (faceIndex: number) => void;
  17525. /**
  17526. * An event triggered after the texture clear
  17527. */
  17528. onClearObservable: Observable<Engine>;
  17529. private _onClearObserver;
  17530. /**
  17531. * Set a clear callback in the texture.
  17532. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17533. */
  17534. onClear: (Engine: Engine) => void;
  17535. /**
  17536. * Define the clear color of the Render Target if it should be different from the scene.
  17537. */
  17538. clearColor: Color4;
  17539. protected _size: number | {
  17540. width: number;
  17541. height: number;
  17542. };
  17543. protected _initialSizeParameter: number | {
  17544. width: number;
  17545. height: number;
  17546. } | {
  17547. ratio: number;
  17548. };
  17549. protected _sizeRatio: Nullable<number>;
  17550. /** @hidden */ generateMipMaps: boolean;
  17551. protected _renderingManager: RenderingManager;
  17552. /** @hidden */ waitingRenderList: string[];
  17553. protected _doNotChangeAspectRatio: boolean;
  17554. protected _currentRefreshId: number;
  17555. protected _refreshRate: number;
  17556. protected _textureMatrix: Matrix;
  17557. protected _samples: number;
  17558. protected _renderTargetOptions: RenderTargetCreationOptions;
  17559. /**
  17560. * Gets render target creation options that were used.
  17561. */
  17562. readonly renderTargetOptions: RenderTargetCreationOptions;
  17563. protected _engine: Engine;
  17564. protected _onRatioRescale(): void;
  17565. /**
  17566. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17567. * It must define where the camera used to render the texture is set
  17568. */
  17569. boundingBoxPosition: Vector3;
  17570. private _boundingBoxSize;
  17571. /**
  17572. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17573. * When defined, the cubemap will switch to local mode
  17574. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17575. * @example https://www.babylonjs-playground.com/#RNASML
  17576. */
  17577. boundingBoxSize: Vector3;
  17578. /**
  17579. * In case the RTT has been created with a depth texture, get the associated
  17580. * depth texture.
  17581. * Otherwise, return null.
  17582. */
  17583. depthStencilTexture: Nullable<InternalTexture>;
  17584. /**
  17585. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17586. * or used a shadow, depth texture...
  17587. * @param name The friendly name of the texture
  17588. * @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)
  17589. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17590. * @param generateMipMaps True if mip maps need to be generated after render.
  17591. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17592. * @param type The type of the buffer in the RTT (int, half float, float...)
  17593. * @param isCube True if a cube texture needs to be created
  17594. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17595. * @param generateDepthBuffer True to generate a depth buffer
  17596. * @param generateStencilBuffer True to generate a stencil buffer
  17597. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17598. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17599. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17600. */
  17601. constructor(name: string, size: number | {
  17602. width: number;
  17603. height: number;
  17604. } | {
  17605. ratio: number;
  17606. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17607. /**
  17608. * Creates a depth stencil texture.
  17609. * This is only available in WebGL 2 or with the depth texture extension available.
  17610. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17611. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17612. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17613. */
  17614. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17615. private _processSizeParameter;
  17616. /**
  17617. * Define the number of samples to use in case of MSAA.
  17618. * It defaults to one meaning no MSAA has been enabled.
  17619. */
  17620. samples: number;
  17621. /**
  17622. * Resets the refresh counter of the texture and start bak from scratch.
  17623. * Could be useful to regenerate the texture if it is setup to render only once.
  17624. */
  17625. resetRefreshCounter(): void;
  17626. /**
  17627. * Define the refresh rate of the texture or the rendering frequency.
  17628. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17629. */
  17630. refreshRate: number;
  17631. /**
  17632. * Adds a post process to the render target rendering passes.
  17633. * @param postProcess define the post process to add
  17634. */
  17635. addPostProcess(postProcess: PostProcess): void;
  17636. /**
  17637. * Clear all the post processes attached to the render target
  17638. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17639. */
  17640. clearPostProcesses(dispose?: boolean): void;
  17641. /**
  17642. * Remove one of the post process from the list of attached post processes to the texture
  17643. * @param postProcess define the post process to remove from the list
  17644. */
  17645. removePostProcess(postProcess: PostProcess): void;
  17646. /** @hidden */ shouldRender(): boolean;
  17647. /**
  17648. * Gets the actual render size of the texture.
  17649. * @returns the width of the render size
  17650. */
  17651. getRenderSize(): number;
  17652. /**
  17653. * Gets the actual render width of the texture.
  17654. * @returns the width of the render size
  17655. */
  17656. getRenderWidth(): number;
  17657. /**
  17658. * Gets the actual render height of the texture.
  17659. * @returns the height of the render size
  17660. */
  17661. getRenderHeight(): number;
  17662. /**
  17663. * Get if the texture can be rescaled or not.
  17664. */
  17665. readonly canRescale: boolean;
  17666. /**
  17667. * Resize the texture using a ratio.
  17668. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17669. */
  17670. scale(ratio: number): void;
  17671. /**
  17672. * Get the texture reflection matrix used to rotate/transform the reflection.
  17673. * @returns the reflection matrix
  17674. */
  17675. getReflectionTextureMatrix(): Matrix;
  17676. /**
  17677. * Resize the texture to a new desired size.
  17678. * Be carrefull as it will recreate all the data in the new texture.
  17679. * @param size Define the new size. It can be:
  17680. * - a number for squared texture,
  17681. * - an object containing { width: number, height: number }
  17682. * - or an object containing a ratio { ratio: number }
  17683. */
  17684. resize(size: number | {
  17685. width: number;
  17686. height: number;
  17687. } | {
  17688. ratio: number;
  17689. }): void;
  17690. /**
  17691. * Renders all the objects from the render list into the texture.
  17692. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17693. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17694. */
  17695. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17696. private _bestReflectionRenderTargetDimension;
  17697. /**
  17698. * @hidden
  17699. * @param faceIndex face index to bind to if this is a cubetexture
  17700. */ bindFrameBuffer(faceIndex?: number): void;
  17701. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17702. private renderToTarget;
  17703. /**
  17704. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17705. * This allowed control for front to back rendering or reversly depending of the special needs.
  17706. *
  17707. * @param renderingGroupId The rendering group id corresponding to its index
  17708. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17709. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17710. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17711. */
  17712. 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;
  17713. /**
  17714. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17715. *
  17716. * @param renderingGroupId The rendering group id corresponding to its index
  17717. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17718. */
  17719. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17720. /**
  17721. * Clones the texture.
  17722. * @returns the cloned texture
  17723. */
  17724. clone(): RenderTargetTexture;
  17725. /**
  17726. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17727. * @returns The JSON representation of the texture
  17728. */
  17729. serialize(): any;
  17730. /**
  17731. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17732. */
  17733. disposeFramebufferObjects(): void;
  17734. /**
  17735. * Dispose the texture and release its associated resources.
  17736. */
  17737. dispose(): void;
  17738. /** @hidden */ rebuild(): void;
  17739. /**
  17740. * Clear the info related to rendering groups preventing retention point in material dispose.
  17741. */
  17742. freeRenderingGroups(): void;
  17743. /**
  17744. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17745. * @returns the view count
  17746. */
  17747. getViewCount(): number;
  17748. }
  17749. }
  17750. declare module BABYLON {
  17751. /**
  17752. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17753. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17754. * You can then easily use it as a reflectionTexture on a flat surface.
  17755. * In case the surface is not a plane, please consider relying on reflection probes.
  17756. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17757. */
  17758. export class MirrorTexture extends RenderTargetTexture {
  17759. private scene;
  17760. /**
  17761. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17762. * 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.
  17763. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17764. */
  17765. mirrorPlane: Plane;
  17766. /**
  17767. * Define the blur ratio used to blur the reflection if needed.
  17768. */
  17769. blurRatio: number;
  17770. /**
  17771. * Define the adaptive blur kernel used to blur the reflection if needed.
  17772. * This will autocompute the closest best match for the `blurKernel`
  17773. */
  17774. adaptiveBlurKernel: number;
  17775. /**
  17776. * Define the blur kernel used to blur the reflection if needed.
  17777. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17778. */
  17779. blurKernel: number;
  17780. /**
  17781. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17783. */
  17784. blurKernelX: number;
  17785. /**
  17786. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17787. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17788. */
  17789. blurKernelY: number;
  17790. private _autoComputeBlurKernel;
  17791. protected _onRatioRescale(): void;
  17792. private _updateGammaSpace;
  17793. private _imageProcessingConfigChangeObserver;
  17794. private _transformMatrix;
  17795. private _mirrorMatrix;
  17796. private _savedViewMatrix;
  17797. private _blurX;
  17798. private _blurY;
  17799. private _adaptiveBlurKernel;
  17800. private _blurKernelX;
  17801. private _blurKernelY;
  17802. private _blurRatio;
  17803. /**
  17804. * Instantiates a Mirror Texture.
  17805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17807. * You can then easily use it as a reflectionTexture on a flat surface.
  17808. * In case the surface is not a plane, please consider relying on reflection probes.
  17809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17810. * @param name
  17811. * @param size
  17812. * @param scene
  17813. * @param generateMipMaps
  17814. * @param type
  17815. * @param samplingMode
  17816. * @param generateDepthBuffer
  17817. */
  17818. constructor(name: string, size: number | {
  17819. width: number;
  17820. height: number;
  17821. } | {
  17822. ratio: number;
  17823. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17824. private _preparePostProcesses;
  17825. /**
  17826. * Clone the mirror texture.
  17827. * @returns the cloned texture
  17828. */
  17829. clone(): MirrorTexture;
  17830. /**
  17831. * Serialize the texture to a JSON representation you could use in Parse later on
  17832. * @returns the serialized JSON representation
  17833. */
  17834. serialize(): any;
  17835. /**
  17836. * Dispose the texture and release its associated resources.
  17837. */
  17838. dispose(): void;
  17839. }
  17840. }
  17841. declare module BABYLON {
  17842. /**
  17843. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17844. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17845. */
  17846. export class Texture extends BaseTexture {
  17847. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17848. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17849. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17850. /** nearest is mag = nearest and min = nearest and mip = linear */
  17851. static readonly NEAREST_SAMPLINGMODE: number;
  17852. /** nearest is mag = nearest and min = nearest and mip = linear */
  17853. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17855. static readonly BILINEAR_SAMPLINGMODE: number;
  17856. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17857. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17858. /** Trilinear is mag = linear and min = linear and mip = linear */
  17859. static readonly TRILINEAR_SAMPLINGMODE: number;
  17860. /** Trilinear is mag = linear and min = linear and mip = linear */
  17861. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17862. /** mag = nearest and min = nearest and mip = nearest */
  17863. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17864. /** mag = nearest and min = linear and mip = nearest */
  17865. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17866. /** mag = nearest and min = linear and mip = linear */
  17867. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17868. /** mag = nearest and min = linear and mip = none */
  17869. static readonly NEAREST_LINEAR: number;
  17870. /** mag = nearest and min = nearest and mip = none */
  17871. static readonly NEAREST_NEAREST: number;
  17872. /** mag = linear and min = nearest and mip = nearest */
  17873. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17874. /** mag = linear and min = nearest and mip = linear */
  17875. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17876. /** mag = linear and min = linear and mip = none */
  17877. static readonly LINEAR_LINEAR: number;
  17878. /** mag = linear and min = nearest and mip = none */
  17879. static readonly LINEAR_NEAREST: number;
  17880. /** Explicit coordinates mode */
  17881. static readonly EXPLICIT_MODE: number;
  17882. /** Spherical coordinates mode */
  17883. static readonly SPHERICAL_MODE: number;
  17884. /** Planar coordinates mode */
  17885. static readonly PLANAR_MODE: number;
  17886. /** Cubic coordinates mode */
  17887. static readonly CUBIC_MODE: number;
  17888. /** Projection coordinates mode */
  17889. static readonly PROJECTION_MODE: number;
  17890. /** Inverse Cubic coordinates mode */
  17891. static readonly SKYBOX_MODE: number;
  17892. /** Inverse Cubic coordinates mode */
  17893. static readonly INVCUBIC_MODE: number;
  17894. /** Equirectangular coordinates mode */
  17895. static readonly EQUIRECTANGULAR_MODE: number;
  17896. /** Equirectangular Fixed coordinates mode */
  17897. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17898. /** Equirectangular Fixed Mirrored coordinates mode */
  17899. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17900. /** Texture is not repeating outside of 0..1 UVs */
  17901. static readonly CLAMP_ADDRESSMODE: number;
  17902. /** Texture is repeating outside of 0..1 UVs */
  17903. static readonly WRAP_ADDRESSMODE: number;
  17904. /** Texture is repeating and mirrored */
  17905. static readonly MIRROR_ADDRESSMODE: number;
  17906. /**
  17907. * 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
  17908. */
  17909. static UseSerializedUrlIfAny: boolean;
  17910. /**
  17911. * Define the url of the texture.
  17912. */
  17913. url: Nullable<string>;
  17914. /**
  17915. * Define an offset on the texture to offset the u coordinates of the UVs
  17916. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17917. */
  17918. uOffset: number;
  17919. /**
  17920. * Define an offset on the texture to offset the v coordinates of the UVs
  17921. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17922. */
  17923. vOffset: number;
  17924. /**
  17925. * Define an offset on the texture to scale the u coordinates of the UVs
  17926. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17927. */
  17928. uScale: number;
  17929. /**
  17930. * Define an offset on the texture to scale the v coordinates of the UVs
  17931. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17932. */
  17933. vScale: number;
  17934. /**
  17935. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17936. * @see http://doc.babylonjs.com/how_to/more_materials
  17937. */
  17938. uAng: number;
  17939. /**
  17940. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17941. * @see http://doc.babylonjs.com/how_to/more_materials
  17942. */
  17943. vAng: number;
  17944. /**
  17945. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17946. * @see http://doc.babylonjs.com/how_to/more_materials
  17947. */
  17948. wAng: number;
  17949. /**
  17950. * Defines the center of rotation (U)
  17951. */
  17952. uRotationCenter: number;
  17953. /**
  17954. * Defines the center of rotation (V)
  17955. */
  17956. vRotationCenter: number;
  17957. /**
  17958. * Defines the center of rotation (W)
  17959. */
  17960. wRotationCenter: number;
  17961. /**
  17962. * Are mip maps generated for this texture or not.
  17963. */
  17964. readonly noMipmap: boolean;
  17965. /**
  17966. * List of inspectable custom properties (used by the Inspector)
  17967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17968. */
  17969. inspectableCustomProperties: Nullable<IInspectable[]>;
  17970. private _noMipmap;
  17971. /** @hidden */ invertY: boolean;
  17972. private _rowGenerationMatrix;
  17973. private _cachedTextureMatrix;
  17974. private _projectionModeMatrix;
  17975. private _t0;
  17976. private _t1;
  17977. private _t2;
  17978. private _cachedUOffset;
  17979. private _cachedVOffset;
  17980. private _cachedUScale;
  17981. private _cachedVScale;
  17982. private _cachedUAng;
  17983. private _cachedVAng;
  17984. private _cachedWAng;
  17985. private _cachedProjectionMatrixId;
  17986. private _cachedCoordinatesMode;
  17987. /** @hidden */
  17988. protected _initialSamplingMode: number;
  17989. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17990. private _deleteBuffer;
  17991. protected _format: Nullable<number>;
  17992. private _delayedOnLoad;
  17993. private _delayedOnError;
  17994. /**
  17995. * Observable triggered once the texture has been loaded.
  17996. */
  17997. onLoadObservable: Observable<Texture>;
  17998. protected _isBlocking: boolean;
  17999. /**
  18000. * Is the texture preventing material to render while loading.
  18001. * If false, a default texture will be used instead of the loading one during the preparation step.
  18002. */
  18003. isBlocking: boolean;
  18004. /**
  18005. * Get the current sampling mode associated with the texture.
  18006. */
  18007. readonly samplingMode: number;
  18008. /**
  18009. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18010. */
  18011. readonly invertY: boolean;
  18012. /**
  18013. * Instantiates a new texture.
  18014. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18015. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18016. * @param url define the url of the picture to load as a texture
  18017. * @param scene define the scene the texture will belong to
  18018. * @param noMipmap define if the texture will require mip maps or not
  18019. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18020. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18021. * @param onLoad define a callback triggered when the texture has been loaded
  18022. * @param onError define a callback triggered when an error occurred during the loading session
  18023. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18024. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18025. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18026. */
  18027. 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);
  18028. /**
  18029. * Update the url (and optional buffer) of this texture if url was null during construction.
  18030. * @param url the url of the texture
  18031. * @param buffer the buffer of the texture (defaults to null)
  18032. * @param onLoad callback called when the texture is loaded (defaults to null)
  18033. */
  18034. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18035. /**
  18036. * Finish the loading sequence of a texture flagged as delayed load.
  18037. * @hidden
  18038. */
  18039. delayLoad(): void;
  18040. private _prepareRowForTextureGeneration;
  18041. /**
  18042. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18043. * @returns the transform matrix of the texture.
  18044. */
  18045. getTextureMatrix(): Matrix;
  18046. /**
  18047. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18048. * @returns The reflection texture transform
  18049. */
  18050. getReflectionTextureMatrix(): Matrix;
  18051. /**
  18052. * Clones the texture.
  18053. * @returns the cloned texture
  18054. */
  18055. clone(): Texture;
  18056. /**
  18057. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18058. * @returns The JSON representation of the texture
  18059. */
  18060. serialize(): any;
  18061. /**
  18062. * Get the current class name of the texture useful for serialization or dynamic coding.
  18063. * @returns "Texture"
  18064. */
  18065. getClassName(): string;
  18066. /**
  18067. * Dispose the texture and release its associated resources.
  18068. */
  18069. dispose(): void;
  18070. /**
  18071. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18072. * @param parsedTexture Define the JSON representation of the texture
  18073. * @param scene Define the scene the parsed texture should be instantiated in
  18074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18075. * @returns The parsed texture if successful
  18076. */
  18077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18078. /**
  18079. * Creates a texture from its base 64 representation.
  18080. * @param data Define the base64 payload without the data: prefix
  18081. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18082. * @param scene Define the scene the texture should belong to
  18083. * @param noMipmap Forces the texture to not create mip map information if true
  18084. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18085. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18086. * @param onLoad define a callback triggered when the texture has been loaded
  18087. * @param onError define a callback triggered when an error occurred during the loading session
  18088. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18089. * @returns the created texture
  18090. */
  18091. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18092. /**
  18093. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18094. * @param data Define the base64 payload without the data: prefix
  18095. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18097. * @param scene Define the scene the texture should belong to
  18098. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18099. * @param noMipmap Forces the texture to not create mip map information if true
  18100. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18101. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18102. * @param onLoad define a callback triggered when the texture has been loaded
  18103. * @param onError define a callback triggered when an error occurred during the loading session
  18104. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18105. * @returns the created texture
  18106. */
  18107. 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;
  18108. }
  18109. }
  18110. declare module BABYLON {
  18111. interface Engine {
  18112. /**
  18113. * Creates a raw texture
  18114. * @param data defines the data to store in the texture
  18115. * @param width defines the width of the texture
  18116. * @param height defines the height of the texture
  18117. * @param format defines the format of the data
  18118. * @param generateMipMaps defines if the engine should generate the mip levels
  18119. * @param invertY defines if data must be stored with Y axis inverted
  18120. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18121. * @param compression defines the compression used (null by default)
  18122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18123. * @returns the raw texture inside an InternalTexture
  18124. */
  18125. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18126. /**
  18127. * Update a raw texture
  18128. * @param texture defines the texture to update
  18129. * @param data defines the data to store in the texture
  18130. * @param format defines the format of the data
  18131. * @param invertY defines if data must be stored with Y axis inverted
  18132. */
  18133. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18134. /**
  18135. * Update a raw texture
  18136. * @param texture defines the texture to update
  18137. * @param data defines the data to store in the texture
  18138. * @param format defines the format of the data
  18139. * @param invertY defines if data must be stored with Y axis inverted
  18140. * @param compression defines the compression used (null by default)
  18141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18142. */
  18143. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18144. /**
  18145. * Creates a new raw cube texture
  18146. * @param data defines the array of data to use to create each face
  18147. * @param size defines the size of the textures
  18148. * @param format defines the format of the data
  18149. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18150. * @param generateMipMaps defines if the engine should generate the mip levels
  18151. * @param invertY defines if data must be stored with Y axis inverted
  18152. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18153. * @param compression defines the compression used (null by default)
  18154. * @returns the cube texture as an InternalTexture
  18155. */
  18156. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18157. /**
  18158. * Update a raw cube texture
  18159. * @param texture defines the texture to udpdate
  18160. * @param data defines the data to store
  18161. * @param format defines the data format
  18162. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18163. * @param invertY defines if data must be stored with Y axis inverted
  18164. */
  18165. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18166. /**
  18167. * Update a raw cube texture
  18168. * @param texture defines the texture to udpdate
  18169. * @param data defines the data to store
  18170. * @param format defines the data format
  18171. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18172. * @param invertY defines if data must be stored with Y axis inverted
  18173. * @param compression defines the compression used (null by default)
  18174. */
  18175. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18176. /**
  18177. * Update a raw cube texture
  18178. * @param texture defines the texture to udpdate
  18179. * @param data defines the data to store
  18180. * @param format defines the data format
  18181. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18182. * @param invertY defines if data must be stored with Y axis inverted
  18183. * @param compression defines the compression used (null by default)
  18184. * @param level defines which level of the texture to update
  18185. */
  18186. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18187. /**
  18188. * Creates a new raw cube texture from a specified url
  18189. * @param url defines the url where the data is located
  18190. * @param scene defines the current scene
  18191. * @param size defines the size of the textures
  18192. * @param format defines the format of the data
  18193. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18194. * @param noMipmap defines if the engine should avoid generating the mip levels
  18195. * @param callback defines a callback used to extract texture data from loaded data
  18196. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18197. * @param onLoad defines a callback called when texture is loaded
  18198. * @param onError defines a callback called if there is an error
  18199. * @returns the cube texture as an InternalTexture
  18200. */
  18201. 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>): InternalTexture;
  18202. /**
  18203. * Creates a new raw cube texture from a specified url
  18204. * @param url defines the url where the data is located
  18205. * @param scene defines the current scene
  18206. * @param size defines the size of the textures
  18207. * @param format defines the format of the data
  18208. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18209. * @param noMipmap defines if the engine should avoid generating the mip levels
  18210. * @param callback defines a callback used to extract texture data from loaded data
  18211. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18212. * @param onLoad defines a callback called when texture is loaded
  18213. * @param onError defines a callback called if there is an error
  18214. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18215. * @param invertY defines if data must be stored with Y axis inverted
  18216. * @returns the cube texture as an InternalTexture
  18217. */
  18218. 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;
  18219. /**
  18220. * Creates a new raw 3D texture
  18221. * @param data defines the data used to create the texture
  18222. * @param width defines the width of the texture
  18223. * @param height defines the height of the texture
  18224. * @param depth defines the depth of the texture
  18225. * @param format defines the format of the texture
  18226. * @param generateMipMaps defines if the engine must generate mip levels
  18227. * @param invertY defines if data must be stored with Y axis inverted
  18228. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18229. * @param compression defines the compressed used (can be null)
  18230. * @param textureType defines the compressed used (can be null)
  18231. * @returns a new raw 3D texture (stored in an InternalTexture)
  18232. */
  18233. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18234. /**
  18235. * Update a raw 3D texture
  18236. * @param texture defines the texture to update
  18237. * @param data defines the data to store
  18238. * @param format defines the data format
  18239. * @param invertY defines if data must be stored with Y axis inverted
  18240. */
  18241. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18242. /**
  18243. * Update a raw 3D texture
  18244. * @param texture defines the texture to update
  18245. * @param data defines the data to store
  18246. * @param format defines the data format
  18247. * @param invertY defines if data must be stored with Y axis inverted
  18248. * @param compression defines the used compression (can be null)
  18249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18250. */
  18251. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18252. }
  18253. }
  18254. declare module BABYLON {
  18255. /**
  18256. * Raw texture can help creating a texture directly from an array of data.
  18257. * This can be super useful if you either get the data from an uncompressed source or
  18258. * if you wish to create your texture pixel by pixel.
  18259. */
  18260. export class RawTexture extends Texture {
  18261. /**
  18262. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18263. */
  18264. format: number;
  18265. private _engine;
  18266. /**
  18267. * Instantiates a new RawTexture.
  18268. * Raw texture can help creating a texture directly from an array of data.
  18269. * This can be super useful if you either get the data from an uncompressed source or
  18270. * if you wish to create your texture pixel by pixel.
  18271. * @param data define the array of data to use to create the texture
  18272. * @param width define the width of the texture
  18273. * @param height define the height of the texture
  18274. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18275. * @param scene define the scene the texture belongs to
  18276. * @param generateMipMaps define whether mip maps should be generated or not
  18277. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18278. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18279. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18280. */
  18281. constructor(data: ArrayBufferView, width: number, height: number,
  18282. /**
  18283. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18284. */
  18285. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18286. /**
  18287. * Updates the texture underlying data.
  18288. * @param data Define the new data of the texture
  18289. */
  18290. update(data: ArrayBufferView): void;
  18291. /**
  18292. * Creates a luminance texture from some data.
  18293. * @param data Define the texture data
  18294. * @param width Define the width of the texture
  18295. * @param height Define the height of the texture
  18296. * @param scene Define the scene the texture belongs to
  18297. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18298. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18299. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18300. * @returns the luminance texture
  18301. */
  18302. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18303. /**
  18304. * Creates a luminance alpha texture from some data.
  18305. * @param data Define the texture data
  18306. * @param width Define the width of the texture
  18307. * @param height Define the height of the texture
  18308. * @param scene Define the scene the texture belongs to
  18309. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18312. * @returns the luminance alpha texture
  18313. */
  18314. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18315. /**
  18316. * Creates an alpha texture from some data.
  18317. * @param data Define the texture data
  18318. * @param width Define the width of the texture
  18319. * @param height Define the height of the texture
  18320. * @param scene Define the scene the texture belongs to
  18321. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18322. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18323. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18324. * @returns the alpha texture
  18325. */
  18326. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18327. /**
  18328. * Creates a RGB texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18337. * @returns the RGB alpha texture
  18338. */
  18339. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18340. /**
  18341. * Creates a RGBA texture from some data.
  18342. * @param data Define the texture data
  18343. * @param width Define the width of the texture
  18344. * @param height Define the height of the texture
  18345. * @param scene Define the scene the texture belongs to
  18346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18349. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18350. * @returns the RGBA texture
  18351. */
  18352. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18353. /**
  18354. * Creates a R texture from some data.
  18355. * @param data Define the texture data
  18356. * @param width Define the width of the texture
  18357. * @param height Define the height of the texture
  18358. * @param scene Define the scene the texture belongs to
  18359. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18360. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18361. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18362. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18363. * @returns the R texture
  18364. */
  18365. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18366. }
  18367. }
  18368. declare module BABYLON {
  18369. /**
  18370. * Defines a runtime animation
  18371. */
  18372. export class RuntimeAnimation {
  18373. private _events;
  18374. /**
  18375. * The current frame of the runtime animation
  18376. */
  18377. private _currentFrame;
  18378. /**
  18379. * The animation used by the runtime animation
  18380. */
  18381. private _animation;
  18382. /**
  18383. * The target of the runtime animation
  18384. */
  18385. private _target;
  18386. /**
  18387. * The initiating animatable
  18388. */
  18389. private _host;
  18390. /**
  18391. * The original value of the runtime animation
  18392. */
  18393. private _originalValue;
  18394. /**
  18395. * The original blend value of the runtime animation
  18396. */
  18397. private _originalBlendValue;
  18398. /**
  18399. * The offsets cache of the runtime animation
  18400. */
  18401. private _offsetsCache;
  18402. /**
  18403. * The high limits cache of the runtime animation
  18404. */
  18405. private _highLimitsCache;
  18406. /**
  18407. * Specifies if the runtime animation has been stopped
  18408. */
  18409. private _stopped;
  18410. /**
  18411. * The blending factor of the runtime animation
  18412. */
  18413. private _blendingFactor;
  18414. /**
  18415. * The BabylonJS scene
  18416. */
  18417. private _scene;
  18418. /**
  18419. * The current value of the runtime animation
  18420. */
  18421. private _currentValue;
  18422. /** @hidden */ animationState: _IAnimationState;
  18423. /**
  18424. * The active target of the runtime animation
  18425. */
  18426. private _activeTargets;
  18427. private _currentActiveTarget;
  18428. private _directTarget;
  18429. /**
  18430. * The target path of the runtime animation
  18431. */
  18432. private _targetPath;
  18433. /**
  18434. * The weight of the runtime animation
  18435. */
  18436. private _weight;
  18437. /**
  18438. * The ratio offset of the runtime animation
  18439. */
  18440. private _ratioOffset;
  18441. /**
  18442. * The previous delay of the runtime animation
  18443. */
  18444. private _previousDelay;
  18445. /**
  18446. * The previous ratio of the runtime animation
  18447. */
  18448. private _previousRatio;
  18449. private _enableBlending;
  18450. private _keys;
  18451. private _minFrame;
  18452. private _maxFrame;
  18453. private _minValue;
  18454. private _maxValue;
  18455. private _targetIsArray;
  18456. /**
  18457. * Gets the current frame of the runtime animation
  18458. */
  18459. readonly currentFrame: number;
  18460. /**
  18461. * Gets the weight of the runtime animation
  18462. */
  18463. readonly weight: number;
  18464. /**
  18465. * Gets the current value of the runtime animation
  18466. */
  18467. readonly currentValue: any;
  18468. /**
  18469. * Gets the target path of the runtime animation
  18470. */
  18471. readonly targetPath: string;
  18472. /**
  18473. * Gets the actual target of the runtime animation
  18474. */
  18475. readonly target: any;
  18476. /** @hidden */ onLoop: () => void;
  18477. /**
  18478. * Create a new RuntimeAnimation object
  18479. * @param target defines the target of the animation
  18480. * @param animation defines the source animation object
  18481. * @param scene defines the hosting scene
  18482. * @param host defines the initiating Animatable
  18483. */
  18484. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18485. private _preparePath;
  18486. /**
  18487. * Gets the animation from the runtime animation
  18488. */
  18489. readonly animation: Animation;
  18490. /**
  18491. * Resets the runtime animation to the beginning
  18492. * @param restoreOriginal defines whether to restore the target property to the original value
  18493. */
  18494. reset(restoreOriginal?: boolean): void;
  18495. /**
  18496. * Specifies if the runtime animation is stopped
  18497. * @returns Boolean specifying if the runtime animation is stopped
  18498. */
  18499. isStopped(): boolean;
  18500. /**
  18501. * Disposes of the runtime animation
  18502. */
  18503. dispose(): void;
  18504. /**
  18505. * Apply the interpolated value to the target
  18506. * @param currentValue defines the value computed by the animation
  18507. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18508. */
  18509. setValue(currentValue: any, weight: number): void;
  18510. private _getOriginalValues;
  18511. private _setValue;
  18512. /**
  18513. * Gets the loop pmode of the runtime animation
  18514. * @returns Loop Mode
  18515. */
  18516. private _getCorrectLoopMode;
  18517. /**
  18518. * Move the current animation to a given frame
  18519. * @param frame defines the frame to move to
  18520. */
  18521. goToFrame(frame: number): void;
  18522. /**
  18523. * @hidden Internal use only
  18524. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18525. /**
  18526. * Execute the current animation
  18527. * @param delay defines the delay to add to the current frame
  18528. * @param from defines the lower bound of the animation range
  18529. * @param to defines the upper bound of the animation range
  18530. * @param loop defines if the current animation must loop
  18531. * @param speedRatio defines the current speed ratio
  18532. * @param weight defines the weight of the animation (default is -1 so no weight)
  18533. * @param onLoop optional callback called when animation loops
  18534. * @returns a boolean indicating if the animation is running
  18535. */
  18536. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18537. }
  18538. }
  18539. declare module BABYLON {
  18540. /**
  18541. * Class used to store an actual running animation
  18542. */
  18543. export class Animatable {
  18544. /** defines the target object */
  18545. target: any;
  18546. /** defines the starting frame number (default is 0) */
  18547. fromFrame: number;
  18548. /** defines the ending frame number (default is 100) */
  18549. toFrame: number;
  18550. /** defines if the animation must loop (default is false) */
  18551. loopAnimation: boolean;
  18552. /** defines a callback to call when animation ends if it is not looping */
  18553. onAnimationEnd?: (() => void) | null | undefined;
  18554. /** defines a callback to call when animation loops */
  18555. onAnimationLoop?: (() => void) | null | undefined;
  18556. private _localDelayOffset;
  18557. private _pausedDelay;
  18558. private _runtimeAnimations;
  18559. private _paused;
  18560. private _scene;
  18561. private _speedRatio;
  18562. private _weight;
  18563. private _syncRoot;
  18564. /**
  18565. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18566. * This will only apply for non looping animation (default is true)
  18567. */
  18568. disposeOnEnd: boolean;
  18569. /**
  18570. * Gets a boolean indicating if the animation has started
  18571. */
  18572. animationStarted: boolean;
  18573. /**
  18574. * Observer raised when the animation ends
  18575. */
  18576. onAnimationEndObservable: Observable<Animatable>;
  18577. /**
  18578. * Observer raised when the animation loops
  18579. */
  18580. onAnimationLoopObservable: Observable<Animatable>;
  18581. /**
  18582. * Gets the root Animatable used to synchronize and normalize animations
  18583. */
  18584. readonly syncRoot: Nullable<Animatable>;
  18585. /**
  18586. * Gets the current frame of the first RuntimeAnimation
  18587. * Used to synchronize Animatables
  18588. */
  18589. readonly masterFrame: number;
  18590. /**
  18591. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18592. */
  18593. weight: number;
  18594. /**
  18595. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18596. */
  18597. speedRatio: number;
  18598. /**
  18599. * Creates a new Animatable
  18600. * @param scene defines the hosting scene
  18601. * @param target defines the target object
  18602. * @param fromFrame defines the starting frame number (default is 0)
  18603. * @param toFrame defines the ending frame number (default is 100)
  18604. * @param loopAnimation defines if the animation must loop (default is false)
  18605. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18606. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18607. * @param animations defines a group of animation to add to the new Animatable
  18608. * @param onAnimationLoop defines a callback to call when animation loops
  18609. */
  18610. constructor(scene: Scene,
  18611. /** defines the target object */
  18612. target: any,
  18613. /** defines the starting frame number (default is 0) */
  18614. fromFrame?: number,
  18615. /** defines the ending frame number (default is 100) */
  18616. toFrame?: number,
  18617. /** defines if the animation must loop (default is false) */
  18618. loopAnimation?: boolean, speedRatio?: number,
  18619. /** defines a callback to call when animation ends if it is not looping */
  18620. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18621. /** defines a callback to call when animation loops */
  18622. onAnimationLoop?: (() => void) | null | undefined);
  18623. /**
  18624. * Synchronize and normalize current Animatable with a source Animatable
  18625. * This is useful when using animation weights and when animations are not of the same length
  18626. * @param root defines the root Animatable to synchronize with
  18627. * @returns the current Animatable
  18628. */
  18629. syncWith(root: Animatable): Animatable;
  18630. /**
  18631. * Gets the list of runtime animations
  18632. * @returns an array of RuntimeAnimation
  18633. */
  18634. getAnimations(): RuntimeAnimation[];
  18635. /**
  18636. * Adds more animations to the current animatable
  18637. * @param target defines the target of the animations
  18638. * @param animations defines the new animations to add
  18639. */
  18640. appendAnimations(target: any, animations: Animation[]): void;
  18641. /**
  18642. * Gets the source animation for a specific property
  18643. * @param property defines the propertyu to look for
  18644. * @returns null or the source animation for the given property
  18645. */
  18646. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18647. /**
  18648. * Gets the runtime animation for a specific property
  18649. * @param property defines the propertyu to look for
  18650. * @returns null or the runtime animation for the given property
  18651. */
  18652. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18653. /**
  18654. * Resets the animatable to its original state
  18655. */
  18656. reset(): void;
  18657. /**
  18658. * Allows the animatable to blend with current running animations
  18659. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18660. * @param blendingSpeed defines the blending speed to use
  18661. */
  18662. enableBlending(blendingSpeed: number): void;
  18663. /**
  18664. * Disable animation blending
  18665. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18666. */
  18667. disableBlending(): void;
  18668. /**
  18669. * Jump directly to a given frame
  18670. * @param frame defines the frame to jump to
  18671. */
  18672. goToFrame(frame: number): void;
  18673. /**
  18674. * Pause the animation
  18675. */
  18676. pause(): void;
  18677. /**
  18678. * Restart the animation
  18679. */
  18680. restart(): void;
  18681. private _raiseOnAnimationEnd;
  18682. /**
  18683. * Stop and delete the current animation
  18684. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18685. * @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)
  18686. */
  18687. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18688. /**
  18689. * Wait asynchronously for the animation to end
  18690. * @returns a promise which will be fullfilled when the animation ends
  18691. */
  18692. waitAsync(): Promise<Animatable>;
  18693. /** @hidden */ animate(delay: number): boolean;
  18694. }
  18695. interface Scene {
  18696. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18697. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18698. totalWeight: number;
  18699. animations: RuntimeAnimation[];
  18700. originalValue: Matrix;
  18701. }): any;
  18702. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18703. totalWeight: number;
  18704. animations: RuntimeAnimation[];
  18705. originalValue: Quaternion;
  18706. }, refQuaternion: Quaternion): Quaternion;
  18707. /** @hidden */ processLateAnimationBindings(): void;
  18708. /**
  18709. * Will start the animation sequence of a given target
  18710. * @param target defines the target
  18711. * @param from defines from which frame should animation start
  18712. * @param to defines until which frame should animation run.
  18713. * @param weight defines the weight to apply to the animation (1.0 by default)
  18714. * @param loop defines if the animation loops
  18715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18716. * @param onAnimationEnd defines the function to be executed when the animation ends
  18717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18718. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18719. * @param onAnimationLoop defines the callback to call when an animation loops
  18720. * @returns the animatable object created for this animation
  18721. */
  18722. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18723. /**
  18724. * Will start the animation sequence of a given target
  18725. * @param target defines the target
  18726. * @param from defines from which frame should animation start
  18727. * @param to defines until which frame should animation run.
  18728. * @param loop defines if the animation loops
  18729. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18730. * @param onAnimationEnd defines the function to be executed when the animation ends
  18731. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18732. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18733. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18734. * @param onAnimationLoop defines the callback to call when an animation loops
  18735. * @returns the animatable object created for this animation
  18736. */
  18737. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18738. /**
  18739. * Will start the animation sequence of a given target and its hierarchy
  18740. * @param target defines the target
  18741. * @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.
  18742. * @param from defines from which frame should animation start
  18743. * @param to defines until which frame should animation run.
  18744. * @param loop defines if the animation loops
  18745. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18746. * @param onAnimationEnd defines the function to be executed when the animation ends
  18747. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18748. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18749. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18750. * @param onAnimationLoop defines the callback to call when an animation loops
  18751. * @returns the list of created animatables
  18752. */
  18753. 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[];
  18754. /**
  18755. * Begin a new animation on a given node
  18756. * @param target defines the target where the animation will take place
  18757. * @param animations defines the list of animations to start
  18758. * @param from defines the initial value
  18759. * @param to defines the final value
  18760. * @param loop defines if you want animation to loop (off by default)
  18761. * @param speedRatio defines the speed ratio to apply to all animations
  18762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18763. * @param onAnimationLoop defines the callback to call when an animation loops
  18764. * @returns the list of created animatables
  18765. */
  18766. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18767. /**
  18768. * Begin a new animation on a given node and its hierarchy
  18769. * @param target defines the root node where the animation will take place
  18770. * @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.
  18771. * @param animations defines the list of animations to start
  18772. * @param from defines the initial value
  18773. * @param to defines the final value
  18774. * @param loop defines if you want animation to loop (off by default)
  18775. * @param speedRatio defines the speed ratio to apply to all animations
  18776. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18777. * @param onAnimationLoop defines the callback to call when an animation loops
  18778. * @returns the list of animatables created for all nodes
  18779. */
  18780. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18781. /**
  18782. * Gets the animatable associated with a specific target
  18783. * @param target defines the target of the animatable
  18784. * @returns the required animatable if found
  18785. */
  18786. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18787. /**
  18788. * Gets all animatables associated with a given target
  18789. * @param target defines the target to look animatables for
  18790. * @returns an array of Animatables
  18791. */
  18792. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18793. /**
  18794. * Will stop the animation of the given target
  18795. * @param target - the target
  18796. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18797. * @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)
  18798. */
  18799. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18800. /**
  18801. * Stops and removes all animations that have been applied to the scene
  18802. */
  18803. stopAllAnimations(): void;
  18804. }
  18805. interface Bone {
  18806. /**
  18807. * Copy an animation range from another bone
  18808. * @param source defines the source bone
  18809. * @param rangeName defines the range name to copy
  18810. * @param frameOffset defines the frame offset
  18811. * @param rescaleAsRequired defines if rescaling must be applied if required
  18812. * @param skelDimensionsRatio defines the scaling ratio
  18813. * @returns true if operation was successful
  18814. */
  18815. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18816. }
  18817. }
  18818. declare module BABYLON {
  18819. /**
  18820. * Class used to handle skinning animations
  18821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18822. */
  18823. export class Skeleton implements IAnimatable {
  18824. /** defines the skeleton name */
  18825. name: string;
  18826. /** defines the skeleton Id */
  18827. id: string;
  18828. /**
  18829. * Defines the list of child bones
  18830. */
  18831. bones: Bone[];
  18832. /**
  18833. * Defines an estimate of the dimension of the skeleton at rest
  18834. */
  18835. dimensionsAtRest: Vector3;
  18836. /**
  18837. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18838. */
  18839. needInitialSkinMatrix: boolean;
  18840. /**
  18841. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18842. */
  18843. overrideMesh: Nullable<AbstractMesh>;
  18844. /**
  18845. * Gets the list of animations attached to this skeleton
  18846. */
  18847. animations: Array<Animation>;
  18848. private _scene;
  18849. private _isDirty;
  18850. private _transformMatrices;
  18851. private _transformMatrixTexture;
  18852. private _meshesWithPoseMatrix;
  18853. private _animatables;
  18854. private _identity;
  18855. private _synchronizedWithMesh;
  18856. private _ranges;
  18857. private _lastAbsoluteTransformsUpdateId;
  18858. private _canUseTextureForBones;
  18859. private _uniqueId;
  18860. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18861. /**
  18862. * Specifies if the skeleton should be serialized
  18863. */
  18864. doNotSerialize: boolean;
  18865. private _useTextureToStoreBoneMatrices;
  18866. /**
  18867. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18868. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18869. */
  18870. useTextureToStoreBoneMatrices: boolean;
  18871. private _animationPropertiesOverride;
  18872. /**
  18873. * Gets or sets the animation properties override
  18874. */
  18875. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18876. /**
  18877. * List of inspectable custom properties (used by the Inspector)
  18878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18879. */
  18880. inspectableCustomProperties: IInspectable[];
  18881. /**
  18882. * An observable triggered before computing the skeleton's matrices
  18883. */
  18884. onBeforeComputeObservable: Observable<Skeleton>;
  18885. /**
  18886. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18887. */
  18888. readonly isUsingTextureForMatrices: boolean;
  18889. /**
  18890. * Gets the unique ID of this skeleton
  18891. */
  18892. readonly uniqueId: number;
  18893. /**
  18894. * Creates a new skeleton
  18895. * @param name defines the skeleton name
  18896. * @param id defines the skeleton Id
  18897. * @param scene defines the hosting scene
  18898. */
  18899. constructor(
  18900. /** defines the skeleton name */
  18901. name: string,
  18902. /** defines the skeleton Id */
  18903. id: string, scene: Scene);
  18904. /**
  18905. * Gets the current object class name.
  18906. * @return the class name
  18907. */
  18908. getClassName(): string;
  18909. /**
  18910. * Returns an array containing the root bones
  18911. * @returns an array containing the root bones
  18912. */
  18913. getChildren(): Array<Bone>;
  18914. /**
  18915. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18916. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18917. * @returns a Float32Array containing matrices data
  18918. */
  18919. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18920. /**
  18921. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18922. * @returns a raw texture containing the data
  18923. */
  18924. getTransformMatrixTexture(): Nullable<RawTexture>;
  18925. /**
  18926. * Gets the current hosting scene
  18927. * @returns a scene object
  18928. */
  18929. getScene(): Scene;
  18930. /**
  18931. * Gets a string representing the current skeleton data
  18932. * @param fullDetails defines a boolean indicating if we want a verbose version
  18933. * @returns a string representing the current skeleton data
  18934. */
  18935. toString(fullDetails?: boolean): string;
  18936. /**
  18937. * Get bone's index searching by name
  18938. * @param name defines bone's name to search for
  18939. * @return the indice of the bone. Returns -1 if not found
  18940. */
  18941. getBoneIndexByName(name: string): number;
  18942. /**
  18943. * Creater a new animation range
  18944. * @param name defines the name of the range
  18945. * @param from defines the start key
  18946. * @param to defines the end key
  18947. */
  18948. createAnimationRange(name: string, from: number, to: number): void;
  18949. /**
  18950. * Delete a specific animation range
  18951. * @param name defines the name of the range
  18952. * @param deleteFrames defines if frames must be removed as well
  18953. */
  18954. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18955. /**
  18956. * Gets a specific animation range
  18957. * @param name defines the name of the range to look for
  18958. * @returns the requested animation range or null if not found
  18959. */
  18960. getAnimationRange(name: string): Nullable<AnimationRange>;
  18961. /**
  18962. * Gets the list of all animation ranges defined on this skeleton
  18963. * @returns an array
  18964. */
  18965. getAnimationRanges(): Nullable<AnimationRange>[];
  18966. /**
  18967. * Copy animation range from a source skeleton.
  18968. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18969. * @param source defines the source skeleton
  18970. * @param name defines the name of the range to copy
  18971. * @param rescaleAsRequired defines if rescaling must be applied if required
  18972. * @returns true if operation was successful
  18973. */
  18974. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18975. /**
  18976. * Forces the skeleton to go to rest pose
  18977. */
  18978. returnToRest(): void;
  18979. private _getHighestAnimationFrame;
  18980. /**
  18981. * Begin a specific animation range
  18982. * @param name defines the name of the range to start
  18983. * @param loop defines if looping must be turned on (false by default)
  18984. * @param speedRatio defines the speed ratio to apply (1 by default)
  18985. * @param onAnimationEnd defines a callback which will be called when animation will end
  18986. * @returns a new animatable
  18987. */
  18988. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18989. /** @hidden */ markAsDirty(): void;
  18990. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18991. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18992. private _computeTransformMatrices;
  18993. /**
  18994. * Build all resources required to render a skeleton
  18995. */
  18996. prepare(): void;
  18997. /**
  18998. * Gets the list of animatables currently running for this skeleton
  18999. * @returns an array of animatables
  19000. */
  19001. getAnimatables(): IAnimatable[];
  19002. /**
  19003. * Clone the current skeleton
  19004. * @param name defines the name of the new skeleton
  19005. * @param id defines the id of the new skeleton
  19006. * @returns the new skeleton
  19007. */
  19008. clone(name: string, id: string): Skeleton;
  19009. /**
  19010. * Enable animation blending for this skeleton
  19011. * @param blendingSpeed defines the blending speed to apply
  19012. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19013. */
  19014. enableBlending(blendingSpeed?: number): void;
  19015. /**
  19016. * Releases all resources associated with the current skeleton
  19017. */
  19018. dispose(): void;
  19019. /**
  19020. * Serialize the skeleton in a JSON object
  19021. * @returns a JSON object
  19022. */
  19023. serialize(): any;
  19024. /**
  19025. * Creates a new skeleton from serialized data
  19026. * @param parsedSkeleton defines the serialized data
  19027. * @param scene defines the hosting scene
  19028. * @returns a new skeleton
  19029. */
  19030. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19031. /**
  19032. * Compute all node absolute transforms
  19033. * @param forceUpdate defines if computation must be done even if cache is up to date
  19034. */
  19035. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19036. /**
  19037. * Gets the root pose matrix
  19038. * @returns a matrix
  19039. */
  19040. getPoseMatrix(): Nullable<Matrix>;
  19041. /**
  19042. * Sorts bones per internal index
  19043. */
  19044. sortBones(): void;
  19045. private _sortBones;
  19046. }
  19047. }
  19048. declare module BABYLON {
  19049. /**
  19050. * Defines a target to use with MorphTargetManager
  19051. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19052. */
  19053. export class MorphTarget implements IAnimatable {
  19054. /** defines the name of the target */
  19055. name: string;
  19056. /**
  19057. * Gets or sets the list of animations
  19058. */
  19059. animations: Animation[];
  19060. private _scene;
  19061. private _positions;
  19062. private _normals;
  19063. private _tangents;
  19064. private _influence;
  19065. /**
  19066. * Observable raised when the influence changes
  19067. */
  19068. onInfluenceChanged: Observable<boolean>;
  19069. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19070. /**
  19071. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19072. */
  19073. influence: number;
  19074. /**
  19075. * Gets or sets the id of the morph Target
  19076. */
  19077. id: string;
  19078. private _animationPropertiesOverride;
  19079. /**
  19080. * Gets or sets the animation properties override
  19081. */
  19082. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19083. /**
  19084. * Creates a new MorphTarget
  19085. * @param name defines the name of the target
  19086. * @param influence defines the influence to use
  19087. * @param scene defines the scene the morphtarget belongs to
  19088. */
  19089. constructor(
  19090. /** defines the name of the target */
  19091. name: string, influence?: number, scene?: Nullable<Scene>);
  19092. /**
  19093. * Gets a boolean defining if the target contains position data
  19094. */
  19095. readonly hasPositions: boolean;
  19096. /**
  19097. * Gets a boolean defining if the target contains normal data
  19098. */
  19099. readonly hasNormals: boolean;
  19100. /**
  19101. * Gets a boolean defining if the target contains tangent data
  19102. */
  19103. readonly hasTangents: boolean;
  19104. /**
  19105. * Affects position data to this target
  19106. * @param data defines the position data to use
  19107. */
  19108. setPositions(data: Nullable<FloatArray>): void;
  19109. /**
  19110. * Gets the position data stored in this target
  19111. * @returns a FloatArray containing the position data (or null if not present)
  19112. */
  19113. getPositions(): Nullable<FloatArray>;
  19114. /**
  19115. * Affects normal data to this target
  19116. * @param data defines the normal data to use
  19117. */
  19118. setNormals(data: Nullable<FloatArray>): void;
  19119. /**
  19120. * Gets the normal data stored in this target
  19121. * @returns a FloatArray containing the normal data (or null if not present)
  19122. */
  19123. getNormals(): Nullable<FloatArray>;
  19124. /**
  19125. * Affects tangent data to this target
  19126. * @param data defines the tangent data to use
  19127. */
  19128. setTangents(data: Nullable<FloatArray>): void;
  19129. /**
  19130. * Gets the tangent data stored in this target
  19131. * @returns a FloatArray containing the tangent data (or null if not present)
  19132. */
  19133. getTangents(): Nullable<FloatArray>;
  19134. /**
  19135. * Serializes the current target into a Serialization object
  19136. * @returns the serialized object
  19137. */
  19138. serialize(): any;
  19139. /**
  19140. * Returns the string "MorphTarget"
  19141. * @returns "MorphTarget"
  19142. */
  19143. getClassName(): string;
  19144. /**
  19145. * Creates a new target from serialized data
  19146. * @param serializationObject defines the serialized data to use
  19147. * @returns a new MorphTarget
  19148. */
  19149. static Parse(serializationObject: any): MorphTarget;
  19150. /**
  19151. * Creates a MorphTarget from mesh data
  19152. * @param mesh defines the source mesh
  19153. * @param name defines the name to use for the new target
  19154. * @param influence defines the influence to attach to the target
  19155. * @returns a new MorphTarget
  19156. */
  19157. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19158. }
  19159. }
  19160. declare module BABYLON {
  19161. /**
  19162. * This class is used to deform meshes using morphing between different targets
  19163. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19164. */
  19165. export class MorphTargetManager {
  19166. private _targets;
  19167. private _targetInfluenceChangedObservers;
  19168. private _targetDataLayoutChangedObservers;
  19169. private _activeTargets;
  19170. private _scene;
  19171. private _influences;
  19172. private _supportsNormals;
  19173. private _supportsTangents;
  19174. private _vertexCount;
  19175. private _uniqueId;
  19176. private _tempInfluences;
  19177. /**
  19178. * Creates a new MorphTargetManager
  19179. * @param scene defines the current scene
  19180. */
  19181. constructor(scene?: Nullable<Scene>);
  19182. /**
  19183. * Gets the unique ID of this manager
  19184. */
  19185. readonly uniqueId: number;
  19186. /**
  19187. * Gets the number of vertices handled by this manager
  19188. */
  19189. readonly vertexCount: number;
  19190. /**
  19191. * Gets a boolean indicating if this manager supports morphing of normals
  19192. */
  19193. readonly supportsNormals: boolean;
  19194. /**
  19195. * Gets a boolean indicating if this manager supports morphing of tangents
  19196. */
  19197. readonly supportsTangents: boolean;
  19198. /**
  19199. * Gets the number of targets stored in this manager
  19200. */
  19201. readonly numTargets: number;
  19202. /**
  19203. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19204. */
  19205. readonly numInfluencers: number;
  19206. /**
  19207. * Gets the list of influences (one per target)
  19208. */
  19209. readonly influences: Float32Array;
  19210. /**
  19211. * Gets the active target at specified index. An active target is a target with an influence > 0
  19212. * @param index defines the index to check
  19213. * @returns the requested target
  19214. */
  19215. getActiveTarget(index: number): MorphTarget;
  19216. /**
  19217. * Gets the target at specified index
  19218. * @param index defines the index to check
  19219. * @returns the requested target
  19220. */
  19221. getTarget(index: number): MorphTarget;
  19222. /**
  19223. * Add a new target to this manager
  19224. * @param target defines the target to add
  19225. */
  19226. addTarget(target: MorphTarget): void;
  19227. /**
  19228. * Removes a target from the manager
  19229. * @param target defines the target to remove
  19230. */
  19231. removeTarget(target: MorphTarget): void;
  19232. /**
  19233. * Serializes the current manager into a Serialization object
  19234. * @returns the serialized object
  19235. */
  19236. serialize(): any;
  19237. private _syncActiveTargets;
  19238. /**
  19239. * Syncrhonize the targets with all the meshes using this morph target manager
  19240. */
  19241. synchronize(): void;
  19242. /**
  19243. * Creates a new MorphTargetManager from serialized data
  19244. * @param serializationObject defines the serialized data
  19245. * @param scene defines the hosting scene
  19246. * @returns the new MorphTargetManager
  19247. */
  19248. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19249. }
  19250. }
  19251. declare module BABYLON {
  19252. /**
  19253. * Class used to represent a specific level of detail of a mesh
  19254. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19255. */
  19256. export class MeshLODLevel {
  19257. /** Defines the distance where this level should star being displayed */
  19258. distance: number;
  19259. /** Defines the mesh to use to render this level */
  19260. mesh: Nullable<Mesh>;
  19261. /**
  19262. * Creates a new LOD level
  19263. * @param distance defines the distance where this level should star being displayed
  19264. * @param mesh defines the mesh to use to render this level
  19265. */
  19266. constructor(
  19267. /** Defines the distance where this level should star being displayed */
  19268. distance: number,
  19269. /** Defines the mesh to use to render this level */
  19270. mesh: Nullable<Mesh>);
  19271. }
  19272. }
  19273. declare module BABYLON {
  19274. /**
  19275. * Mesh representing the gorund
  19276. */
  19277. export class GroundMesh extends Mesh {
  19278. /** If octree should be generated */
  19279. generateOctree: boolean;
  19280. private _heightQuads;
  19281. /** @hidden */ subdivisionsX: number;
  19282. /** @hidden */ subdivisionsY: number;
  19283. /** @hidden */ width: number;
  19284. /** @hidden */ height: number;
  19285. /** @hidden */ minX: number;
  19286. /** @hidden */ maxX: number;
  19287. /** @hidden */ minZ: number;
  19288. /** @hidden */ maxZ: number;
  19289. constructor(name: string, scene: Scene);
  19290. /**
  19291. * "GroundMesh"
  19292. * @returns "GroundMesh"
  19293. */
  19294. getClassName(): string;
  19295. /**
  19296. * The minimum of x and y subdivisions
  19297. */
  19298. readonly subdivisions: number;
  19299. /**
  19300. * X subdivisions
  19301. */
  19302. readonly subdivisionsX: number;
  19303. /**
  19304. * Y subdivisions
  19305. */
  19306. readonly subdivisionsY: number;
  19307. /**
  19308. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19309. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19310. * @param chunksCount the number of subdivisions for x and y
  19311. * @param octreeBlocksSize (Default: 32)
  19312. */
  19313. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19314. /**
  19315. * Returns a height (y) value in the Worl system :
  19316. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19317. * @param x x coordinate
  19318. * @param z z coordinate
  19319. * @returns the ground y position if (x, z) are outside the ground surface.
  19320. */
  19321. getHeightAtCoordinates(x: number, z: number): number;
  19322. /**
  19323. * Returns a normalized vector (Vector3) orthogonal to the ground
  19324. * at the ground coordinates (x, z) expressed in the World system.
  19325. * @param x x coordinate
  19326. * @param z z coordinate
  19327. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19328. */
  19329. getNormalAtCoordinates(x: number, z: number): Vector3;
  19330. /**
  19331. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19332. * at the ground coordinates (x, z) expressed in the World system.
  19333. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19334. * @param x x coordinate
  19335. * @param z z coordinate
  19336. * @param ref vector to store the result
  19337. * @returns the GroundMesh.
  19338. */
  19339. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19340. /**
  19341. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19342. * if the ground has been updated.
  19343. * This can be used in the render loop.
  19344. * @returns the GroundMesh.
  19345. */
  19346. updateCoordinateHeights(): GroundMesh;
  19347. private _getFacetAt;
  19348. private _initHeightQuads;
  19349. private _computeHeightQuads;
  19350. /**
  19351. * Serializes this ground mesh
  19352. * @param serializationObject object to write serialization to
  19353. */
  19354. serialize(serializationObject: any): void;
  19355. /**
  19356. * Parses a serialized ground mesh
  19357. * @param parsedMesh the serialized mesh
  19358. * @param scene the scene to create the ground mesh in
  19359. * @returns the created ground mesh
  19360. */
  19361. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19362. }
  19363. }
  19364. declare module BABYLON {
  19365. /**
  19366. * Interface for Physics-Joint data
  19367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19368. */
  19369. export interface PhysicsJointData {
  19370. /**
  19371. * The main pivot of the joint
  19372. */
  19373. mainPivot?: Vector3;
  19374. /**
  19375. * The connected pivot of the joint
  19376. */
  19377. connectedPivot?: Vector3;
  19378. /**
  19379. * The main axis of the joint
  19380. */
  19381. mainAxis?: Vector3;
  19382. /**
  19383. * The connected axis of the joint
  19384. */
  19385. connectedAxis?: Vector3;
  19386. /**
  19387. * The collision of the joint
  19388. */
  19389. collision?: boolean;
  19390. /**
  19391. * Native Oimo/Cannon/Energy data
  19392. */
  19393. nativeParams?: any;
  19394. }
  19395. /**
  19396. * This is a holder class for the physics joint created by the physics plugin
  19397. * It holds a set of functions to control the underlying joint
  19398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19399. */
  19400. export class PhysicsJoint {
  19401. /**
  19402. * The type of the physics joint
  19403. */
  19404. type: number;
  19405. /**
  19406. * The data for the physics joint
  19407. */
  19408. jointData: PhysicsJointData;
  19409. private _physicsJoint;
  19410. protected _physicsPlugin: IPhysicsEnginePlugin;
  19411. /**
  19412. * Initializes the physics joint
  19413. * @param type The type of the physics joint
  19414. * @param jointData The data for the physics joint
  19415. */
  19416. constructor(
  19417. /**
  19418. * The type of the physics joint
  19419. */
  19420. type: number,
  19421. /**
  19422. * The data for the physics joint
  19423. */
  19424. jointData: PhysicsJointData);
  19425. /**
  19426. * Gets the physics joint
  19427. */
  19428. /**
  19429. * Sets the physics joint
  19430. */
  19431. physicsJoint: any;
  19432. /**
  19433. * Sets the physics plugin
  19434. */
  19435. physicsPlugin: IPhysicsEnginePlugin;
  19436. /**
  19437. * Execute a function that is physics-plugin specific.
  19438. * @param {Function} func the function that will be executed.
  19439. * It accepts two parameters: the physics world and the physics joint
  19440. */
  19441. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19442. /**
  19443. * Distance-Joint type
  19444. */
  19445. static DistanceJoint: number;
  19446. /**
  19447. * Hinge-Joint type
  19448. */
  19449. static HingeJoint: number;
  19450. /**
  19451. * Ball-and-Socket joint type
  19452. */
  19453. static BallAndSocketJoint: number;
  19454. /**
  19455. * Wheel-Joint type
  19456. */
  19457. static WheelJoint: number;
  19458. /**
  19459. * Slider-Joint type
  19460. */
  19461. static SliderJoint: number;
  19462. /**
  19463. * Prismatic-Joint type
  19464. */
  19465. static PrismaticJoint: number;
  19466. /**
  19467. * Universal-Joint type
  19468. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19469. */
  19470. static UniversalJoint: number;
  19471. /**
  19472. * Hinge-Joint 2 type
  19473. */
  19474. static Hinge2Joint: number;
  19475. /**
  19476. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19477. */
  19478. static PointToPointJoint: number;
  19479. /**
  19480. * Spring-Joint type
  19481. */
  19482. static SpringJoint: number;
  19483. /**
  19484. * Lock-Joint type
  19485. */
  19486. static LockJoint: number;
  19487. }
  19488. /**
  19489. * A class representing a physics distance joint
  19490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19491. */
  19492. export class DistanceJoint extends PhysicsJoint {
  19493. /**
  19494. *
  19495. * @param jointData The data for the Distance-Joint
  19496. */
  19497. constructor(jointData: DistanceJointData);
  19498. /**
  19499. * Update the predefined distance.
  19500. * @param maxDistance The maximum preferred distance
  19501. * @param minDistance The minimum preferred distance
  19502. */
  19503. updateDistance(maxDistance: number, minDistance?: number): void;
  19504. }
  19505. /**
  19506. * Represents a Motor-Enabled Joint
  19507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19508. */
  19509. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19510. /**
  19511. * Initializes the Motor-Enabled Joint
  19512. * @param type The type of the joint
  19513. * @param jointData The physica joint data for the joint
  19514. */
  19515. constructor(type: number, jointData: PhysicsJointData);
  19516. /**
  19517. * Set the motor values.
  19518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19519. * @param force the force to apply
  19520. * @param maxForce max force for this motor.
  19521. */
  19522. setMotor(force?: number, maxForce?: number): void;
  19523. /**
  19524. * Set the motor's limits.
  19525. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19526. * @param upperLimit The upper limit of the motor
  19527. * @param lowerLimit The lower limit of the motor
  19528. */
  19529. setLimit(upperLimit: number, lowerLimit?: number): void;
  19530. }
  19531. /**
  19532. * This class represents a single physics Hinge-Joint
  19533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19534. */
  19535. export class HingeJoint extends MotorEnabledJoint {
  19536. /**
  19537. * Initializes the Hinge-Joint
  19538. * @param jointData The joint data for the Hinge-Joint
  19539. */
  19540. constructor(jointData: PhysicsJointData);
  19541. /**
  19542. * Set the motor values.
  19543. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19544. * @param {number} force the force to apply
  19545. * @param {number} maxForce max force for this motor.
  19546. */
  19547. setMotor(force?: number, maxForce?: number): void;
  19548. /**
  19549. * Set the motor's limits.
  19550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19551. * @param upperLimit The upper limit of the motor
  19552. * @param lowerLimit The lower limit of the motor
  19553. */
  19554. setLimit(upperLimit: number, lowerLimit?: number): void;
  19555. }
  19556. /**
  19557. * This class represents a dual hinge physics joint (same as wheel joint)
  19558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19559. */
  19560. export class Hinge2Joint extends MotorEnabledJoint {
  19561. /**
  19562. * Initializes the Hinge2-Joint
  19563. * @param jointData The joint data for the Hinge2-Joint
  19564. */
  19565. constructor(jointData: PhysicsJointData);
  19566. /**
  19567. * Set the motor values.
  19568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19569. * @param {number} targetSpeed the speed the motor is to reach
  19570. * @param {number} maxForce max force for this motor.
  19571. * @param {motorIndex} the motor's index, 0 or 1.
  19572. */
  19573. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19574. /**
  19575. * Set the motor limits.
  19576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19577. * @param {number} upperLimit the upper limit
  19578. * @param {number} lowerLimit lower limit
  19579. * @param {motorIndex} the motor's index, 0 or 1.
  19580. */
  19581. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19582. }
  19583. /**
  19584. * Interface for a motor enabled joint
  19585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19586. */
  19587. export interface IMotorEnabledJoint {
  19588. /**
  19589. * Physics joint
  19590. */
  19591. physicsJoint: any;
  19592. /**
  19593. * Sets the motor of the motor-enabled joint
  19594. * @param force The force of the motor
  19595. * @param maxForce The maximum force of the motor
  19596. * @param motorIndex The index of the motor
  19597. */
  19598. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19599. /**
  19600. * Sets the limit of the motor
  19601. * @param upperLimit The upper limit of the motor
  19602. * @param lowerLimit The lower limit of the motor
  19603. * @param motorIndex The index of the motor
  19604. */
  19605. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19606. }
  19607. /**
  19608. * Joint data for a Distance-Joint
  19609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19610. */
  19611. export interface DistanceJointData extends PhysicsJointData {
  19612. /**
  19613. * Max distance the 2 joint objects can be apart
  19614. */
  19615. maxDistance: number;
  19616. }
  19617. /**
  19618. * Joint data from a spring joint
  19619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19620. */
  19621. export interface SpringJointData extends PhysicsJointData {
  19622. /**
  19623. * Length of the spring
  19624. */
  19625. length: number;
  19626. /**
  19627. * Stiffness of the spring
  19628. */
  19629. stiffness: number;
  19630. /**
  19631. * Damping of the spring
  19632. */
  19633. damping: number;
  19634. /** this callback will be called when applying the force to the impostors. */
  19635. forceApplicationCallback: () => void;
  19636. }
  19637. }
  19638. declare module BABYLON {
  19639. /**
  19640. * Holds the data for the raycast result
  19641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19642. */
  19643. export class PhysicsRaycastResult {
  19644. private _hasHit;
  19645. private _hitDistance;
  19646. private _hitNormalWorld;
  19647. private _hitPointWorld;
  19648. private _rayFromWorld;
  19649. private _rayToWorld;
  19650. /**
  19651. * Gets if there was a hit
  19652. */
  19653. readonly hasHit: boolean;
  19654. /**
  19655. * Gets the distance from the hit
  19656. */
  19657. readonly hitDistance: number;
  19658. /**
  19659. * Gets the hit normal/direction in the world
  19660. */
  19661. readonly hitNormalWorld: Vector3;
  19662. /**
  19663. * Gets the hit point in the world
  19664. */
  19665. readonly hitPointWorld: Vector3;
  19666. /**
  19667. * Gets the ray "start point" of the ray in the world
  19668. */
  19669. readonly rayFromWorld: Vector3;
  19670. /**
  19671. * Gets the ray "end point" of the ray in the world
  19672. */
  19673. readonly rayToWorld: Vector3;
  19674. /**
  19675. * Sets the hit data (normal & point in world space)
  19676. * @param hitNormalWorld defines the normal in world space
  19677. * @param hitPointWorld defines the point in world space
  19678. */
  19679. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19680. /**
  19681. * Sets the distance from the start point to the hit point
  19682. * @param distance
  19683. */
  19684. setHitDistance(distance: number): void;
  19685. /**
  19686. * Calculates the distance manually
  19687. */
  19688. calculateHitDistance(): void;
  19689. /**
  19690. * Resets all the values to default
  19691. * @param from The from point on world space
  19692. * @param to The to point on world space
  19693. */
  19694. reset(from?: Vector3, to?: Vector3): void;
  19695. }
  19696. /**
  19697. * Interface for the size containing width and height
  19698. */
  19699. interface IXYZ {
  19700. /**
  19701. * X
  19702. */
  19703. x: number;
  19704. /**
  19705. * Y
  19706. */
  19707. y: number;
  19708. /**
  19709. * Z
  19710. */
  19711. z: number;
  19712. }
  19713. }
  19714. declare module BABYLON {
  19715. /**
  19716. * Interface used to describe a physics joint
  19717. */
  19718. export interface PhysicsImpostorJoint {
  19719. /** Defines the main impostor to which the joint is linked */
  19720. mainImpostor: PhysicsImpostor;
  19721. /** Defines the impostor that is connected to the main impostor using this joint */
  19722. connectedImpostor: PhysicsImpostor;
  19723. /** Defines the joint itself */
  19724. joint: PhysicsJoint;
  19725. }
  19726. /** @hidden */
  19727. export interface IPhysicsEnginePlugin {
  19728. world: any;
  19729. name: string;
  19730. setGravity(gravity: Vector3): void;
  19731. setTimeStep(timeStep: number): void;
  19732. getTimeStep(): number;
  19733. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19737. removePhysicsBody(impostor: PhysicsImpostor): void;
  19738. generateJoint(joint: PhysicsImpostorJoint): void;
  19739. removeJoint(joint: PhysicsImpostorJoint): void;
  19740. isSupported(): boolean;
  19741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19743. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19744. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19745. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19746. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19747. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19748. getBodyMass(impostor: PhysicsImpostor): number;
  19749. getBodyFriction(impostor: PhysicsImpostor): number;
  19750. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19751. getBodyRestitution(impostor: PhysicsImpostor): number;
  19752. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19753. getBodyPressure?(impostor: PhysicsImpostor): number;
  19754. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19755. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19756. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19757. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19758. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19759. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19760. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19761. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19762. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19763. sleepBody(impostor: PhysicsImpostor): void;
  19764. wakeUpBody(impostor: PhysicsImpostor): void;
  19765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19767. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19769. getRadius(impostor: PhysicsImpostor): number;
  19770. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19772. dispose(): void;
  19773. }
  19774. /**
  19775. * Interface used to define a physics engine
  19776. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19777. */
  19778. export interface IPhysicsEngine {
  19779. /**
  19780. * Gets the gravity vector used by the simulation
  19781. */
  19782. gravity: Vector3;
  19783. /**
  19784. * Sets the gravity vector used by the simulation
  19785. * @param gravity defines the gravity vector to use
  19786. */
  19787. setGravity(gravity: Vector3): void;
  19788. /**
  19789. * Set the time step of the physics engine.
  19790. * Default is 1/60.
  19791. * To slow it down, enter 1/600 for example.
  19792. * To speed it up, 1/30
  19793. * @param newTimeStep the new timestep to apply to this world.
  19794. */
  19795. setTimeStep(newTimeStep: number): void;
  19796. /**
  19797. * Get the time step of the physics engine.
  19798. * @returns the current time step
  19799. */
  19800. getTimeStep(): number;
  19801. /**
  19802. * Release all resources
  19803. */
  19804. dispose(): void;
  19805. /**
  19806. * Gets the name of the current physics plugin
  19807. * @returns the name of the plugin
  19808. */
  19809. getPhysicsPluginName(): string;
  19810. /**
  19811. * Adding a new impostor for the impostor tracking.
  19812. * This will be done by the impostor itself.
  19813. * @param impostor the impostor to add
  19814. */
  19815. addImpostor(impostor: PhysicsImpostor): void;
  19816. /**
  19817. * Remove an impostor from the engine.
  19818. * This impostor and its mesh will not longer be updated by the physics engine.
  19819. * @param impostor the impostor to remove
  19820. */
  19821. removeImpostor(impostor: PhysicsImpostor): void;
  19822. /**
  19823. * Add a joint to the physics engine
  19824. * @param mainImpostor defines the main impostor to which the joint is added.
  19825. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19826. * @param joint defines the joint that will connect both impostors.
  19827. */
  19828. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19829. /**
  19830. * Removes a joint from the simulation
  19831. * @param mainImpostor defines the impostor used with the joint
  19832. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19833. * @param joint defines the joint to remove
  19834. */
  19835. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19836. /**
  19837. * Gets the current plugin used to run the simulation
  19838. * @returns current plugin
  19839. */
  19840. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19841. /**
  19842. * Gets the list of physic impostors
  19843. * @returns an array of PhysicsImpostor
  19844. */
  19845. getImpostors(): Array<PhysicsImpostor>;
  19846. /**
  19847. * Gets the impostor for a physics enabled object
  19848. * @param object defines the object impersonated by the impostor
  19849. * @returns the PhysicsImpostor or null if not found
  19850. */
  19851. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19852. /**
  19853. * Gets the impostor for a physics body object
  19854. * @param body defines physics body used by the impostor
  19855. * @returns the PhysicsImpostor or null if not found
  19856. */
  19857. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19858. /**
  19859. * Does a raycast in the physics world
  19860. * @param from when should the ray start?
  19861. * @param to when should the ray end?
  19862. * @returns PhysicsRaycastResult
  19863. */
  19864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19865. /**
  19866. * Called by the scene. No need to call it.
  19867. * @param delta defines the timespam between frames
  19868. */ step(delta: number): void;
  19869. }
  19870. }
  19871. declare module BABYLON {
  19872. /**
  19873. * The interface for the physics imposter parameters
  19874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19875. */
  19876. export interface PhysicsImpostorParameters {
  19877. /**
  19878. * The mass of the physics imposter
  19879. */
  19880. mass: number;
  19881. /**
  19882. * The friction of the physics imposter
  19883. */
  19884. friction?: number;
  19885. /**
  19886. * The coefficient of restitution of the physics imposter
  19887. */
  19888. restitution?: number;
  19889. /**
  19890. * The native options of the physics imposter
  19891. */
  19892. nativeOptions?: any;
  19893. /**
  19894. * Specifies if the parent should be ignored
  19895. */
  19896. ignoreParent?: boolean;
  19897. /**
  19898. * Specifies if bi-directional transformations should be disabled
  19899. */
  19900. disableBidirectionalTransformation?: boolean;
  19901. /**
  19902. * The pressure inside the physics imposter, soft object only
  19903. */
  19904. pressure?: number;
  19905. /**
  19906. * The stiffness the physics imposter, soft object only
  19907. */
  19908. stiffness?: number;
  19909. /**
  19910. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19911. */
  19912. velocityIterations?: number;
  19913. /**
  19914. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19915. */
  19916. positionIterations?: number;
  19917. /**
  19918. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19919. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19920. * Add to fix multiple points
  19921. */
  19922. fixedPoints?: number;
  19923. /**
  19924. * The collision margin around a soft object
  19925. */
  19926. margin?: number;
  19927. /**
  19928. * The collision margin around a soft object
  19929. */
  19930. damping?: number;
  19931. /**
  19932. * The path for a rope based on an extrusion
  19933. */
  19934. path?: any;
  19935. /**
  19936. * The shape of an extrusion used for a rope based on an extrusion
  19937. */
  19938. shape?: any;
  19939. }
  19940. /**
  19941. * Interface for a physics-enabled object
  19942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19943. */
  19944. export interface IPhysicsEnabledObject {
  19945. /**
  19946. * The position of the physics-enabled object
  19947. */
  19948. position: Vector3;
  19949. /**
  19950. * The rotation of the physics-enabled object
  19951. */
  19952. rotationQuaternion: Nullable<Quaternion>;
  19953. /**
  19954. * The scale of the physics-enabled object
  19955. */
  19956. scaling: Vector3;
  19957. /**
  19958. * The rotation of the physics-enabled object
  19959. */
  19960. rotation?: Vector3;
  19961. /**
  19962. * The parent of the physics-enabled object
  19963. */
  19964. parent?: any;
  19965. /**
  19966. * The bounding info of the physics-enabled object
  19967. * @returns The bounding info of the physics-enabled object
  19968. */
  19969. getBoundingInfo(): BoundingInfo;
  19970. /**
  19971. * Computes the world matrix
  19972. * @param force Specifies if the world matrix should be computed by force
  19973. * @returns A world matrix
  19974. */
  19975. computeWorldMatrix(force: boolean): Matrix;
  19976. /**
  19977. * Gets the world matrix
  19978. * @returns A world matrix
  19979. */
  19980. getWorldMatrix?(): Matrix;
  19981. /**
  19982. * Gets the child meshes
  19983. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19984. * @returns An array of abstract meshes
  19985. */
  19986. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19987. /**
  19988. * Gets the vertex data
  19989. * @param kind The type of vertex data
  19990. * @returns A nullable array of numbers, or a float32 array
  19991. */
  19992. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19993. /**
  19994. * Gets the indices from the mesh
  19995. * @returns A nullable array of index arrays
  19996. */
  19997. getIndices?(): Nullable<IndicesArray>;
  19998. /**
  19999. * Gets the scene from the mesh
  20000. * @returns the indices array or null
  20001. */
  20002. getScene?(): Scene;
  20003. /**
  20004. * Gets the absolute position from the mesh
  20005. * @returns the absolute position
  20006. */
  20007. getAbsolutePosition(): Vector3;
  20008. /**
  20009. * Gets the absolute pivot point from the mesh
  20010. * @returns the absolute pivot point
  20011. */
  20012. getAbsolutePivotPoint(): Vector3;
  20013. /**
  20014. * Rotates the mesh
  20015. * @param axis The axis of rotation
  20016. * @param amount The amount of rotation
  20017. * @param space The space of the rotation
  20018. * @returns The rotation transform node
  20019. */
  20020. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20021. /**
  20022. * Translates the mesh
  20023. * @param axis The axis of translation
  20024. * @param distance The distance of translation
  20025. * @param space The space of the translation
  20026. * @returns The transform node
  20027. */
  20028. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20029. /**
  20030. * Sets the absolute position of the mesh
  20031. * @param absolutePosition The absolute position of the mesh
  20032. * @returns The transform node
  20033. */
  20034. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20035. /**
  20036. * Gets the class name of the mesh
  20037. * @returns The class name
  20038. */
  20039. getClassName(): string;
  20040. }
  20041. /**
  20042. * Represents a physics imposter
  20043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20044. */
  20045. export class PhysicsImpostor {
  20046. /**
  20047. * The physics-enabled object used as the physics imposter
  20048. */
  20049. object: IPhysicsEnabledObject;
  20050. /**
  20051. * The type of the physics imposter
  20052. */
  20053. type: number;
  20054. private _options;
  20055. private _scene?;
  20056. /**
  20057. * The default object size of the imposter
  20058. */
  20059. static DEFAULT_OBJECT_SIZE: Vector3;
  20060. /**
  20061. * The identity quaternion of the imposter
  20062. */
  20063. static IDENTITY_QUATERNION: Quaternion;
  20064. /** @hidden */ pluginData: any;
  20065. private _physicsEngine;
  20066. private _physicsBody;
  20067. private _bodyUpdateRequired;
  20068. private _onBeforePhysicsStepCallbacks;
  20069. private _onAfterPhysicsStepCallbacks;
  20070. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20071. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20072. otherImpostors: Array<PhysicsImpostor>;
  20073. }>;
  20074. private _deltaPosition;
  20075. private _deltaRotation;
  20076. private _deltaRotationConjugated;
  20077. /** hidden */ isFromLine: boolean;
  20078. private _parent;
  20079. private _isDisposed;
  20080. private static _tmpVecs;
  20081. private static _tmpQuat;
  20082. /**
  20083. * Specifies if the physics imposter is disposed
  20084. */
  20085. readonly isDisposed: boolean;
  20086. /**
  20087. * Gets the mass of the physics imposter
  20088. */
  20089. mass: number;
  20090. /**
  20091. * Gets the coefficient of friction
  20092. */
  20093. /**
  20094. * Sets the coefficient of friction
  20095. */
  20096. friction: number;
  20097. /**
  20098. * Gets the coefficient of restitution
  20099. */
  20100. /**
  20101. * Sets the coefficient of restitution
  20102. */
  20103. restitution: number;
  20104. /**
  20105. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20106. */
  20107. /**
  20108. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20109. */
  20110. pressure: number;
  20111. /**
  20112. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20113. */
  20114. /**
  20115. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20116. */
  20117. stiffness: number;
  20118. /**
  20119. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20120. */
  20121. /**
  20122. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20123. */
  20124. velocityIterations: number;
  20125. /**
  20126. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20127. */
  20128. /**
  20129. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20130. */
  20131. positionIterations: number;
  20132. /**
  20133. * The unique id of the physics imposter
  20134. * set by the physics engine when adding this impostor to the array
  20135. */
  20136. uniqueId: number;
  20137. /**
  20138. * @hidden
  20139. */
  20140. soft: boolean;
  20141. /**
  20142. * @hidden
  20143. */
  20144. segments: number;
  20145. private _joints;
  20146. /**
  20147. * Initializes the physics imposter
  20148. * @param object The physics-enabled object used as the physics imposter
  20149. * @param type The type of the physics imposter
  20150. * @param _options The options for the physics imposter
  20151. * @param _scene The Babylon scene
  20152. */
  20153. constructor(
  20154. /**
  20155. * The physics-enabled object used as the physics imposter
  20156. */
  20157. object: IPhysicsEnabledObject,
  20158. /**
  20159. * The type of the physics imposter
  20160. */
  20161. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20162. /**
  20163. * This function will completly initialize this impostor.
  20164. * It will create a new body - but only if this mesh has no parent.
  20165. * If it has, this impostor will not be used other than to define the impostor
  20166. * of the child mesh.
  20167. * @hidden
  20168. */ init(): void;
  20169. private _getPhysicsParent;
  20170. /**
  20171. * Should a new body be generated.
  20172. * @returns boolean specifying if body initialization is required
  20173. */
  20174. isBodyInitRequired(): boolean;
  20175. /**
  20176. * Sets the updated scaling
  20177. * @param updated Specifies if the scaling is updated
  20178. */
  20179. setScalingUpdated(): void;
  20180. /**
  20181. * Force a regeneration of this or the parent's impostor's body.
  20182. * Use under cautious - This will remove all joints already implemented.
  20183. */
  20184. forceUpdate(): void;
  20185. /**
  20186. * Gets the body that holds this impostor. Either its own, or its parent.
  20187. */
  20188. /**
  20189. * Set the physics body. Used mainly by the physics engine/plugin
  20190. */
  20191. physicsBody: any;
  20192. /**
  20193. * Get the parent of the physics imposter
  20194. * @returns Physics imposter or null
  20195. */
  20196. /**
  20197. * Sets the parent of the physics imposter
  20198. */
  20199. parent: Nullable<PhysicsImpostor>;
  20200. /**
  20201. * Resets the update flags
  20202. */
  20203. resetUpdateFlags(): void;
  20204. /**
  20205. * Gets the object extend size
  20206. * @returns the object extend size
  20207. */
  20208. getObjectExtendSize(): Vector3;
  20209. /**
  20210. * Gets the object center
  20211. * @returns The object center
  20212. */
  20213. getObjectCenter(): Vector3;
  20214. /**
  20215. * Get a specific parametes from the options parameter
  20216. * @param paramName The object parameter name
  20217. * @returns The object parameter
  20218. */
  20219. getParam(paramName: string): any;
  20220. /**
  20221. * Sets a specific parameter in the options given to the physics plugin
  20222. * @param paramName The parameter name
  20223. * @param value The value of the parameter
  20224. */
  20225. setParam(paramName: string, value: number): void;
  20226. /**
  20227. * Specifically change the body's mass option. Won't recreate the physics body object
  20228. * @param mass The mass of the physics imposter
  20229. */
  20230. setMass(mass: number): void;
  20231. /**
  20232. * Gets the linear velocity
  20233. * @returns linear velocity or null
  20234. */
  20235. getLinearVelocity(): Nullable<Vector3>;
  20236. /**
  20237. * Sets the linear velocity
  20238. * @param velocity linear velocity or null
  20239. */
  20240. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20241. /**
  20242. * Gets the angular velocity
  20243. * @returns angular velocity or null
  20244. */
  20245. getAngularVelocity(): Nullable<Vector3>;
  20246. /**
  20247. * Sets the angular velocity
  20248. * @param velocity The velocity or null
  20249. */
  20250. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20251. /**
  20252. * Execute a function with the physics plugin native code
  20253. * Provide a function the will have two variables - the world object and the physics body object
  20254. * @param func The function to execute with the physics plugin native code
  20255. */
  20256. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20257. /**
  20258. * Register a function that will be executed before the physics world is stepping forward
  20259. * @param func The function to execute before the physics world is stepped forward
  20260. */
  20261. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20262. /**
  20263. * Unregister a function that will be executed before the physics world is stepping forward
  20264. * @param func The function to execute before the physics world is stepped forward
  20265. */
  20266. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20267. /**
  20268. * Register a function that will be executed after the physics step
  20269. * @param func The function to execute after physics step
  20270. */
  20271. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20272. /**
  20273. * Unregisters a function that will be executed after the physics step
  20274. * @param func The function to execute after physics step
  20275. */
  20276. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20277. /**
  20278. * register a function that will be executed when this impostor collides against a different body
  20279. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20280. * @param func Callback that is executed on collision
  20281. */
  20282. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20283. /**
  20284. * Unregisters the physics imposter on contact
  20285. * @param collideAgainst The physics object to collide against
  20286. * @param func Callback to execute on collision
  20287. */
  20288. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20289. private _tmpQuat;
  20290. private _tmpQuat2;
  20291. /**
  20292. * Get the parent rotation
  20293. * @returns The parent rotation
  20294. */
  20295. getParentsRotation(): Quaternion;
  20296. /**
  20297. * this function is executed by the physics engine.
  20298. */
  20299. beforeStep: () => void;
  20300. /**
  20301. * this function is executed by the physics engine
  20302. */
  20303. afterStep: () => void;
  20304. /**
  20305. * Legacy collision detection event support
  20306. */
  20307. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20308. /**
  20309. * event and body object due to cannon's event-based architecture.
  20310. */
  20311. onCollide: (e: {
  20312. body: any;
  20313. }) => void;
  20314. /**
  20315. * Apply a force
  20316. * @param force The force to apply
  20317. * @param contactPoint The contact point for the force
  20318. * @returns The physics imposter
  20319. */
  20320. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20321. /**
  20322. * Apply an impulse
  20323. * @param force The impulse force
  20324. * @param contactPoint The contact point for the impulse force
  20325. * @returns The physics imposter
  20326. */
  20327. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20328. /**
  20329. * A help function to create a joint
  20330. * @param otherImpostor A physics imposter used to create a joint
  20331. * @param jointType The type of joint
  20332. * @param jointData The data for the joint
  20333. * @returns The physics imposter
  20334. */
  20335. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20336. /**
  20337. * Add a joint to this impostor with a different impostor
  20338. * @param otherImpostor A physics imposter used to add a joint
  20339. * @param joint The joint to add
  20340. * @returns The physics imposter
  20341. */
  20342. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20343. /**
  20344. * Add an anchor to a cloth impostor
  20345. * @param otherImpostor rigid impostor to anchor to
  20346. * @param width ratio across width from 0 to 1
  20347. * @param height ratio up height from 0 to 1
  20348. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20349. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20350. * @returns impostor the soft imposter
  20351. */
  20352. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20353. /**
  20354. * Add a hook to a rope impostor
  20355. * @param otherImpostor rigid impostor to anchor to
  20356. * @param length ratio across rope from 0 to 1
  20357. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20358. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20359. * @returns impostor the rope imposter
  20360. */
  20361. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20362. /**
  20363. * Will keep this body still, in a sleep mode.
  20364. * @returns the physics imposter
  20365. */
  20366. sleep(): PhysicsImpostor;
  20367. /**
  20368. * Wake the body up.
  20369. * @returns The physics imposter
  20370. */
  20371. wakeUp(): PhysicsImpostor;
  20372. /**
  20373. * Clones the physics imposter
  20374. * @param newObject The physics imposter clones to this physics-enabled object
  20375. * @returns A nullable physics imposter
  20376. */
  20377. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20378. /**
  20379. * Disposes the physics imposter
  20380. */
  20381. dispose(): void;
  20382. /**
  20383. * Sets the delta position
  20384. * @param position The delta position amount
  20385. */
  20386. setDeltaPosition(position: Vector3): void;
  20387. /**
  20388. * Sets the delta rotation
  20389. * @param rotation The delta rotation amount
  20390. */
  20391. setDeltaRotation(rotation: Quaternion): void;
  20392. /**
  20393. * Gets the box size of the physics imposter and stores the result in the input parameter
  20394. * @param result Stores the box size
  20395. * @returns The physics imposter
  20396. */
  20397. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20398. /**
  20399. * Gets the radius of the physics imposter
  20400. * @returns Radius of the physics imposter
  20401. */
  20402. getRadius(): number;
  20403. /**
  20404. * Sync a bone with this impostor
  20405. * @param bone The bone to sync to the impostor.
  20406. * @param boneMesh The mesh that the bone is influencing.
  20407. * @param jointPivot The pivot of the joint / bone in local space.
  20408. * @param distToJoint Optional distance from the impostor to the joint.
  20409. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20410. */
  20411. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20412. /**
  20413. * Sync impostor to a bone
  20414. * @param bone The bone that the impostor will be synced to.
  20415. * @param boneMesh The mesh that the bone is influencing.
  20416. * @param jointPivot The pivot of the joint / bone in local space.
  20417. * @param distToJoint Optional distance from the impostor to the joint.
  20418. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20419. * @param boneAxis Optional vector3 axis the bone is aligned with
  20420. */
  20421. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20422. /**
  20423. * No-Imposter type
  20424. */
  20425. static NoImpostor: number;
  20426. /**
  20427. * Sphere-Imposter type
  20428. */
  20429. static SphereImpostor: number;
  20430. /**
  20431. * Box-Imposter type
  20432. */
  20433. static BoxImpostor: number;
  20434. /**
  20435. * Plane-Imposter type
  20436. */
  20437. static PlaneImpostor: number;
  20438. /**
  20439. * Mesh-imposter type
  20440. */
  20441. static MeshImpostor: number;
  20442. /**
  20443. * Cylinder-Imposter type
  20444. */
  20445. static CylinderImpostor: number;
  20446. /**
  20447. * Particle-Imposter type
  20448. */
  20449. static ParticleImpostor: number;
  20450. /**
  20451. * Heightmap-Imposter type
  20452. */
  20453. static HeightmapImpostor: number;
  20454. /**
  20455. * ConvexHull-Impostor type (Ammo.js plugin only)
  20456. */
  20457. static ConvexHullImpostor: number;
  20458. /**
  20459. * Rope-Imposter type
  20460. */
  20461. static RopeImpostor: number;
  20462. /**
  20463. * Cloth-Imposter type
  20464. */
  20465. static ClothImpostor: number;
  20466. /**
  20467. * Softbody-Imposter type
  20468. */
  20469. static SoftbodyImpostor: number;
  20470. }
  20471. }
  20472. declare module BABYLON {
  20473. /**
  20474. * @hidden
  20475. **/
  20476. export class _CreationDataStorage {
  20477. closePath?: boolean;
  20478. closeArray?: boolean;
  20479. idx: number[];
  20480. dashSize: number;
  20481. gapSize: number;
  20482. path3D: Path3D;
  20483. pathArray: Vector3[][];
  20484. arc: number;
  20485. radius: number;
  20486. cap: number;
  20487. tessellation: number;
  20488. }
  20489. /**
  20490. * @hidden
  20491. **/ private class _InstanceDataStorage {
  20492. visibleInstances: any;
  20493. batchCache: _InstancesBatch;
  20494. instancesBufferSize: number;
  20495. instancesBuffer: Nullable<Buffer>;
  20496. instancesData: Float32Array;
  20497. overridenInstanceCount: number;
  20498. isFrozen: boolean;
  20499. previousBatch: _InstancesBatch;
  20500. hardwareInstancedRendering: boolean;
  20501. sideOrientation: number;
  20502. }
  20503. /**
  20504. * @hidden
  20505. **/
  20506. export class _InstancesBatch {
  20507. mustReturn: boolean;
  20508. visibleInstances: Nullable<InstancedMesh[]>[];
  20509. renderSelf: boolean[];
  20510. hardwareInstancedRendering: boolean[];
  20511. }
  20512. /**
  20513. * Class used to represent renderable models
  20514. */
  20515. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20516. /**
  20517. * Mesh side orientation : usually the external or front surface
  20518. */
  20519. static readonly FRONTSIDE: number;
  20520. /**
  20521. * Mesh side orientation : usually the internal or back surface
  20522. */
  20523. static readonly BACKSIDE: number;
  20524. /**
  20525. * Mesh side orientation : both internal and external or front and back surfaces
  20526. */
  20527. static readonly DOUBLESIDE: number;
  20528. /**
  20529. * Mesh side orientation : by default, `FRONTSIDE`
  20530. */
  20531. static readonly DEFAULTSIDE: number;
  20532. /**
  20533. * Mesh cap setting : no cap
  20534. */
  20535. static readonly NO_CAP: number;
  20536. /**
  20537. * Mesh cap setting : one cap at the beginning of the mesh
  20538. */
  20539. static readonly CAP_START: number;
  20540. /**
  20541. * Mesh cap setting : one cap at the end of the mesh
  20542. */
  20543. static readonly CAP_END: number;
  20544. /**
  20545. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20546. */
  20547. static readonly CAP_ALL: number;
  20548. /**
  20549. * Gets the default side orientation.
  20550. * @param orientation the orientation to value to attempt to get
  20551. * @returns the default orientation
  20552. * @hidden
  20553. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20554. private _onBeforeRenderObservable;
  20555. private _onBeforeBindObservable;
  20556. private _onAfterRenderObservable;
  20557. private _onBeforeDrawObservable;
  20558. /**
  20559. * An event triggered before rendering the mesh
  20560. */
  20561. readonly onBeforeRenderObservable: Observable<Mesh>;
  20562. /**
  20563. * An event triggered before binding the mesh
  20564. */
  20565. readonly onBeforeBindObservable: Observable<Mesh>;
  20566. /**
  20567. * An event triggered after rendering the mesh
  20568. */
  20569. readonly onAfterRenderObservable: Observable<Mesh>;
  20570. /**
  20571. * An event triggered before drawing the mesh
  20572. */
  20573. readonly onBeforeDrawObservable: Observable<Mesh>;
  20574. private _onBeforeDrawObserver;
  20575. /**
  20576. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20577. */
  20578. onBeforeDraw: () => void;
  20579. /**
  20580. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20581. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20582. */
  20583. delayLoadState: number;
  20584. /**
  20585. * Gets the list of instances created from this mesh
  20586. * it is not supposed to be modified manually.
  20587. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20588. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20589. */
  20590. instances: InstancedMesh[];
  20591. /**
  20592. * Gets the file containing delay loading data for this mesh
  20593. */
  20594. delayLoadingFile: string;
  20595. /** @hidden */ binaryInfo: any;
  20596. private _LODLevels;
  20597. /**
  20598. * User defined function used to change how LOD level selection is done
  20599. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20600. */
  20601. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20602. private _morphTargetManager;
  20603. /**
  20604. * Gets or sets the morph target manager
  20605. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20606. */
  20607. morphTargetManager: Nullable<MorphTargetManager>;
  20608. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20609. /** @hidden */ geometry: Nullable<Geometry>;
  20610. /** @hidden */ delayInfo: Array<string>;
  20611. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20612. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20613. private _effectiveMaterial;
  20614. /** @hidden */ shouldGenerateFlatShading: boolean;
  20615. private _preActivateId;
  20616. /** @hidden */ originalBuilderSideOrientation: number;
  20617. /**
  20618. * Use this property to change the original side orientation defined at construction time
  20619. */
  20620. overrideMaterialSideOrientation: Nullable<number>;
  20621. private _areNormalsFrozen;
  20622. private _sourcePositions;
  20623. private _sourceNormals;
  20624. private _source;
  20625. private meshMap;
  20626. /**
  20627. * Gets the source mesh (the one used to clone this one from)
  20628. */
  20629. readonly source: Nullable<Mesh>;
  20630. /**
  20631. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20632. */
  20633. isUnIndexed: boolean;
  20634. /**
  20635. * @constructor
  20636. * @param name The value used by scene.getMeshByName() to do a lookup.
  20637. * @param scene The scene to add this mesh to.
  20638. * @param parent The parent of this mesh, if it has one
  20639. * @param source An optional Mesh from which geometry is shared, cloned.
  20640. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20641. * When false, achieved by calling a clone(), also passing False.
  20642. * This will make creation of children, recursive.
  20643. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20644. */
  20645. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20646. /**
  20647. * Gets the class name
  20648. * @returns the string "Mesh".
  20649. */
  20650. getClassName(): string;
  20651. /** @hidden */ protected readonly _isMesh: boolean;
  20652. /**
  20653. * Returns a description of this mesh
  20654. * @param fullDetails define if full details about this mesh must be used
  20655. * @returns a descriptive string representing this mesh
  20656. */
  20657. toString(fullDetails?: boolean): string;
  20658. /** @hidden */ unBindEffect(): void;
  20659. /**
  20660. * Gets a boolean indicating if this mesh has LOD
  20661. */
  20662. readonly hasLODLevels: boolean;
  20663. /**
  20664. * Gets the list of MeshLODLevel associated with the current mesh
  20665. * @returns an array of MeshLODLevel
  20666. */
  20667. getLODLevels(): MeshLODLevel[];
  20668. private _sortLODLevels;
  20669. /**
  20670. * Add a mesh as LOD level triggered at the given distance.
  20671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20672. * @param distance The distance from the center of the object to show this level
  20673. * @param mesh The mesh to be added as LOD level (can be null)
  20674. * @return This mesh (for chaining)
  20675. */
  20676. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20677. /**
  20678. * Returns the LOD level mesh at the passed distance or null if not found.
  20679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20680. * @param distance The distance from the center of the object to show this level
  20681. * @returns a Mesh or `null`
  20682. */
  20683. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20684. /**
  20685. * Remove a mesh from the LOD array
  20686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20687. * @param mesh defines the mesh to be removed
  20688. * @return This mesh (for chaining)
  20689. */
  20690. removeLODLevel(mesh: Mesh): Mesh;
  20691. /**
  20692. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20694. * @param camera defines the camera to use to compute distance
  20695. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20696. * @return This mesh (for chaining)
  20697. */
  20698. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20699. /**
  20700. * Gets the mesh internal Geometry object
  20701. */
  20702. readonly geometry: Nullable<Geometry>;
  20703. /**
  20704. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20705. * @returns the total number of vertices
  20706. */
  20707. getTotalVertices(): number;
  20708. /**
  20709. * Returns the content of an associated vertex buffer
  20710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @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
  20724. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20725. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20726. */
  20727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20728. /**
  20729. * Returns the mesh VertexBuffer object from the requested `kind`
  20730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20731. * - VertexBuffer.PositionKind
  20732. * - VertexBuffer.UVKind
  20733. * - VertexBuffer.UV2Kind
  20734. * - VertexBuffer.UV3Kind
  20735. * - VertexBuffer.UV4Kind
  20736. * - VertexBuffer.UV5Kind
  20737. * - VertexBuffer.UV6Kind
  20738. * - VertexBuffer.ColorKind
  20739. * - VertexBuffer.MatricesIndicesKind
  20740. * - VertexBuffer.MatricesIndicesExtraKind
  20741. * - VertexBuffer.MatricesWeightsKind
  20742. * - VertexBuffer.MatricesWeightsExtraKind
  20743. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20744. */
  20745. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20746. /**
  20747. * Tests if a specific vertex buffer is associated with this mesh
  20748. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20749. * - VertexBuffer.PositionKind
  20750. * - VertexBuffer.UVKind
  20751. * - VertexBuffer.UV2Kind
  20752. * - VertexBuffer.UV3Kind
  20753. * - VertexBuffer.UV4Kind
  20754. * - VertexBuffer.UV5Kind
  20755. * - VertexBuffer.UV6Kind
  20756. * - VertexBuffer.ColorKind
  20757. * - VertexBuffer.MatricesIndicesKind
  20758. * - VertexBuffer.MatricesIndicesExtraKind
  20759. * - VertexBuffer.MatricesWeightsKind
  20760. * - VertexBuffer.MatricesWeightsExtraKind
  20761. * @returns a boolean
  20762. */
  20763. isVerticesDataPresent(kind: string): boolean;
  20764. /**
  20765. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20766. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20767. * - VertexBuffer.PositionKind
  20768. * - VertexBuffer.UVKind
  20769. * - VertexBuffer.UV2Kind
  20770. * - VertexBuffer.UV3Kind
  20771. * - VertexBuffer.UV4Kind
  20772. * - VertexBuffer.UV5Kind
  20773. * - VertexBuffer.UV6Kind
  20774. * - VertexBuffer.ColorKind
  20775. * - VertexBuffer.MatricesIndicesKind
  20776. * - VertexBuffer.MatricesIndicesExtraKind
  20777. * - VertexBuffer.MatricesWeightsKind
  20778. * - VertexBuffer.MatricesWeightsExtraKind
  20779. * @returns a boolean
  20780. */
  20781. isVertexBufferUpdatable(kind: string): boolean;
  20782. /**
  20783. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20784. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20785. * - VertexBuffer.PositionKind
  20786. * - VertexBuffer.UVKind
  20787. * - VertexBuffer.UV2Kind
  20788. * - VertexBuffer.UV3Kind
  20789. * - VertexBuffer.UV4Kind
  20790. * - VertexBuffer.UV5Kind
  20791. * - VertexBuffer.UV6Kind
  20792. * - VertexBuffer.ColorKind
  20793. * - VertexBuffer.MatricesIndicesKind
  20794. * - VertexBuffer.MatricesIndicesExtraKind
  20795. * - VertexBuffer.MatricesWeightsKind
  20796. * - VertexBuffer.MatricesWeightsExtraKind
  20797. * @returns an array of strings
  20798. */
  20799. getVerticesDataKinds(): string[];
  20800. /**
  20801. * Returns a positive integer : the total number of indices in this mesh geometry.
  20802. * @returns the numner of indices or zero if the mesh has no geometry.
  20803. */
  20804. getTotalIndices(): number;
  20805. /**
  20806. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20807. * @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.
  20808. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20809. * @returns the indices array or an empty array if the mesh has no geometry
  20810. */
  20811. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20812. readonly isBlocked: boolean;
  20813. /**
  20814. * Determine if the current mesh is ready to be rendered
  20815. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20816. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20817. * @returns true if all associated assets are ready (material, textures, shaders)
  20818. */
  20819. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20820. /**
  20821. * 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.
  20822. */
  20823. readonly areNormalsFrozen: boolean;
  20824. /**
  20825. * 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.
  20826. * @returns the current mesh
  20827. */
  20828. freezeNormals(): Mesh;
  20829. /**
  20830. * 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
  20831. * @returns the current mesh
  20832. */
  20833. unfreezeNormals(): Mesh;
  20834. /**
  20835. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20836. */
  20837. overridenInstanceCount: number;
  20838. /** @hidden */ preActivate(): Mesh;
  20839. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20840. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20841. /**
  20842. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20843. * This means the mesh underlying bounding box and sphere are recomputed.
  20844. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20845. * @returns the current mesh
  20846. */
  20847. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20848. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20849. /**
  20850. * This function will subdivide the mesh into multiple submeshes
  20851. * @param count defines the expected number of submeshes
  20852. */
  20853. subdivide(count: number): void;
  20854. /**
  20855. * Copy a FloatArray into a specific associated vertex buffer
  20856. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20857. * - VertexBuffer.PositionKind
  20858. * - VertexBuffer.UVKind
  20859. * - VertexBuffer.UV2Kind
  20860. * - VertexBuffer.UV3Kind
  20861. * - VertexBuffer.UV4Kind
  20862. * - VertexBuffer.UV5Kind
  20863. * - VertexBuffer.UV6Kind
  20864. * - VertexBuffer.ColorKind
  20865. * - VertexBuffer.MatricesIndicesKind
  20866. * - VertexBuffer.MatricesIndicesExtraKind
  20867. * - VertexBuffer.MatricesWeightsKind
  20868. * - VertexBuffer.MatricesWeightsExtraKind
  20869. * @param data defines the data source
  20870. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20871. * @param stride defines the data stride size (can be null)
  20872. * @returns the current mesh
  20873. */
  20874. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20875. /**
  20876. * Flags an associated vertex buffer as updatable
  20877. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20878. * - VertexBuffer.PositionKind
  20879. * - VertexBuffer.UVKind
  20880. * - VertexBuffer.UV2Kind
  20881. * - VertexBuffer.UV3Kind
  20882. * - VertexBuffer.UV4Kind
  20883. * - VertexBuffer.UV5Kind
  20884. * - VertexBuffer.UV6Kind
  20885. * - VertexBuffer.ColorKind
  20886. * - VertexBuffer.MatricesIndicesKind
  20887. * - VertexBuffer.MatricesIndicesExtraKind
  20888. * - VertexBuffer.MatricesWeightsKind
  20889. * - VertexBuffer.MatricesWeightsExtraKind
  20890. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20891. */
  20892. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20893. /**
  20894. * Sets the mesh global Vertex Buffer
  20895. * @param buffer defines the buffer to use
  20896. * @returns the current mesh
  20897. */
  20898. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20899. /**
  20900. * Update a specific associated vertex buffer
  20901. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20902. * - VertexBuffer.PositionKind
  20903. * - VertexBuffer.UVKind
  20904. * - VertexBuffer.UV2Kind
  20905. * - VertexBuffer.UV3Kind
  20906. * - VertexBuffer.UV4Kind
  20907. * - VertexBuffer.UV5Kind
  20908. * - VertexBuffer.UV6Kind
  20909. * - VertexBuffer.ColorKind
  20910. * - VertexBuffer.MatricesIndicesKind
  20911. * - VertexBuffer.MatricesIndicesExtraKind
  20912. * - VertexBuffer.MatricesWeightsKind
  20913. * - VertexBuffer.MatricesWeightsExtraKind
  20914. * @param data defines the data source
  20915. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20916. * @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)
  20917. * @returns the current mesh
  20918. */
  20919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20920. /**
  20921. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20922. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20923. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20924. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20925. * @returns the current mesh
  20926. */
  20927. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20928. /**
  20929. * Creates a un-shared specific occurence of the geometry for the mesh.
  20930. * @returns the current mesh
  20931. */
  20932. makeGeometryUnique(): Mesh;
  20933. /**
  20934. * Set the index buffer of this mesh
  20935. * @param indices defines the source data
  20936. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20937. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20938. * @returns the current mesh
  20939. */
  20940. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20941. /**
  20942. * Update the current index buffer
  20943. * @param indices defines the source data
  20944. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20945. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20946. * @returns the current mesh
  20947. */
  20948. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20949. /**
  20950. * Invert the geometry to move from a right handed system to a left handed one.
  20951. * @returns the current mesh
  20952. */
  20953. toLeftHanded(): Mesh;
  20954. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20955. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20956. /**
  20957. * Registers for this mesh a javascript function called just before the rendering process
  20958. * @param func defines the function to call before rendering this mesh
  20959. * @returns the current mesh
  20960. */
  20961. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20962. /**
  20963. * Disposes a previously registered javascript function called before the rendering
  20964. * @param func defines the function to remove
  20965. * @returns the current mesh
  20966. */
  20967. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20968. /**
  20969. * Registers for this mesh a javascript function called just after the rendering is complete
  20970. * @param func defines the function to call after rendering this mesh
  20971. * @returns the current mesh
  20972. */
  20973. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20974. /**
  20975. * Disposes a previously registered javascript function called after the rendering.
  20976. * @param func defines the function to remove
  20977. * @returns the current mesh
  20978. */
  20979. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20980. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20981. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20982. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20983. /** @hidden */ freeze(): void;
  20984. /** @hidden */ unFreeze(): void;
  20985. /**
  20986. * 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
  20987. * @param subMesh defines the subMesh to render
  20988. * @param enableAlphaMode defines if alpha mode can be changed
  20989. * @returns the current mesh
  20990. */
  20991. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20992. private _onBeforeDraw;
  20993. /**
  20994. * Renormalize the mesh and patch it up if there are no weights
  20995. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20996. * However in the case of zero weights then we set just a single influence to 1.
  20997. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20998. */
  20999. cleanMatrixWeights(): void;
  21000. private normalizeSkinFourWeights;
  21001. private normalizeSkinWeightsAndExtra;
  21002. /**
  21003. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21004. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21005. * the user know there was an issue with importing the mesh
  21006. * @returns a validation object with skinned, valid and report string
  21007. */
  21008. validateSkinning(): {
  21009. skinned: boolean;
  21010. valid: boolean;
  21011. report: string;
  21012. };
  21013. /** @hidden */ checkDelayState(): Mesh;
  21014. private _queueLoad;
  21015. /**
  21016. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21017. * A mesh is in the frustum if its bounding box intersects the frustum
  21018. * @param frustumPlanes defines the frustum to test
  21019. * @returns true if the mesh is in the frustum planes
  21020. */
  21021. isInFrustum(frustumPlanes: Plane[]): boolean;
  21022. /**
  21023. * Sets the mesh material by the material or multiMaterial `id` property
  21024. * @param id is a string identifying the material or the multiMaterial
  21025. * @returns the current mesh
  21026. */
  21027. setMaterialByID(id: string): Mesh;
  21028. /**
  21029. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21030. * @returns an array of IAnimatable
  21031. */
  21032. getAnimatables(): IAnimatable[];
  21033. /**
  21034. * Modifies the mesh geometry according to the passed transformation matrix.
  21035. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21036. * The mesh normals are modified using the same transformation.
  21037. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21038. * @param transform defines the transform matrix to use
  21039. * @see http://doc.babylonjs.com/resources/baking_transformations
  21040. * @returns the current mesh
  21041. */
  21042. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21043. /**
  21044. * Modifies the mesh geometry according to its own current World Matrix.
  21045. * The mesh World Matrix is then reset.
  21046. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21047. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21048. * @see http://doc.babylonjs.com/resources/baking_transformations
  21049. * @returns the current mesh
  21050. */
  21051. bakeCurrentTransformIntoVertices(): Mesh;
  21052. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  21053. /** @hidden */ resetPointsArrayCache(): Mesh;
  21054. /** @hidden */ generatePointsArray(): boolean;
  21055. /**
  21056. * Returns a new Mesh object generated from the current mesh properties.
  21057. * This method must not get confused with createInstance()
  21058. * @param name is a string, the name given to the new mesh
  21059. * @param newParent can be any Node object (default `null`)
  21060. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21061. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21062. * @returns a new mesh
  21063. */
  21064. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21065. /**
  21066. * Releases resources associated with this mesh.
  21067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21069. */
  21070. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21071. /**
  21072. * Modifies the mesh geometry according to a displacement map.
  21073. * 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.
  21074. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21075. * @param url is a string, the URL from the image file is to be downloaded.
  21076. * @param minHeight is the lower limit of the displacement.
  21077. * @param maxHeight is the upper limit of the displacement.
  21078. * @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.
  21079. * @param uvOffset is an optional vector2 used to offset UV.
  21080. * @param uvScale is an optional vector2 used to scale UV.
  21081. * @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.
  21082. * @returns the Mesh.
  21083. */
  21084. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21085. /**
  21086. * Modifies the mesh geometry according to a displacementMap buffer.
  21087. * 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.
  21088. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21089. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21090. * @param heightMapWidth is the width of the buffer image.
  21091. * @param heightMapHeight is the height of the buffer image.
  21092. * @param minHeight is the lower limit of the displacement.
  21093. * @param maxHeight is the upper limit of the displacement.
  21094. * @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.
  21095. * @param uvOffset is an optional vector2 used to offset UV.
  21096. * @param uvScale is an optional vector2 used to scale UV.
  21097. * @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.
  21098. * @returns the Mesh.
  21099. */
  21100. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21101. /**
  21102. * Modify the mesh to get a flat shading rendering.
  21103. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21104. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21105. * @returns current mesh
  21106. */
  21107. convertToFlatShadedMesh(): Mesh;
  21108. /**
  21109. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21110. * In other words, more vertices, no more indices and a single bigger VBO.
  21111. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21112. * @returns current mesh
  21113. */
  21114. convertToUnIndexedMesh(): Mesh;
  21115. /**
  21116. * Inverses facet orientations.
  21117. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21118. * @param flipNormals will also inverts the normals
  21119. * @returns current mesh
  21120. */
  21121. flipFaces(flipNormals?: boolean): Mesh;
  21122. /**
  21123. * Increase the number of facets and hence vertices in a mesh
  21124. * Vertex normals are interpolated from existing vertex normals
  21125. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21126. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21127. */
  21128. increaseVertices(numberPerEdge: number): void;
  21129. /**
  21130. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21131. * This will undo any application of covertToFlatShadedMesh
  21132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21133. */
  21134. forceSharedVertices(): void;
  21135. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21136. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21137. /**
  21138. * Creates a new InstancedMesh object from the mesh model.
  21139. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21140. * @param name defines the name of the new instance
  21141. * @returns a new InstancedMesh
  21142. */
  21143. createInstance(name: string): InstancedMesh;
  21144. /**
  21145. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21146. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21147. * @returns the current mesh
  21148. */
  21149. synchronizeInstances(): Mesh;
  21150. /**
  21151. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21152. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21153. * This should be used together with the simplification to avoid disappearing triangles.
  21154. * @param successCallback an optional success callback to be called after the optimization finished.
  21155. * @returns the current mesh
  21156. */
  21157. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21158. /**
  21159. * Serialize current mesh
  21160. * @param serializationObject defines the object which will receive the serialization data
  21161. */
  21162. serialize(serializationObject: any): void;
  21163. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21164. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21165. /**
  21166. * Returns a new Mesh object parsed from the source provided.
  21167. * @param parsedMesh is the source
  21168. * @param scene defines the hosting scene
  21169. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21170. * @returns a new Mesh
  21171. */
  21172. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21173. /**
  21174. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21175. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21176. * @param name defines the name of the mesh to create
  21177. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21178. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21179. * @param closePath creates a seam between the first and the last points of each path of the path array
  21180. * @param offset is taken in account only if the `pathArray` is containing a single path
  21181. * @param scene defines the hosting scene
  21182. * @param updatable defines if the mesh must be flagged as updatable
  21183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21184. * @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)
  21185. * @returns a new Mesh
  21186. */
  21187. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21188. /**
  21189. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21190. * @param name defines the name of the mesh to create
  21191. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21192. * @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
  21193. * @param scene defines the hosting scene
  21194. * @param updatable defines if the mesh must be flagged as updatable
  21195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21196. * @returns a new Mesh
  21197. */
  21198. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21199. /**
  21200. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21201. * @param name defines the name of the mesh to create
  21202. * @param size sets the size (float) of each box side (default 1)
  21203. * @param scene defines the hosting scene
  21204. * @param updatable defines if the mesh must be flagged as updatable
  21205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21206. * @returns a new Mesh
  21207. */
  21208. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21209. /**
  21210. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21211. * @param name defines the name of the mesh to create
  21212. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21213. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21214. * @param scene defines the hosting scene
  21215. * @param updatable defines if the mesh must be flagged as updatable
  21216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21217. * @returns a new Mesh
  21218. */
  21219. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21220. /**
  21221. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21222. * @param name defines the name of the mesh to create
  21223. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21224. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21225. * @param scene defines the hosting scene
  21226. * @returns a new Mesh
  21227. */
  21228. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21229. /**
  21230. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21231. * @param name defines the name of the mesh to create
  21232. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21233. * @param diameterTop set the top cap diameter (floats, default 1)
  21234. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21235. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21236. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21237. * @param scene defines the hosting scene
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21240. * @returns a new Mesh
  21241. */
  21242. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21243. /**
  21244. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21245. * @param name defines the name of the mesh to create
  21246. * @param diameter sets the diameter size (float) of the torus (default 1)
  21247. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21248. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21249. * @param scene defines the hosting scene
  21250. * @param updatable defines if the mesh must be flagged as updatable
  21251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21252. * @returns a new Mesh
  21253. */
  21254. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21255. /**
  21256. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21257. * @param name defines the name of the mesh to create
  21258. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21259. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21260. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21261. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21262. * @param p the number of windings on X axis (positive integers, default 2)
  21263. * @param q the number of windings on Y axis (positive integers, default 3)
  21264. * @param scene defines the hosting scene
  21265. * @param updatable defines if the mesh must be flagged as updatable
  21266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21267. * @returns a new Mesh
  21268. */
  21269. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21270. /**
  21271. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21272. * @param name defines the name of the mesh to create
  21273. * @param points is an array successive Vector3
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @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).
  21277. * @returns a new Mesh
  21278. */
  21279. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21280. /**
  21281. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21282. * @param name defines the name of the mesh to create
  21283. * @param points is an array successive Vector3
  21284. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21285. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21286. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21287. * @param scene defines the hosting scene
  21288. * @param updatable defines if the mesh must be flagged as updatable
  21289. * @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)
  21290. * @returns a new Mesh
  21291. */
  21292. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21293. /**
  21294. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21295. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21296. * 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.
  21297. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21298. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21299. * Remember you can only change the shape positions, not their number when updating a polygon.
  21300. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21301. * @param name defines the name of the mesh to create
  21302. * @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
  21303. * @param scene defines the hosting scene
  21304. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21305. * @param updatable defines if the mesh must be flagged as updatable
  21306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21307. * @param earcutInjection can be used to inject your own earcut reference
  21308. * @returns a new Mesh
  21309. */
  21310. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21311. /**
  21312. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21314. * @param name defines the name of the mesh to create
  21315. * @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
  21316. * @param depth defines the height of extrusion
  21317. * @param scene defines the hosting scene
  21318. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21319. * @param updatable defines if the mesh must be flagged as updatable
  21320. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21321. * @param earcutInjection can be used to inject your own earcut reference
  21322. * @returns a new Mesh
  21323. */
  21324. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21325. /**
  21326. * Creates an extruded shape mesh.
  21327. * 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
  21328. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21329. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21330. * @param name defines the name of the mesh to create
  21331. * @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
  21332. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21333. * @param scale is the value to scale the shape
  21334. * @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
  21335. * @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
  21336. * @param scene defines the hosting scene
  21337. * @param updatable defines if the mesh must be flagged as updatable
  21338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21339. * @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)
  21340. * @returns a new Mesh
  21341. */
  21342. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21343. /**
  21344. * Creates an custom extruded shape mesh.
  21345. * The custom extrusion is a parametric shape.
  21346. * It has no predefined shape. Its final shape will depend on the input parameters.
  21347. * Please consider using the same method from the MeshBuilder class instead
  21348. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21349. * @param name defines the name of the mesh to create
  21350. * @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
  21351. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21352. * @param scaleFunction is a custom Javascript function called on each path point
  21353. * @param rotationFunction is a custom Javascript function called on each path point
  21354. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21355. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21356. * @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
  21357. * @param scene defines the hosting scene
  21358. * @param updatable defines if the mesh must be flagged as updatable
  21359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21360. * @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)
  21361. * @returns a new Mesh
  21362. */
  21363. 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;
  21364. /**
  21365. * Creates lathe mesh.
  21366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21367. * Please consider using the same method from the MeshBuilder class instead
  21368. * @param name defines the name of the mesh to create
  21369. * @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
  21370. * @param radius is the radius value of the lathe
  21371. * @param tessellation is the side number of the lathe.
  21372. * @param scene defines the hosting scene
  21373. * @param updatable defines if the mesh must be flagged as updatable
  21374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21375. * @returns a new Mesh
  21376. */
  21377. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21378. /**
  21379. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21380. * @param name defines the name of the mesh to create
  21381. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21382. * @param scene defines the hosting scene
  21383. * @param updatable defines if the mesh must be flagged as updatable
  21384. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21385. * @returns a new Mesh
  21386. */
  21387. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21388. /**
  21389. * Creates a ground mesh.
  21390. * Please consider using the same method from the MeshBuilder class instead
  21391. * @param name defines the name of the mesh to create
  21392. * @param width set the width of the ground
  21393. * @param height set the height of the ground
  21394. * @param subdivisions sets the number of subdivisions per side
  21395. * @param scene defines the hosting scene
  21396. * @param updatable defines if the mesh must be flagged as updatable
  21397. * @returns a new Mesh
  21398. */
  21399. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21400. /**
  21401. * Creates a tiled ground mesh.
  21402. * Please consider using the same method from the MeshBuilder class instead
  21403. * @param name defines the name of the mesh to create
  21404. * @param xmin set the ground minimum X coordinate
  21405. * @param zmin set the ground minimum Y coordinate
  21406. * @param xmax set the ground maximum X coordinate
  21407. * @param zmax set the ground maximum Z coordinate
  21408. * @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
  21409. * @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
  21410. * @param scene defines the hosting scene
  21411. * @param updatable defines if the mesh must be flagged as updatable
  21412. * @returns a new Mesh
  21413. */
  21414. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21415. w: number;
  21416. h: number;
  21417. }, precision: {
  21418. w: number;
  21419. h: number;
  21420. }, scene: Scene, updatable?: boolean): Mesh;
  21421. /**
  21422. * Creates a ground mesh from a height map.
  21423. * Please consider using the same method from the MeshBuilder class instead
  21424. * @see http://doc.babylonjs.com/babylon101/height_map
  21425. * @param name defines the name of the mesh to create
  21426. * @param url sets the URL of the height map image resource
  21427. * @param width set the ground width size
  21428. * @param height set the ground height size
  21429. * @param subdivisions sets the number of subdivision per side
  21430. * @param minHeight is the minimum altitude on the ground
  21431. * @param maxHeight is the maximum altitude on the ground
  21432. * @param scene defines the hosting scene
  21433. * @param updatable defines if the mesh must be flagged as updatable
  21434. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21435. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21436. * @returns a new Mesh
  21437. */
  21438. 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;
  21439. /**
  21440. * Creates a tube mesh.
  21441. * The tube is a parametric shape.
  21442. * It has no predefined shape. Its final shape will depend on the input parameters.
  21443. * Please consider using the same method from the MeshBuilder class instead
  21444. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21445. * @param name defines the name of the mesh to create
  21446. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21447. * @param radius sets the tube radius size
  21448. * @param tessellation is the number of sides on the tubular surface
  21449. * @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
  21450. * @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
  21451. * @param scene defines the hosting scene
  21452. * @param updatable defines if the mesh must be flagged as updatable
  21453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21454. * @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)
  21455. * @returns a new Mesh
  21456. */
  21457. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21458. (i: number, distance: number): number;
  21459. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21460. /**
  21461. * Creates a polyhedron mesh.
  21462. * Please consider using the same method from the MeshBuilder class instead.
  21463. * * 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
  21464. * * The parameter `size` (positive float, default 1) sets the polygon size
  21465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21466. * * 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`
  21467. * * 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
  21468. * * 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)`)
  21469. * * 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
  21470. * * 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
  21471. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21472. * * 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
  21473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21474. * @param name defines the name of the mesh to create
  21475. * @param options defines the options used to create the mesh
  21476. * @param scene defines the hosting scene
  21477. * @returns a new Mesh
  21478. */
  21479. static CreatePolyhedron(name: string, options: {
  21480. type?: number;
  21481. size?: number;
  21482. sizeX?: number;
  21483. sizeY?: number;
  21484. sizeZ?: number;
  21485. custom?: any;
  21486. faceUV?: Vector4[];
  21487. faceColors?: Color4[];
  21488. updatable?: boolean;
  21489. sideOrientation?: number;
  21490. }, scene: Scene): Mesh;
  21491. /**
  21492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21494. * * 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`)
  21495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21496. * * 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
  21497. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21498. * * 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
  21499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21500. * @param name defines the name of the mesh
  21501. * @param options defines the options used to create the mesh
  21502. * @param scene defines the hosting scene
  21503. * @returns a new Mesh
  21504. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21505. */
  21506. static CreateIcoSphere(name: string, options: {
  21507. radius?: number;
  21508. flat?: boolean;
  21509. subdivisions?: number;
  21510. sideOrientation?: number;
  21511. updatable?: boolean;
  21512. }, scene: Scene): Mesh;
  21513. /**
  21514. * Creates a decal mesh.
  21515. * Please consider using the same method from the MeshBuilder class instead.
  21516. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21517. * @param name defines the name of the mesh
  21518. * @param sourceMesh defines the mesh receiving the decal
  21519. * @param position sets the position of the decal in world coordinates
  21520. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21521. * @param size sets the decal scaling
  21522. * @param angle sets the angle to rotate the decal
  21523. * @returns a new Mesh
  21524. */
  21525. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21526. /**
  21527. * Prepare internal position array for software CPU skinning
  21528. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21529. */
  21530. setPositionsForCPUSkinning(): Float32Array;
  21531. /**
  21532. * Prepare internal normal array for software CPU skinning
  21533. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21534. */
  21535. setNormalsForCPUSkinning(): Float32Array;
  21536. /**
  21537. * Updates the vertex buffer by applying transformation from the bones
  21538. * @param skeleton defines the skeleton to apply to current mesh
  21539. * @returns the current mesh
  21540. */
  21541. applySkeleton(skeleton: Skeleton): Mesh;
  21542. /**
  21543. * 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
  21544. * @param meshes defines the list of meshes to scan
  21545. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21546. */
  21547. static MinMax(meshes: AbstractMesh[]): {
  21548. min: Vector3;
  21549. max: Vector3;
  21550. };
  21551. /**
  21552. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21553. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21554. * @returns a vector3
  21555. */
  21556. static Center(meshesOrMinMaxVector: {
  21557. min: Vector3;
  21558. max: Vector3;
  21559. } | AbstractMesh[]): Vector3;
  21560. /**
  21561. * Merge the array of meshes into a single mesh for performance reasons.
  21562. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21563. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21564. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21565. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21566. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21567. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21568. * @returns a new mesh
  21569. */
  21570. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21571. /** @hidden */
  21572. addInstance(instance: InstancedMesh): void;
  21573. /** @hidden */
  21574. removeInstance(instance: InstancedMesh): void;
  21575. }
  21576. }
  21577. declare module BABYLON {
  21578. /**
  21579. * Base class for the main features of a material in Babylon.js
  21580. */
  21581. export class Material implements IAnimatable {
  21582. /**
  21583. * Returns the triangle fill mode
  21584. */
  21585. static readonly TriangleFillMode: number;
  21586. /**
  21587. * Returns the wireframe mode
  21588. */
  21589. static readonly WireFrameFillMode: number;
  21590. /**
  21591. * Returns the point fill mode
  21592. */
  21593. static readonly PointFillMode: number;
  21594. /**
  21595. * Returns the point list draw mode
  21596. */
  21597. static readonly PointListDrawMode: number;
  21598. /**
  21599. * Returns the line list draw mode
  21600. */
  21601. static readonly LineListDrawMode: number;
  21602. /**
  21603. * Returns the line loop draw mode
  21604. */
  21605. static readonly LineLoopDrawMode: number;
  21606. /**
  21607. * Returns the line strip draw mode
  21608. */
  21609. static readonly LineStripDrawMode: number;
  21610. /**
  21611. * Returns the triangle strip draw mode
  21612. */
  21613. static readonly TriangleStripDrawMode: number;
  21614. /**
  21615. * Returns the triangle fan draw mode
  21616. */
  21617. static readonly TriangleFanDrawMode: number;
  21618. /**
  21619. * Stores the clock-wise side orientation
  21620. */
  21621. static readonly ClockWiseSideOrientation: number;
  21622. /**
  21623. * Stores the counter clock-wise side orientation
  21624. */
  21625. static readonly CounterClockWiseSideOrientation: number;
  21626. /**
  21627. * The dirty texture flag value
  21628. */
  21629. static readonly TextureDirtyFlag: number;
  21630. /**
  21631. * The dirty light flag value
  21632. */
  21633. static readonly LightDirtyFlag: number;
  21634. /**
  21635. * The dirty fresnel flag value
  21636. */
  21637. static readonly FresnelDirtyFlag: number;
  21638. /**
  21639. * The dirty attribute flag value
  21640. */
  21641. static readonly AttributesDirtyFlag: number;
  21642. /**
  21643. * The dirty misc flag value
  21644. */
  21645. static readonly MiscDirtyFlag: number;
  21646. /**
  21647. * The all dirty flag value
  21648. */
  21649. static readonly AllDirtyFlag: number;
  21650. /**
  21651. * The ID of the material
  21652. */
  21653. id: string;
  21654. /**
  21655. * Gets or sets the unique id of the material
  21656. */
  21657. uniqueId: number;
  21658. /**
  21659. * The name of the material
  21660. */
  21661. name: string;
  21662. /**
  21663. * Gets or sets user defined metadata
  21664. */
  21665. metadata: any;
  21666. /**
  21667. * For internal use only. Please do not use.
  21668. */
  21669. reservedDataStore: any;
  21670. /**
  21671. * Specifies if the ready state should be checked on each call
  21672. */
  21673. checkReadyOnEveryCall: boolean;
  21674. /**
  21675. * Specifies if the ready state should be checked once
  21676. */
  21677. checkReadyOnlyOnce: boolean;
  21678. /**
  21679. * The state of the material
  21680. */
  21681. state: string;
  21682. /**
  21683. * The alpha value of the material
  21684. */
  21685. protected _alpha: number;
  21686. /**
  21687. * List of inspectable custom properties (used by the Inspector)
  21688. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21689. */
  21690. inspectableCustomProperties: IInspectable[];
  21691. /**
  21692. * Sets the alpha value of the material
  21693. */
  21694. /**
  21695. * Gets the alpha value of the material
  21696. */
  21697. alpha: number;
  21698. /**
  21699. * Specifies if back face culling is enabled
  21700. */
  21701. protected _backFaceCulling: boolean;
  21702. /**
  21703. * Sets the back-face culling state
  21704. */
  21705. /**
  21706. * Gets the back-face culling state
  21707. */
  21708. backFaceCulling: boolean;
  21709. /**
  21710. * Stores the value for side orientation
  21711. */
  21712. sideOrientation: number;
  21713. /**
  21714. * Callback triggered when the material is compiled
  21715. */
  21716. onCompiled: Nullable<(effect: Effect) => void>;
  21717. /**
  21718. * Callback triggered when an error occurs
  21719. */
  21720. onError: Nullable<(effect: Effect, errors: string) => void>;
  21721. /**
  21722. * Callback triggered to get the render target textures
  21723. */
  21724. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21725. /**
  21726. * Gets a boolean indicating that current material needs to register RTT
  21727. */
  21728. readonly hasRenderTargetTextures: boolean;
  21729. /**
  21730. * Specifies if the material should be serialized
  21731. */
  21732. doNotSerialize: boolean;
  21733. /**
  21734. * @hidden
  21735. */ storeEffectOnSubMeshes: boolean;
  21736. /**
  21737. * Stores the animations for the material
  21738. */
  21739. animations: Nullable<Array<Animation>>;
  21740. /**
  21741. * An event triggered when the material is disposed
  21742. */
  21743. onDisposeObservable: Observable<Material>;
  21744. /**
  21745. * An observer which watches for dispose events
  21746. */
  21747. private _onDisposeObserver;
  21748. private _onUnBindObservable;
  21749. /**
  21750. * Called during a dispose event
  21751. */
  21752. onDispose: () => void;
  21753. private _onBindObservable;
  21754. /**
  21755. * An event triggered when the material is bound
  21756. */
  21757. readonly onBindObservable: Observable<AbstractMesh>;
  21758. /**
  21759. * An observer which watches for bind events
  21760. */
  21761. private _onBindObserver;
  21762. /**
  21763. * Called during a bind event
  21764. */
  21765. onBind: (Mesh: AbstractMesh) => void;
  21766. /**
  21767. * An event triggered when the material is unbound
  21768. */
  21769. readonly onUnBindObservable: Observable<Material>;
  21770. /**
  21771. * Stores the value of the alpha mode
  21772. */
  21773. private _alphaMode;
  21774. /**
  21775. * Sets the value of the alpha mode.
  21776. *
  21777. * | Value | Type | Description |
  21778. * | --- | --- | --- |
  21779. * | 0 | ALPHA_DISABLE | |
  21780. * | 1 | ALPHA_ADD | |
  21781. * | 2 | ALPHA_COMBINE | |
  21782. * | 3 | ALPHA_SUBTRACT | |
  21783. * | 4 | ALPHA_MULTIPLY | |
  21784. * | 5 | ALPHA_MAXIMIZED | |
  21785. * | 6 | ALPHA_ONEONE | |
  21786. * | 7 | ALPHA_PREMULTIPLIED | |
  21787. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21788. * | 9 | ALPHA_INTERPOLATE | |
  21789. * | 10 | ALPHA_SCREENMODE | |
  21790. *
  21791. */
  21792. /**
  21793. * Gets the value of the alpha mode
  21794. */
  21795. alphaMode: number;
  21796. /**
  21797. * Stores the state of the need depth pre-pass value
  21798. */
  21799. private _needDepthPrePass;
  21800. /**
  21801. * Sets the need depth pre-pass value
  21802. */
  21803. /**
  21804. * Gets the depth pre-pass value
  21805. */
  21806. needDepthPrePass: boolean;
  21807. /**
  21808. * Specifies if depth writing should be disabled
  21809. */
  21810. disableDepthWrite: boolean;
  21811. /**
  21812. * Specifies if depth writing should be forced
  21813. */
  21814. forceDepthWrite: boolean;
  21815. /**
  21816. * Specifies if there should be a separate pass for culling
  21817. */
  21818. separateCullingPass: boolean;
  21819. /**
  21820. * Stores the state specifing if fog should be enabled
  21821. */
  21822. private _fogEnabled;
  21823. /**
  21824. * Sets the state for enabling fog
  21825. */
  21826. /**
  21827. * Gets the value of the fog enabled state
  21828. */
  21829. fogEnabled: boolean;
  21830. /**
  21831. * Stores the size of points
  21832. */
  21833. pointSize: number;
  21834. /**
  21835. * Stores the z offset value
  21836. */
  21837. zOffset: number;
  21838. /**
  21839. * Gets a value specifying if wireframe mode is enabled
  21840. */
  21841. /**
  21842. * Sets the state of wireframe mode
  21843. */
  21844. wireframe: boolean;
  21845. /**
  21846. * Gets the value specifying if point clouds are enabled
  21847. */
  21848. /**
  21849. * Sets the state of point cloud mode
  21850. */
  21851. pointsCloud: boolean;
  21852. /**
  21853. * Gets the material fill mode
  21854. */
  21855. /**
  21856. * Sets the material fill mode
  21857. */
  21858. fillMode: number;
  21859. /**
  21860. * @hidden
  21861. * Stores the effects for the material
  21862. */ effect: Nullable<Effect>;
  21863. /**
  21864. * @hidden
  21865. * Specifies if the material was previously ready
  21866. */ wasPreviouslyReady: boolean;
  21867. /**
  21868. * Specifies if uniform buffers should be used
  21869. */
  21870. private _useUBO;
  21871. /**
  21872. * Stores a reference to the scene
  21873. */
  21874. private _scene;
  21875. /**
  21876. * Stores the fill mode state
  21877. */
  21878. private _fillMode;
  21879. /**
  21880. * Specifies if the depth write state should be cached
  21881. */
  21882. private _cachedDepthWriteState;
  21883. /**
  21884. * Stores the uniform buffer
  21885. */
  21886. protected _uniformBuffer: UniformBuffer;
  21887. /** @hidden */ indexInSceneMaterialArray: number;
  21888. /** @hidden */
  21889. meshMap: Nullable<{
  21890. [id: string]: AbstractMesh | undefined;
  21891. }>;
  21892. /**
  21893. * Creates a material instance
  21894. * @param name defines the name of the material
  21895. * @param scene defines the scene to reference
  21896. * @param doNotAdd specifies if the material should be added to the scene
  21897. */
  21898. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21899. /**
  21900. * Returns a string representation of the current material
  21901. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21902. * @returns a string with material information
  21903. */
  21904. toString(fullDetails?: boolean): string;
  21905. /**
  21906. * Gets the class name of the material
  21907. * @returns a string with the class name of the material
  21908. */
  21909. getClassName(): string;
  21910. /**
  21911. * Specifies if updates for the material been locked
  21912. */
  21913. readonly isFrozen: boolean;
  21914. /**
  21915. * Locks updates for the material
  21916. */
  21917. freeze(): void;
  21918. /**
  21919. * Unlocks updates for the material
  21920. */
  21921. unfreeze(): void;
  21922. /**
  21923. * Specifies if the material is ready to be used
  21924. * @param mesh defines the mesh to check
  21925. * @param useInstances specifies if instances should be used
  21926. * @returns a boolean indicating if the material is ready to be used
  21927. */
  21928. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21929. /**
  21930. * Specifies that the submesh is ready to be used
  21931. * @param mesh defines the mesh to check
  21932. * @param subMesh defines which submesh to check
  21933. * @param useInstances specifies that instances should be used
  21934. * @returns a boolean indicating that the submesh is ready or not
  21935. */
  21936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21937. /**
  21938. * Returns the material effect
  21939. * @returns the effect associated with the material
  21940. */
  21941. getEffect(): Nullable<Effect>;
  21942. /**
  21943. * Returns the current scene
  21944. * @returns a Scene
  21945. */
  21946. getScene(): Scene;
  21947. /**
  21948. * Specifies if the material will require alpha blending
  21949. * @returns a boolean specifying if alpha blending is needed
  21950. */
  21951. needAlphaBlending(): boolean;
  21952. /**
  21953. * Specifies if the mesh will require alpha blending
  21954. * @param mesh defines the mesh to check
  21955. * @returns a boolean specifying if alpha blending is needed for the mesh
  21956. */
  21957. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21958. /**
  21959. * Specifies if this material should be rendered in alpha test mode
  21960. * @returns a boolean specifying if an alpha test is needed.
  21961. */
  21962. needAlphaTesting(): boolean;
  21963. /**
  21964. * Gets the texture used for the alpha test
  21965. * @returns the texture to use for alpha testing
  21966. */
  21967. getAlphaTestTexture(): Nullable<BaseTexture>;
  21968. /**
  21969. * Marks the material to indicate that it needs to be re-calculated
  21970. */
  21971. markDirty(): void;
  21972. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21973. /**
  21974. * Binds the material to the mesh
  21975. * @param world defines the world transformation matrix
  21976. * @param mesh defines the mesh to bind the material to
  21977. */
  21978. bind(world: Matrix, mesh?: Mesh): void;
  21979. /**
  21980. * Binds the submesh to the material
  21981. * @param world defines the world transformation matrix
  21982. * @param mesh defines the mesh containing the submesh
  21983. * @param subMesh defines the submesh to bind the material to
  21984. */
  21985. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21986. /**
  21987. * Binds the world matrix to the material
  21988. * @param world defines the world transformation matrix
  21989. */
  21990. bindOnlyWorldMatrix(world: Matrix): void;
  21991. /**
  21992. * Binds the scene's uniform buffer to the effect.
  21993. * @param effect defines the effect to bind to the scene uniform buffer
  21994. * @param sceneUbo defines the uniform buffer storing scene data
  21995. */
  21996. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21997. /**
  21998. * Binds the view matrix to the effect
  21999. * @param effect defines the effect to bind the view matrix to
  22000. */
  22001. bindView(effect: Effect): void;
  22002. /**
  22003. * Binds the view projection matrix to the effect
  22004. * @param effect defines the effect to bind the view projection matrix to
  22005. */
  22006. bindViewProjection(effect: Effect): void;
  22007. /**
  22008. * Specifies if material alpha testing should be turned on for the mesh
  22009. * @param mesh defines the mesh to check
  22010. */
  22011. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22012. /**
  22013. * Processes to execute after binding the material to a mesh
  22014. * @param mesh defines the rendered mesh
  22015. */
  22016. protected _afterBind(mesh?: Mesh): void;
  22017. /**
  22018. * Unbinds the material from the mesh
  22019. */
  22020. unbind(): void;
  22021. /**
  22022. * Gets the active textures from the material
  22023. * @returns an array of textures
  22024. */
  22025. getActiveTextures(): BaseTexture[];
  22026. /**
  22027. * Specifies if the material uses a texture
  22028. * @param texture defines the texture to check against the material
  22029. * @returns a boolean specifying if the material uses the texture
  22030. */
  22031. hasTexture(texture: BaseTexture): boolean;
  22032. /**
  22033. * Makes a duplicate of the material, and gives it a new name
  22034. * @param name defines the new name for the duplicated material
  22035. * @returns the cloned material
  22036. */
  22037. clone(name: string): Nullable<Material>;
  22038. /**
  22039. * Gets the meshes bound to the material
  22040. * @returns an array of meshes bound to the material
  22041. */
  22042. getBindedMeshes(): AbstractMesh[];
  22043. /**
  22044. * Force shader compilation
  22045. * @param mesh defines the mesh associated with this material
  22046. * @param onCompiled defines a function to execute once the material is compiled
  22047. * @param options defines the options to configure the compilation
  22048. */
  22049. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22050. clipPlane: boolean;
  22051. }>): void;
  22052. /**
  22053. * Force shader compilation
  22054. * @param mesh defines the mesh that will use this material
  22055. * @param options defines additional options for compiling the shaders
  22056. * @returns a promise that resolves when the compilation completes
  22057. */
  22058. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22059. clipPlane: boolean;
  22060. }>): Promise<void>;
  22061. private static readonly _ImageProcessingDirtyCallBack;
  22062. private static readonly _TextureDirtyCallBack;
  22063. private static readonly _FresnelDirtyCallBack;
  22064. private static readonly _MiscDirtyCallBack;
  22065. private static readonly _LightsDirtyCallBack;
  22066. private static readonly _AttributeDirtyCallBack;
  22067. private static _FresnelAndMiscDirtyCallBack;
  22068. private static _TextureAndMiscDirtyCallBack;
  22069. private static readonly _DirtyCallbackArray;
  22070. private static readonly _RunDirtyCallBacks;
  22071. /**
  22072. * Marks a define in the material to indicate that it needs to be re-computed
  22073. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22074. */
  22075. markAsDirty(flag: number): void;
  22076. /**
  22077. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22078. * @param func defines a function which checks material defines against the submeshes
  22079. */
  22080. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22081. /**
  22082. * Indicates that image processing needs to be re-calculated for all submeshes
  22083. */
  22084. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22085. /**
  22086. * Indicates that textures need to be re-calculated for all submeshes
  22087. */
  22088. protected _markAllSubMeshesAsTexturesDirty(): void;
  22089. /**
  22090. * Indicates that fresnel needs to be re-calculated for all submeshes
  22091. */
  22092. protected _markAllSubMeshesAsFresnelDirty(): void;
  22093. /**
  22094. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22095. */
  22096. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22097. /**
  22098. * Indicates that lights need to be re-calculated for all submeshes
  22099. */
  22100. protected _markAllSubMeshesAsLightsDirty(): void;
  22101. /**
  22102. * Indicates that attributes need to be re-calculated for all submeshes
  22103. */
  22104. protected _markAllSubMeshesAsAttributesDirty(): void;
  22105. /**
  22106. * Indicates that misc needs to be re-calculated for all submeshes
  22107. */
  22108. protected _markAllSubMeshesAsMiscDirty(): void;
  22109. /**
  22110. * Indicates that textures and misc need to be re-calculated for all submeshes
  22111. */
  22112. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22113. /**
  22114. * Disposes the material
  22115. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22116. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22117. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22118. */
  22119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22120. /** @hidden */
  22121. private releaseVertexArrayObject;
  22122. /**
  22123. * Serializes this material
  22124. * @returns the serialized material object
  22125. */
  22126. serialize(): any;
  22127. /**
  22128. * Creates a material from parsed material data
  22129. * @param parsedMaterial defines parsed material data
  22130. * @param scene defines the hosting scene
  22131. * @param rootUrl defines the root URL to use to load textures
  22132. * @returns a new material
  22133. */
  22134. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22135. }
  22136. }
  22137. declare module BABYLON {
  22138. /**
  22139. * Base class for submeshes
  22140. */
  22141. export class BaseSubMesh {
  22142. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22143. /** @hidden */ materialEffect: Nullable<Effect>;
  22144. /**
  22145. * Gets associated effect
  22146. */
  22147. readonly effect: Nullable<Effect>;
  22148. /**
  22149. * Sets associated effect (effect used to render this submesh)
  22150. * @param effect defines the effect to associate with
  22151. * @param defines defines the set of defines used to compile this effect
  22152. */
  22153. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22154. }
  22155. /**
  22156. * Defines a subdivision inside a mesh
  22157. */
  22158. export class SubMesh extends BaseSubMesh implements ICullable {
  22159. /** the material index to use */
  22160. materialIndex: number;
  22161. /** vertex index start */
  22162. verticesStart: number;
  22163. /** vertices count */
  22164. verticesCount: number;
  22165. /** index start */
  22166. indexStart: number;
  22167. /** indices count */
  22168. indexCount: number;
  22169. /** @hidden */ linesIndexCount: number;
  22170. private _mesh;
  22171. private _renderingMesh;
  22172. private _boundingInfo;
  22173. private _linesIndexBuffer;
  22174. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22175. /** @hidden */ trianglePlanes: Plane[];
  22176. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22177. /** @hidden */ renderId: number;
  22178. /** @hidden */ alphaIndex: number;
  22179. /** @hidden */ distanceToCamera: number;
  22180. /** @hidden */ id: number;
  22181. private _currentMaterial;
  22182. /**
  22183. * Add a new submesh to a mesh
  22184. * @param materialIndex defines the material index to use
  22185. * @param verticesStart defines vertex index start
  22186. * @param verticesCount defines vertices count
  22187. * @param indexStart defines index start
  22188. * @param indexCount defines indices count
  22189. * @param mesh defines the parent mesh
  22190. * @param renderingMesh defines an optional rendering mesh
  22191. * @param createBoundingBox defines if bounding box should be created for this submesh
  22192. * @returns the new submesh
  22193. */
  22194. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22195. /**
  22196. * Creates a new submesh
  22197. * @param materialIndex defines the material index to use
  22198. * @param verticesStart defines vertex index start
  22199. * @param verticesCount defines vertices count
  22200. * @param indexStart defines index start
  22201. * @param indexCount defines indices count
  22202. * @param mesh defines the parent mesh
  22203. * @param renderingMesh defines an optional rendering mesh
  22204. * @param createBoundingBox defines if bounding box should be created for this submesh
  22205. */
  22206. constructor(
  22207. /** the material index to use */
  22208. materialIndex: number,
  22209. /** vertex index start */
  22210. verticesStart: number,
  22211. /** vertices count */
  22212. verticesCount: number,
  22213. /** index start */
  22214. indexStart: number,
  22215. /** indices count */
  22216. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22217. /**
  22218. * Returns true if this submesh covers the entire parent mesh
  22219. * @ignorenaming
  22220. */
  22221. readonly IsGlobal: boolean;
  22222. /**
  22223. * Returns the submesh BoudingInfo object
  22224. * @returns current bounding info (or mesh's one if the submesh is global)
  22225. */
  22226. getBoundingInfo(): BoundingInfo;
  22227. /**
  22228. * Sets the submesh BoundingInfo
  22229. * @param boundingInfo defines the new bounding info to use
  22230. * @returns the SubMesh
  22231. */
  22232. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22233. /**
  22234. * Returns the mesh of the current submesh
  22235. * @return the parent mesh
  22236. */
  22237. getMesh(): AbstractMesh;
  22238. /**
  22239. * Returns the rendering mesh of the submesh
  22240. * @returns the rendering mesh (could be different from parent mesh)
  22241. */
  22242. getRenderingMesh(): Mesh;
  22243. /**
  22244. * Returns the submesh material
  22245. * @returns null or the current material
  22246. */
  22247. getMaterial(): Nullable<Material>;
  22248. /**
  22249. * Sets a new updated BoundingInfo object to the submesh
  22250. * @param data defines an optional position array to use to determine the bounding info
  22251. * @returns the SubMesh
  22252. */
  22253. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22254. /** @hidden */ checkCollision(collider: Collider): boolean;
  22255. /**
  22256. * Updates the submesh BoundingInfo
  22257. * @param world defines the world matrix to use to update the bounding info
  22258. * @returns the submesh
  22259. */
  22260. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22261. /**
  22262. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22263. * @param frustumPlanes defines the frustum planes
  22264. * @returns true if the submesh is intersecting with the frustum
  22265. */
  22266. isInFrustum(frustumPlanes: Plane[]): boolean;
  22267. /**
  22268. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22269. * @param frustumPlanes defines the frustum planes
  22270. * @returns true if the submesh is inside the frustum
  22271. */
  22272. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22273. /**
  22274. * Renders the submesh
  22275. * @param enableAlphaMode defines if alpha needs to be used
  22276. * @returns the submesh
  22277. */
  22278. render(enableAlphaMode: boolean): SubMesh;
  22279. /**
  22280. * @hidden
  22281. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22282. /**
  22283. * Checks if the submesh intersects with a ray
  22284. * @param ray defines the ray to test
  22285. * @returns true is the passed ray intersects the submesh bounding box
  22286. */
  22287. canIntersects(ray: Ray): boolean;
  22288. /**
  22289. * Intersects current submesh with a ray
  22290. * @param ray defines the ray to test
  22291. * @param positions defines mesh's positions array
  22292. * @param indices defines mesh's indices array
  22293. * @param fastCheck defines if only bounding info should be used
  22294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22295. * @returns intersection info or null if no intersection
  22296. */
  22297. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22298. /** @hidden */
  22299. private _intersectLines;
  22300. /** @hidden */
  22301. private _intersectTriangles;
  22302. /** @hidden */ rebuild(): void;
  22303. /**
  22304. * Creates a new submesh from the passed mesh
  22305. * @param newMesh defines the new hosting mesh
  22306. * @param newRenderingMesh defines an optional rendering mesh
  22307. * @returns the new submesh
  22308. */
  22309. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22310. /**
  22311. * Release associated resources
  22312. */
  22313. dispose(): void;
  22314. /**
  22315. * Gets the class name
  22316. * @returns the string "SubMesh".
  22317. */
  22318. getClassName(): string;
  22319. /**
  22320. * Creates a new submesh from indices data
  22321. * @param materialIndex the index of the main mesh material
  22322. * @param startIndex the index where to start the copy in the mesh indices array
  22323. * @param indexCount the number of indices to copy then from the startIndex
  22324. * @param mesh the main mesh to create the submesh from
  22325. * @param renderingMesh the optional rendering mesh
  22326. * @returns a new submesh
  22327. */
  22328. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22329. }
  22330. }
  22331. declare module BABYLON {
  22332. /**
  22333. * Class used to store geometry data (vertex buffers + index buffer)
  22334. */
  22335. export class Geometry implements IGetSetVerticesData {
  22336. /**
  22337. * Gets or sets the ID of the geometry
  22338. */
  22339. id: string;
  22340. /**
  22341. * Gets or sets the unique ID of the geometry
  22342. */
  22343. uniqueId: number;
  22344. /**
  22345. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22346. */
  22347. delayLoadState: number;
  22348. /**
  22349. * Gets the file containing the data to load when running in delay load state
  22350. */
  22351. delayLoadingFile: Nullable<string>;
  22352. /**
  22353. * Callback called when the geometry is updated
  22354. */
  22355. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22356. private _scene;
  22357. private _engine;
  22358. private _meshes;
  22359. private _totalVertices;
  22360. /** @hidden */ indices: IndicesArray;
  22361. /** @hidden */ vertexBuffers: {
  22362. [key: string]: VertexBuffer;
  22363. };
  22364. private _isDisposed;
  22365. private _extend;
  22366. private _boundingBias;
  22367. /** @hidden */ delayInfo: Array<string>;
  22368. private _indexBuffer;
  22369. private _indexBufferIsUpdatable;
  22370. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22371. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22372. /** @hidden */ softwareSkinningFrameId: number;
  22373. private _vertexArrayObjects;
  22374. private _updatable;
  22375. /** @hidden */ positions: Nullable<Vector3[]>;
  22376. /**
  22377. * 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
  22378. */
  22379. /**
  22380. * 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
  22381. */
  22382. boundingBias: Vector2;
  22383. /**
  22384. * Static function used to attach a new empty geometry to a mesh
  22385. * @param mesh defines the mesh to attach the geometry to
  22386. * @returns the new Geometry
  22387. */
  22388. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22389. /**
  22390. * Creates a new geometry
  22391. * @param id defines the unique ID
  22392. * @param scene defines the hosting scene
  22393. * @param vertexData defines the VertexData used to get geometry data
  22394. * @param updatable defines if geometry must be updatable (false by default)
  22395. * @param mesh defines the mesh that will be associated with the geometry
  22396. */
  22397. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22398. /**
  22399. * Gets the current extend of the geometry
  22400. */
  22401. readonly extend: {
  22402. minimum: Vector3;
  22403. maximum: Vector3;
  22404. };
  22405. /**
  22406. * Gets the hosting scene
  22407. * @returns the hosting Scene
  22408. */
  22409. getScene(): Scene;
  22410. /**
  22411. * Gets the hosting engine
  22412. * @returns the hosting Engine
  22413. */
  22414. getEngine(): Engine;
  22415. /**
  22416. * Defines if the geometry is ready to use
  22417. * @returns true if the geometry is ready to be used
  22418. */
  22419. isReady(): boolean;
  22420. /**
  22421. * Gets a value indicating that the geometry should not be serialized
  22422. */
  22423. readonly doNotSerialize: boolean;
  22424. /** @hidden */ rebuild(): void;
  22425. /**
  22426. * Affects all geometry data in one call
  22427. * @param vertexData defines the geometry data
  22428. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22429. */
  22430. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22431. /**
  22432. * Set specific vertex data
  22433. * @param kind defines the data kind (Position, normal, etc...)
  22434. * @param data defines the vertex data to use
  22435. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22436. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22437. */
  22438. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22439. /**
  22440. * Removes a specific vertex data
  22441. * @param kind defines the data kind (Position, normal, etc...)
  22442. */
  22443. removeVerticesData(kind: string): void;
  22444. /**
  22445. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22446. * @param buffer defines the vertex buffer to use
  22447. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22448. */
  22449. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22450. /**
  22451. * Update a specific vertex buffer
  22452. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22453. * It will do nothing if the buffer is not updatable
  22454. * @param kind defines the data kind (Position, normal, etc...)
  22455. * @param data defines the data to use
  22456. * @param offset defines the offset in the target buffer where to store the data
  22457. * @param useBytes set to true if the offset is in bytes
  22458. */
  22459. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22460. /**
  22461. * Update a specific vertex buffer
  22462. * This function will create a new buffer if the current one is not updatable
  22463. * @param kind defines the data kind (Position, normal, etc...)
  22464. * @param data defines the data to use
  22465. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22466. */
  22467. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22468. private _updateBoundingInfo;
  22469. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22470. /**
  22471. * Gets total number of vertices
  22472. * @returns the total number of vertices
  22473. */
  22474. getTotalVertices(): number;
  22475. /**
  22476. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22477. * @param kind defines the data kind (Position, normal, etc...)
  22478. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22479. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22480. * @returns a float array containing vertex data
  22481. */
  22482. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22483. /**
  22484. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22485. * @param kind defines the data kind (Position, normal, etc...)
  22486. * @returns true if the vertex buffer with the specified kind is updatable
  22487. */
  22488. isVertexBufferUpdatable(kind: string): boolean;
  22489. /**
  22490. * Gets a specific vertex buffer
  22491. * @param kind defines the data kind (Position, normal, etc...)
  22492. * @returns a VertexBuffer
  22493. */
  22494. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22495. /**
  22496. * Returns all vertex buffers
  22497. * @return an object holding all vertex buffers indexed by kind
  22498. */
  22499. getVertexBuffers(): Nullable<{
  22500. [key: string]: VertexBuffer;
  22501. }>;
  22502. /**
  22503. * Gets a boolean indicating if specific vertex buffer is present
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if data is present
  22506. */
  22507. isVerticesDataPresent(kind: string): boolean;
  22508. /**
  22509. * Gets a list of all attached data kinds (Position, normal, etc...)
  22510. * @returns a list of string containing all kinds
  22511. */
  22512. getVerticesDataKinds(): string[];
  22513. /**
  22514. * Update index buffer
  22515. * @param indices defines the indices to store in the index buffer
  22516. * @param offset defines the offset in the target buffer where to store the data
  22517. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22518. */
  22519. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22520. /**
  22521. * Creates a new index buffer
  22522. * @param indices defines the indices to store in the index buffer
  22523. * @param totalVertices defines the total number of vertices (could be null)
  22524. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22525. */
  22526. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22527. /**
  22528. * Return the total number of indices
  22529. * @returns the total number of indices
  22530. */
  22531. getTotalIndices(): number;
  22532. /**
  22533. * Gets the index buffer array
  22534. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22535. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22536. * @returns the index buffer array
  22537. */
  22538. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22539. /**
  22540. * Gets the index buffer
  22541. * @return the index buffer
  22542. */
  22543. getIndexBuffer(): Nullable<DataBuffer>;
  22544. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22545. /**
  22546. * Release the associated resources for a specific mesh
  22547. * @param mesh defines the source mesh
  22548. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22549. */
  22550. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22551. /**
  22552. * Apply current geometry to a given mesh
  22553. * @param mesh defines the mesh to apply geometry to
  22554. */
  22555. applyToMesh(mesh: Mesh): void;
  22556. private _updateExtend;
  22557. private _applyToMesh;
  22558. private notifyUpdate;
  22559. /**
  22560. * Load the geometry if it was flagged as delay loaded
  22561. * @param scene defines the hosting scene
  22562. * @param onLoaded defines a callback called when the geometry is loaded
  22563. */
  22564. load(scene: Scene, onLoaded?: () => void): void;
  22565. private _queueLoad;
  22566. /**
  22567. * Invert the geometry to move from a right handed system to a left handed one.
  22568. */
  22569. toLeftHanded(): void;
  22570. /** @hidden */ resetPointsArrayCache(): void;
  22571. /** @hidden */ generatePointsArray(): boolean;
  22572. /**
  22573. * Gets a value indicating if the geometry is disposed
  22574. * @returns true if the geometry was disposed
  22575. */
  22576. isDisposed(): boolean;
  22577. private _disposeVertexArrayObjects;
  22578. /**
  22579. * Free all associated resources
  22580. */
  22581. dispose(): void;
  22582. /**
  22583. * Clone the current geometry into a new geometry
  22584. * @param id defines the unique ID of the new geometry
  22585. * @returns a new geometry object
  22586. */
  22587. copy(id: string): Geometry;
  22588. /**
  22589. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22590. * @return a JSON representation of the current geometry data (without the vertices data)
  22591. */
  22592. serialize(): any;
  22593. private toNumberArray;
  22594. /**
  22595. * Serialize all vertices data into a JSON oject
  22596. * @returns a JSON representation of the current geometry data
  22597. */
  22598. serializeVerticeData(): any;
  22599. /**
  22600. * Extracts a clone of a mesh geometry
  22601. * @param mesh defines the source mesh
  22602. * @param id defines the unique ID of the new geometry object
  22603. * @returns the new geometry object
  22604. */
  22605. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22606. /**
  22607. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22608. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22609. * Be aware Math.random() could cause collisions, but:
  22610. * "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"
  22611. * @returns a string containing a new GUID
  22612. */
  22613. static RandomId(): string;
  22614. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22615. private static _CleanMatricesWeights;
  22616. /**
  22617. * Create a new geometry from persisted data (Using .babylon file format)
  22618. * @param parsedVertexData defines the persisted data
  22619. * @param scene defines the hosting scene
  22620. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22621. * @returns the new geometry object
  22622. */
  22623. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22624. }
  22625. }
  22626. declare module BABYLON {
  22627. /**
  22628. * Define an interface for all classes that will get and set the data on vertices
  22629. */
  22630. export interface IGetSetVerticesData {
  22631. /**
  22632. * Gets a boolean indicating if specific vertex data is present
  22633. * @param kind defines the vertex data kind to use
  22634. * @returns true is data kind is present
  22635. */
  22636. isVerticesDataPresent(kind: string): boolean;
  22637. /**
  22638. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22639. * @param kind defines the data kind (Position, normal, etc...)
  22640. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22641. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22642. * @returns a float array containing vertex data
  22643. */
  22644. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22645. /**
  22646. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22647. * @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.
  22648. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22649. * @returns the indices array or an empty array if the mesh has no geometry
  22650. */
  22651. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22652. /**
  22653. * Set specific vertex data
  22654. * @param kind defines the data kind (Position, normal, etc...)
  22655. * @param data defines the vertex data to use
  22656. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22657. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22658. */
  22659. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22660. /**
  22661. * Update a specific associated vertex buffer
  22662. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22663. * - VertexBuffer.PositionKind
  22664. * - VertexBuffer.UVKind
  22665. * - VertexBuffer.UV2Kind
  22666. * - VertexBuffer.UV3Kind
  22667. * - VertexBuffer.UV4Kind
  22668. * - VertexBuffer.UV5Kind
  22669. * - VertexBuffer.UV6Kind
  22670. * - VertexBuffer.ColorKind
  22671. * - VertexBuffer.MatricesIndicesKind
  22672. * - VertexBuffer.MatricesIndicesExtraKind
  22673. * - VertexBuffer.MatricesWeightsKind
  22674. * - VertexBuffer.MatricesWeightsExtraKind
  22675. * @param data defines the data source
  22676. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22677. * @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)
  22678. */
  22679. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22680. /**
  22681. * Creates a new index buffer
  22682. * @param indices defines the indices to store in the index buffer
  22683. * @param totalVertices defines the total number of vertices (could be null)
  22684. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22685. */
  22686. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22687. }
  22688. /**
  22689. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22690. */
  22691. export class VertexData {
  22692. /**
  22693. * Mesh side orientation : usually the external or front surface
  22694. */
  22695. static readonly FRONTSIDE: number;
  22696. /**
  22697. * Mesh side orientation : usually the internal or back surface
  22698. */
  22699. static readonly BACKSIDE: number;
  22700. /**
  22701. * Mesh side orientation : both internal and external or front and back surfaces
  22702. */
  22703. static readonly DOUBLESIDE: number;
  22704. /**
  22705. * Mesh side orientation : by default, `FRONTSIDE`
  22706. */
  22707. static readonly DEFAULTSIDE: number;
  22708. /**
  22709. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22710. */
  22711. positions: Nullable<FloatArray>;
  22712. /**
  22713. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22714. */
  22715. normals: Nullable<FloatArray>;
  22716. /**
  22717. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22718. */
  22719. tangents: Nullable<FloatArray>;
  22720. /**
  22721. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22722. */
  22723. uvs: Nullable<FloatArray>;
  22724. /**
  22725. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22726. */
  22727. uvs2: Nullable<FloatArray>;
  22728. /**
  22729. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22730. */
  22731. uvs3: Nullable<FloatArray>;
  22732. /**
  22733. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22734. */
  22735. uvs4: Nullable<FloatArray>;
  22736. /**
  22737. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22738. */
  22739. uvs5: Nullable<FloatArray>;
  22740. /**
  22741. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22742. */
  22743. uvs6: Nullable<FloatArray>;
  22744. /**
  22745. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22746. */
  22747. colors: Nullable<FloatArray>;
  22748. /**
  22749. * 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).
  22750. */
  22751. matricesIndices: Nullable<FloatArray>;
  22752. /**
  22753. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22754. */
  22755. matricesWeights: Nullable<FloatArray>;
  22756. /**
  22757. * An array extending the number of possible indices
  22758. */
  22759. matricesIndicesExtra: Nullable<FloatArray>;
  22760. /**
  22761. * An array extending the number of possible weights when the number of indices is extended
  22762. */
  22763. matricesWeightsExtra: Nullable<FloatArray>;
  22764. /**
  22765. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22766. */
  22767. indices: Nullable<IndicesArray>;
  22768. /**
  22769. * Uses the passed data array to set the set the values for the specified kind of data
  22770. * @param data a linear array of floating numbers
  22771. * @param kind the type of data that is being set, eg positions, colors etc
  22772. */
  22773. set(data: FloatArray, kind: string): void;
  22774. /**
  22775. * Associates the vertexData to the passed Mesh.
  22776. * Sets it as updatable or not (default `false`)
  22777. * @param mesh the mesh the vertexData is applied to
  22778. * @param updatable when used and having the value true allows new data to update the vertexData
  22779. * @returns the VertexData
  22780. */
  22781. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22782. /**
  22783. * Associates the vertexData to the passed Geometry.
  22784. * Sets it as updatable or not (default `false`)
  22785. * @param geometry the geometry the vertexData is applied to
  22786. * @param updatable when used and having the value true allows new data to update the vertexData
  22787. * @returns VertexData
  22788. */
  22789. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22790. /**
  22791. * Updates the associated mesh
  22792. * @param mesh the mesh to be updated
  22793. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22794. * @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
  22795. * @returns VertexData
  22796. */
  22797. updateMesh(mesh: Mesh): VertexData;
  22798. /**
  22799. * Updates the associated geometry
  22800. * @param geometry the geometry to be updated
  22801. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22802. * @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
  22803. * @returns VertexData.
  22804. */
  22805. updateGeometry(geometry: Geometry): VertexData;
  22806. private _applyTo;
  22807. private _update;
  22808. /**
  22809. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22810. * @param matrix the transforming matrix
  22811. * @returns the VertexData
  22812. */
  22813. transform(matrix: Matrix): VertexData;
  22814. /**
  22815. * Merges the passed VertexData into the current one
  22816. * @param other the VertexData to be merged into the current one
  22817. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22818. * @returns the modified VertexData
  22819. */
  22820. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22821. private _mergeElement;
  22822. private _validate;
  22823. /**
  22824. * Serializes the VertexData
  22825. * @returns a serialized object
  22826. */
  22827. serialize(): any;
  22828. /**
  22829. * Extracts the vertexData from a mesh
  22830. * @param mesh the mesh from which to extract the VertexData
  22831. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22832. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22833. * @returns the object VertexData associated to the passed mesh
  22834. */
  22835. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22836. /**
  22837. * Extracts the vertexData from the geometry
  22838. * @param geometry the geometry from which to extract the VertexData
  22839. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22840. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22841. * @returns the object VertexData associated to the passed mesh
  22842. */
  22843. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22844. private static _ExtractFrom;
  22845. /**
  22846. * Creates the VertexData for a Ribbon
  22847. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22848. * * pathArray array of paths, each of which an array of successive Vector3
  22849. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22850. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22851. * * 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
  22852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22853. * * 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)
  22854. * * 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)
  22855. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22856. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22857. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22858. * @returns the VertexData of the ribbon
  22859. */
  22860. static CreateRibbon(options: {
  22861. pathArray: Vector3[][];
  22862. closeArray?: boolean;
  22863. closePath?: boolean;
  22864. offset?: number;
  22865. sideOrientation?: number;
  22866. frontUVs?: Vector4;
  22867. backUVs?: Vector4;
  22868. invertUV?: boolean;
  22869. uvs?: Vector2[];
  22870. colors?: Color4[];
  22871. }): VertexData;
  22872. /**
  22873. * Creates the VertexData for a box
  22874. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22875. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22876. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22877. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22878. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22879. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22880. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22881. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22882. * * 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)
  22883. * * 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)
  22884. * @returns the VertexData of the box
  22885. */
  22886. static CreateBox(options: {
  22887. size?: number;
  22888. width?: number;
  22889. height?: number;
  22890. depth?: number;
  22891. faceUV?: Vector4[];
  22892. faceColors?: Color4[];
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. }): VertexData;
  22897. /**
  22898. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22900. * * segments sets the number of horizontal strips optional, default 32
  22901. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22902. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22903. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22904. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22905. * * 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
  22906. * * 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
  22907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22908. * * 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)
  22909. * * 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)
  22910. * @returns the VertexData of the ellipsoid
  22911. */
  22912. static CreateSphere(options: {
  22913. segments?: number;
  22914. diameter?: number;
  22915. diameterX?: number;
  22916. diameterY?: number;
  22917. diameterZ?: number;
  22918. arc?: number;
  22919. slice?: number;
  22920. sideOrientation?: number;
  22921. frontUVs?: Vector4;
  22922. backUVs?: Vector4;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData for a cylinder, cone or prism
  22926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22927. * * height sets the height (y direction) of the cylinder, optional, default 2
  22928. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22929. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22930. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22931. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22932. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22933. * * 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
  22934. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22935. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22936. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22937. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22939. * * 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)
  22940. * * 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)
  22941. * @returns the VertexData of the cylinder, cone or prism
  22942. */
  22943. static CreateCylinder(options: {
  22944. height?: number;
  22945. diameterTop?: number;
  22946. diameterBottom?: number;
  22947. diameter?: number;
  22948. tessellation?: number;
  22949. subdivisions?: number;
  22950. arc?: number;
  22951. faceColors?: Color4[];
  22952. faceUV?: Vector4[];
  22953. hasRings?: boolean;
  22954. enclose?: boolean;
  22955. sideOrientation?: number;
  22956. frontUVs?: Vector4;
  22957. backUVs?: Vector4;
  22958. }): VertexData;
  22959. /**
  22960. * Creates the VertexData for a torus
  22961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22962. * * diameter the diameter of the torus, optional default 1
  22963. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22964. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22966. * * 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)
  22967. * * 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)
  22968. * @returns the VertexData of the torus
  22969. */
  22970. static CreateTorus(options: {
  22971. diameter?: number;
  22972. thickness?: number;
  22973. tessellation?: number;
  22974. sideOrientation?: number;
  22975. frontUVs?: Vector4;
  22976. backUVs?: Vector4;
  22977. }): VertexData;
  22978. /**
  22979. * Creates the VertexData of the LineSystem
  22980. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22981. * - lines an array of lines, each line being an array of successive Vector3
  22982. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22983. * @returns the VertexData of the LineSystem
  22984. */
  22985. static CreateLineSystem(options: {
  22986. lines: Vector3[][];
  22987. colors?: Nullable<Color4[][]>;
  22988. }): VertexData;
  22989. /**
  22990. * Create the VertexData for a DashedLines
  22991. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22992. * - points an array successive Vector3
  22993. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22994. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22995. * - dashNb the intended total number of dashes, optional, default 200
  22996. * @returns the VertexData for the DashedLines
  22997. */
  22998. static CreateDashedLines(options: {
  22999. points: Vector3[];
  23000. dashSize?: number;
  23001. gapSize?: number;
  23002. dashNb?: number;
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData for a Ground
  23006. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23007. * - width the width (x direction) of the ground, optional, default 1
  23008. * - height the height (z direction) of the ground, optional, default 1
  23009. * - subdivisions the number of subdivisions per side, optional, default 1
  23010. * @returns the VertexData of the Ground
  23011. */
  23012. static CreateGround(options: {
  23013. width?: number;
  23014. height?: number;
  23015. subdivisions?: number;
  23016. subdivisionsX?: number;
  23017. subdivisionsY?: number;
  23018. }): VertexData;
  23019. /**
  23020. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23021. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23022. * * xmin the ground minimum X coordinate, optional, default -1
  23023. * * zmin the ground minimum Z coordinate, optional, default -1
  23024. * * xmax the ground maximum X coordinate, optional, default 1
  23025. * * zmax the ground maximum Z coordinate, optional, default 1
  23026. * * 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}
  23027. * * 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}
  23028. * @returns the VertexData of the TiledGround
  23029. */
  23030. static CreateTiledGround(options: {
  23031. xmin: number;
  23032. zmin: number;
  23033. xmax: number;
  23034. zmax: number;
  23035. subdivisions?: {
  23036. w: number;
  23037. h: number;
  23038. };
  23039. precision?: {
  23040. w: number;
  23041. h: number;
  23042. };
  23043. }): VertexData;
  23044. /**
  23045. * Creates the VertexData of the Ground designed from a heightmap
  23046. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23047. * * width the width (x direction) of the ground
  23048. * * height the height (z direction) of the ground
  23049. * * subdivisions the number of subdivisions per side
  23050. * * minHeight the minimum altitude on the ground, optional, default 0
  23051. * * maxHeight the maximum altitude on the ground, optional default 1
  23052. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23053. * * buffer the array holding the image color data
  23054. * * bufferWidth the width of image
  23055. * * bufferHeight the height of image
  23056. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23057. * @returns the VertexData of the Ground designed from a heightmap
  23058. */
  23059. static CreateGroundFromHeightMap(options: {
  23060. width: number;
  23061. height: number;
  23062. subdivisions: number;
  23063. minHeight: number;
  23064. maxHeight: number;
  23065. colorFilter: Color3;
  23066. buffer: Uint8Array;
  23067. bufferWidth: number;
  23068. bufferHeight: number;
  23069. alphaFilter: number;
  23070. }): VertexData;
  23071. /**
  23072. * Creates the VertexData for a Plane
  23073. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23074. * * size sets the width and height of the plane to the value of size, optional default 1
  23075. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23076. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23078. * * 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)
  23079. * * 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)
  23080. * @returns the VertexData of the box
  23081. */
  23082. static CreatePlane(options: {
  23083. size?: number;
  23084. width?: number;
  23085. height?: number;
  23086. sideOrientation?: number;
  23087. frontUVs?: Vector4;
  23088. backUVs?: Vector4;
  23089. }): VertexData;
  23090. /**
  23091. * Creates the VertexData of the Disc or regular Polygon
  23092. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23093. * * radius the radius of the disc, optional default 0.5
  23094. * * tessellation the number of polygon sides, optional, default 64
  23095. * * 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
  23096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23097. * * 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)
  23098. * * 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)
  23099. * @returns the VertexData of the box
  23100. */
  23101. static CreateDisc(options: {
  23102. radius?: number;
  23103. tessellation?: number;
  23104. arc?: number;
  23105. sideOrientation?: number;
  23106. frontUVs?: Vector4;
  23107. backUVs?: Vector4;
  23108. }): VertexData;
  23109. /**
  23110. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23111. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23112. * @param polygon a mesh built from polygonTriangulation.build()
  23113. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23114. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23115. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23116. * @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)
  23117. * @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)
  23118. * @returns the VertexData of the Polygon
  23119. */
  23120. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23121. /**
  23122. * Creates the VertexData of the IcoSphere
  23123. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23124. * * radius the radius of the IcoSphere, optional default 1
  23125. * * radiusX allows stretching in the x direction, optional, default radius
  23126. * * radiusY allows stretching in the y direction, optional, default radius
  23127. * * radiusZ allows stretching in the z direction, optional, default radius
  23128. * * flat when true creates a flat shaded mesh, optional, default true
  23129. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23130. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23131. * * 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)
  23132. * * 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)
  23133. * @returns the VertexData of the IcoSphere
  23134. */
  23135. static CreateIcoSphere(options: {
  23136. radius?: number;
  23137. radiusX?: number;
  23138. radiusY?: number;
  23139. radiusZ?: number;
  23140. flat?: boolean;
  23141. subdivisions?: number;
  23142. sideOrientation?: number;
  23143. frontUVs?: Vector4;
  23144. backUVs?: Vector4;
  23145. }): VertexData;
  23146. /**
  23147. * Creates the VertexData for a Polyhedron
  23148. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23149. * * type provided types are:
  23150. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23151. * * 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)
  23152. * * size the size of the IcoSphere, optional default 1
  23153. * * sizeX allows stretching in the x direction, optional, default size
  23154. * * sizeY allows stretching in the y direction, optional, default size
  23155. * * sizeZ allows stretching in the z direction, optional, default size
  23156. * * 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
  23157. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23158. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23159. * * flat when true creates a flat shaded mesh, optional, default true
  23160. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23162. * * 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)
  23163. * * 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)
  23164. * @returns the VertexData of the Polyhedron
  23165. */
  23166. static CreatePolyhedron(options: {
  23167. type?: number;
  23168. size?: number;
  23169. sizeX?: number;
  23170. sizeY?: number;
  23171. sizeZ?: number;
  23172. custom?: any;
  23173. faceUV?: Vector4[];
  23174. faceColors?: Color4[];
  23175. flat?: boolean;
  23176. sideOrientation?: number;
  23177. frontUVs?: Vector4;
  23178. backUVs?: Vector4;
  23179. }): VertexData;
  23180. /**
  23181. * Creates the VertexData for a TorusKnot
  23182. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23183. * * radius the radius of the torus knot, optional, default 2
  23184. * * tube the thickness of the tube, optional, default 0.5
  23185. * * radialSegments the number of sides on each tube segments, optional, default 32
  23186. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23187. * * p the number of windings around the z axis, optional, default 2
  23188. * * q the number of windings around the x axis, optional, default 3
  23189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23190. * * 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)
  23191. * * 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)
  23192. * @returns the VertexData of the Torus Knot
  23193. */
  23194. static CreateTorusKnot(options: {
  23195. radius?: number;
  23196. tube?: number;
  23197. radialSegments?: number;
  23198. tubularSegments?: number;
  23199. p?: number;
  23200. q?: number;
  23201. sideOrientation?: number;
  23202. frontUVs?: Vector4;
  23203. backUVs?: Vector4;
  23204. }): VertexData;
  23205. /**
  23206. * Compute normals for given positions and indices
  23207. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23208. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23209. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23210. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23211. * * facetNormals : optional array of facet normals (vector3)
  23212. * * facetPositions : optional array of facet positions (vector3)
  23213. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23214. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23215. * * bInfo : optional bounding info, required for facetPartitioning computation
  23216. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23217. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23218. * * useRightHandedSystem: optional boolean to for right handed system computation
  23219. * * depthSort : optional boolean to enable the facet depth sort computation
  23220. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23221. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23222. */
  23223. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23224. facetNormals?: any;
  23225. facetPositions?: any;
  23226. facetPartitioning?: any;
  23227. ratio?: number;
  23228. bInfo?: any;
  23229. bbSize?: Vector3;
  23230. subDiv?: any;
  23231. useRightHandedSystem?: boolean;
  23232. depthSort?: boolean;
  23233. distanceTo?: Vector3;
  23234. depthSortedFacets?: any;
  23235. }): void;
  23236. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23237. /**
  23238. * Applies VertexData created from the imported parameters to the geometry
  23239. * @param parsedVertexData the parsed data from an imported file
  23240. * @param geometry the geometry to apply the VertexData to
  23241. */
  23242. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23243. }
  23244. }
  23245. declare module BABYLON {
  23246. /**
  23247. * Class containing static functions to help procedurally build meshes
  23248. */
  23249. export class DiscBuilder {
  23250. /**
  23251. * Creates a plane polygonal mesh. By default, this is a disc
  23252. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23253. * * 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
  23254. * * 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
  23255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23256. * * 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
  23257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23258. * @param name defines the name of the mesh
  23259. * @param options defines the options used to create the mesh
  23260. * @param scene defines the hosting scene
  23261. * @returns the plane polygonal mesh
  23262. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23263. */
  23264. static CreateDisc(name: string, options: {
  23265. radius?: number;
  23266. tessellation?: number;
  23267. arc?: number;
  23268. updatable?: boolean;
  23269. sideOrientation?: number;
  23270. frontUVs?: Vector4;
  23271. backUVs?: Vector4;
  23272. }, scene?: Nullable<Scene>): Mesh;
  23273. }
  23274. }
  23275. declare module BABYLON {
  23276. /**
  23277. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23278. *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.
  23279. * The SPS is also a particle system. It provides some methods to manage the particles.
  23280. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23281. *
  23282. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23283. */
  23284. export class SolidParticleSystem implements IDisposable {
  23285. /**
  23286. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23287. * Example : var p = SPS.particles[i];
  23288. */
  23289. particles: SolidParticle[];
  23290. /**
  23291. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23292. */
  23293. nbParticles: number;
  23294. /**
  23295. * If the particles must ever face the camera (default false). Useful for planar particles.
  23296. */
  23297. billboard: boolean;
  23298. /**
  23299. * Recompute normals when adding a shape
  23300. */
  23301. recomputeNormals: boolean;
  23302. /**
  23303. * This a counter ofr your own usage. It's not set by any SPS functions.
  23304. */
  23305. counter: number;
  23306. /**
  23307. * The SPS name. This name is also given to the underlying mesh.
  23308. */
  23309. name: string;
  23310. /**
  23311. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23312. */
  23313. mesh: Mesh;
  23314. /**
  23315. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23316. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23317. */
  23318. vars: any;
  23319. /**
  23320. * This array is populated when the SPS is set as 'pickable'.
  23321. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23322. * Each element of this array is an object `{idx: int, faceId: int}`.
  23323. * `idx` is the picked particle index in the `SPS.particles` array
  23324. * `faceId` is the picked face index counted within this particle.
  23325. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23326. */
  23327. pickedParticles: {
  23328. idx: number;
  23329. faceId: number;
  23330. }[];
  23331. /**
  23332. * This array is populated when `enableDepthSort` is set to true.
  23333. * Each element of this array is an instance of the class DepthSortedParticle.
  23334. */
  23335. depthSortedParticles: DepthSortedParticle[];
  23336. /**
  23337. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23338. * @hidden
  23339. */ bSphereOnly: boolean;
  23340. /**
  23341. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23342. * @hidden
  23343. */ bSphereRadiusFactor: number;
  23344. private _scene;
  23345. private _positions;
  23346. private _indices;
  23347. private _normals;
  23348. private _colors;
  23349. private _uvs;
  23350. private _indices32;
  23351. private _positions32;
  23352. private _normals32;
  23353. private _fixedNormal32;
  23354. private _colors32;
  23355. private _uvs32;
  23356. private _index;
  23357. private _updatable;
  23358. private _pickable;
  23359. private _isVisibilityBoxLocked;
  23360. private _alwaysVisible;
  23361. private _depthSort;
  23362. private _shapeCounter;
  23363. private _copy;
  23364. private _color;
  23365. private _computeParticleColor;
  23366. private _computeParticleTexture;
  23367. private _computeParticleRotation;
  23368. private _computeParticleVertex;
  23369. private _computeBoundingBox;
  23370. private _depthSortParticles;
  23371. private _camera;
  23372. private _mustUnrotateFixedNormals;
  23373. private _particlesIntersect;
  23374. private _needs32Bits;
  23375. /**
  23376. * Creates a SPS (Solid Particle System) object.
  23377. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23378. * @param scene (Scene) is the scene in which the SPS is added.
  23379. * @param options defines the options of the sps e.g.
  23380. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23381. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23382. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23383. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23384. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23385. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23386. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23387. */
  23388. constructor(name: string, scene: Scene, options?: {
  23389. updatable?: boolean;
  23390. isPickable?: boolean;
  23391. enableDepthSort?: boolean;
  23392. particleIntersection?: boolean;
  23393. boundingSphereOnly?: boolean;
  23394. bSphereRadiusFactor?: number;
  23395. });
  23396. /**
  23397. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23398. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23399. * @returns the created mesh
  23400. */
  23401. buildMesh(): Mesh;
  23402. /**
  23403. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23404. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23405. * Thus the particles generated from `digest()` have their property `position` set yet.
  23406. * @param mesh ( Mesh ) is the mesh to be digested
  23407. * @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
  23408. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23409. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23410. * @returns the current SPS
  23411. */
  23412. digest(mesh: Mesh, options?: {
  23413. facetNb?: number;
  23414. number?: number;
  23415. delta?: number;
  23416. }): SolidParticleSystem;
  23417. private _unrotateFixedNormals;
  23418. private _resetCopy;
  23419. private _meshBuilder;
  23420. private _posToShape;
  23421. private _uvsToShapeUV;
  23422. private _addParticle;
  23423. /**
  23424. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23425. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23426. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23427. * @param nb (positive integer) the number of particles to be created from this model
  23428. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23429. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23430. * @returns the number of shapes in the system
  23431. */
  23432. addShape(mesh: Mesh, nb: number, options?: {
  23433. positionFunction?: any;
  23434. vertexFunction?: any;
  23435. }): number;
  23436. private _rebuildParticle;
  23437. /**
  23438. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23439. * @returns the SPS.
  23440. */
  23441. rebuildMesh(): SolidParticleSystem;
  23442. /**
  23443. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23444. * This method calls `updateParticle()` for each particle of the SPS.
  23445. * For an animated SPS, it is usually called within the render loop.
  23446. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23447. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23448. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23449. * @returns the SPS.
  23450. */
  23451. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23452. /**
  23453. * Disposes the SPS.
  23454. */
  23455. dispose(): void;
  23456. /**
  23457. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23458. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23459. * @returns the SPS.
  23460. */
  23461. refreshVisibleSize(): SolidParticleSystem;
  23462. /**
  23463. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23464. * @param size the size (float) of the visibility box
  23465. * note : this doesn't lock the SPS mesh bounding box.
  23466. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23467. */
  23468. setVisibilityBox(size: number): void;
  23469. /**
  23470. * Gets whether the SPS as always visible or not
  23471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23472. */
  23473. /**
  23474. * Sets the SPS as always visible or not
  23475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23476. */
  23477. isAlwaysVisible: boolean;
  23478. /**
  23479. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. /**
  23483. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23484. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23485. */
  23486. isVisibilityBoxLocked: boolean;
  23487. /**
  23488. * Tells to `setParticles()` to compute the particle rotations or not.
  23489. * Default value : true. The SPS is faster when it's set to false.
  23490. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23491. */
  23492. /**
  23493. * Gets if `setParticles()` computes the particle rotations or not.
  23494. * Default value : true. The SPS is faster when it's set to false.
  23495. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23496. */
  23497. computeParticleRotation: boolean;
  23498. /**
  23499. * Tells to `setParticles()` to compute the particle colors or not.
  23500. * Default value : true. The SPS is faster when it's set to false.
  23501. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23502. */
  23503. /**
  23504. * Gets if `setParticles()` computes the particle colors or not.
  23505. * Default value : true. The SPS is faster when it's set to false.
  23506. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23507. */
  23508. computeParticleColor: boolean;
  23509. /**
  23510. * Gets if `setParticles()` computes the particle textures or not.
  23511. * Default value : true. The SPS is faster when it's set to false.
  23512. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23513. */
  23514. computeParticleTexture: boolean;
  23515. /**
  23516. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23517. * Default value : false. The SPS is faster when it's set to false.
  23518. * Note : the particle custom vertex positions aren't stored values.
  23519. */
  23520. /**
  23521. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23522. * Default value : false. The SPS is faster when it's set to false.
  23523. * Note : the particle custom vertex positions aren't stored values.
  23524. */
  23525. computeParticleVertex: boolean;
  23526. /**
  23527. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23528. */
  23529. /**
  23530. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23531. */
  23532. computeBoundingBox: boolean;
  23533. /**
  23534. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23535. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23536. * Default : `true`
  23537. */
  23538. /**
  23539. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23540. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23541. * Default : `true`
  23542. */
  23543. depthSortParticles: boolean;
  23544. /**
  23545. * This function does nothing. It may be overwritten to set all the particle first values.
  23546. * The SPS doesn't call this function, you may have to call it by your own.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23548. */
  23549. initParticles(): void;
  23550. /**
  23551. * This function does nothing. It may be overwritten to recycle a particle.
  23552. * The SPS doesn't call this function, you may have to call it by your own.
  23553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23554. * @param particle The particle to recycle
  23555. * @returns the recycled particle
  23556. */
  23557. recycleParticle(particle: SolidParticle): SolidParticle;
  23558. /**
  23559. * Updates a particle : this function should be overwritten by the user.
  23560. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23562. * @example : just set a particle position or velocity and recycle conditions
  23563. * @param particle The particle to update
  23564. * @returns the updated particle
  23565. */
  23566. updateParticle(particle: SolidParticle): SolidParticle;
  23567. /**
  23568. * Updates a vertex of a particle : it can be overwritten by the user.
  23569. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23570. * @param particle the current particle
  23571. * @param vertex the current index of the current particle
  23572. * @param pt the index of the current vertex in the particle shape
  23573. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23574. * @example : just set a vertex particle position
  23575. * @returns the updated vertex
  23576. */
  23577. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23578. /**
  23579. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23580. * This does nothing and may be overwritten by the user.
  23581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23583. * @param update the boolean update value actually passed to setParticles()
  23584. */
  23585. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23586. /**
  23587. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23588. * This will be passed three parameters.
  23589. * This does nothing and may be overwritten by the user.
  23590. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23592. * @param update the boolean update value actually passed to setParticles()
  23593. */
  23594. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23595. }
  23596. }
  23597. declare module BABYLON {
  23598. /**
  23599. * Represents one particle of a solid particle system.
  23600. */
  23601. export class SolidParticle {
  23602. /**
  23603. * particle global index
  23604. */
  23605. idx: number;
  23606. /**
  23607. * The color of the particle
  23608. */
  23609. color: Nullable<Color4>;
  23610. /**
  23611. * The world space position of the particle.
  23612. */
  23613. position: Vector3;
  23614. /**
  23615. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23616. */
  23617. rotation: Vector3;
  23618. /**
  23619. * The world space rotation quaternion of the particle.
  23620. */
  23621. rotationQuaternion: Nullable<Quaternion>;
  23622. /**
  23623. * The scaling of the particle.
  23624. */
  23625. scaling: Vector3;
  23626. /**
  23627. * The uvs of the particle.
  23628. */
  23629. uvs: Vector4;
  23630. /**
  23631. * The current speed of the particle.
  23632. */
  23633. velocity: Vector3;
  23634. /**
  23635. * The pivot point in the particle local space.
  23636. */
  23637. pivot: Vector3;
  23638. /**
  23639. * Must the particle be translated from its pivot point in its local space ?
  23640. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23641. * Default : false
  23642. */
  23643. translateFromPivot: boolean;
  23644. /**
  23645. * Is the particle active or not ?
  23646. */
  23647. alive: boolean;
  23648. /**
  23649. * Is the particle visible or not ?
  23650. */
  23651. isVisible: boolean;
  23652. /**
  23653. * Index of this particle in the global "positions" array (Internal use)
  23654. * @hidden
  23655. */ pos: number;
  23656. /**
  23657. * @hidden Index of this particle in the global "indices" array (Internal use)
  23658. */ ind: number;
  23659. /**
  23660. * @hidden ModelShape of this particle (Internal use)
  23661. */ model: ModelShape;
  23662. /**
  23663. * ModelShape id of this particle
  23664. */
  23665. shapeId: number;
  23666. /**
  23667. * Index of the particle in its shape id (Internal use)
  23668. */
  23669. idxInShape: number;
  23670. /**
  23671. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23672. */ modelBoundingInfo: BoundingInfo;
  23673. /**
  23674. * @hidden Particle BoundingInfo object (Internal use)
  23675. */ boundingInfo: BoundingInfo;
  23676. /**
  23677. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23678. */ sps: SolidParticleSystem;
  23679. /**
  23680. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23681. */ stillInvisible: boolean;
  23682. /**
  23683. * @hidden Last computed particle rotation matrix
  23684. */ rotationMatrix: number[];
  23685. /**
  23686. * Parent particle Id, if any.
  23687. * Default null.
  23688. */
  23689. parentId: Nullable<number>;
  23690. /**
  23691. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23692. * The possible values are :
  23693. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23694. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23697. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23698. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23699. * */
  23700. cullingStrategy: number;
  23701. /**
  23702. * @hidden Internal global position in the SPS.
  23703. */ globalPosition: Vector3;
  23704. /**
  23705. * Creates a Solid Particle object.
  23706. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23707. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23708. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23709. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23710. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23711. * @param shapeId (integer) is the model shape identifier in the SPS.
  23712. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23713. * @param sps defines the sps it is associated to
  23714. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23715. */
  23716. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23717. /**
  23718. * Legacy support, changed scale to scaling
  23719. */
  23720. /**
  23721. * Legacy support, changed scale to scaling
  23722. */
  23723. scale: Vector3;
  23724. /**
  23725. * Legacy support, changed quaternion to rotationQuaternion
  23726. */
  23727. /**
  23728. * Legacy support, changed quaternion to rotationQuaternion
  23729. */
  23730. quaternion: Nullable<Quaternion>;
  23731. /**
  23732. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23733. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23734. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23735. * @returns true if it intersects
  23736. */
  23737. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23738. /**
  23739. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23740. * A particle is in the frustum if its bounding box intersects the frustum
  23741. * @param frustumPlanes defines the frustum to test
  23742. * @returns true if the particle is in the frustum planes
  23743. */
  23744. isInFrustum(frustumPlanes: Plane[]): boolean;
  23745. /**
  23746. * get the rotation matrix of the particle
  23747. * @hidden
  23748. */
  23749. getRotationMatrix(m: Matrix): void;
  23750. }
  23751. /**
  23752. * Represents the shape of the model used by one particle of a solid particle system.
  23753. * SPS internal tool, don't use it manually.
  23754. */
  23755. export class ModelShape {
  23756. /**
  23757. * The shape id
  23758. * @hidden
  23759. */
  23760. shapeID: number;
  23761. /**
  23762. * flat array of model positions (internal use)
  23763. * @hidden
  23764. */ shape: Vector3[];
  23765. /**
  23766. * flat array of model UVs (internal use)
  23767. * @hidden
  23768. */ shapeUV: number[];
  23769. /**
  23770. * length of the shape in the model indices array (internal use)
  23771. * @hidden
  23772. */ indicesLength: number;
  23773. /**
  23774. * Custom position function (internal use)
  23775. * @hidden
  23776. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23777. /**
  23778. * Custom vertex function (internal use)
  23779. * @hidden
  23780. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23781. /**
  23782. * 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.
  23783. * SPS internal tool, don't use it manually.
  23784. * @hidden
  23785. */
  23786. 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>);
  23787. }
  23788. /**
  23789. * Represents a Depth Sorted Particle in the solid particle system.
  23790. */
  23791. export class DepthSortedParticle {
  23792. /**
  23793. * Index of the particle in the "indices" array
  23794. */
  23795. ind: number;
  23796. /**
  23797. * Length of the particle shape in the "indices" array
  23798. */
  23799. indicesLength: number;
  23800. /**
  23801. * Squared distance from the particle to the camera
  23802. */
  23803. sqDistance: number;
  23804. }
  23805. }
  23806. declare module BABYLON {
  23807. /**
  23808. * Class used to store all common mesh properties
  23809. */
  23810. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23811. /** No occlusion */
  23812. static OCCLUSION_TYPE_NONE: number;
  23813. /** Occlusion set to optimisitic */
  23814. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23815. /** Occlusion set to strict */
  23816. static OCCLUSION_TYPE_STRICT: number;
  23817. /** Use an accurante occlusion algorithm */
  23818. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23819. /** Use a conservative occlusion algorithm */
  23820. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23821. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23822. * Test order :
  23823. * Is the bounding sphere outside the frustum ?
  23824. * If not, are the bounding box vertices outside the frustum ?
  23825. * It not, then the cullable object is in the frustum.
  23826. */
  23827. static readonly CULLINGSTRATEGY_STANDARD: number;
  23828. /** Culling strategy : Bounding Sphere Only.
  23829. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23830. * It's also less accurate than the standard because some not visible objects can still be selected.
  23831. * Test : is the bounding sphere outside the frustum ?
  23832. * If not, then the cullable object is in the frustum.
  23833. */
  23834. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23835. /** Culling strategy : Optimistic Inclusion.
  23836. * This in an inclusion test first, then the standard exclusion test.
  23837. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23838. * 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.
  23839. * Anyway, it's as accurate as the standard strategy.
  23840. * Test :
  23841. * Is the cullable object bounding sphere center in the frustum ?
  23842. * If not, apply the default culling strategy.
  23843. */
  23844. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23845. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23846. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23847. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23848. * 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.
  23849. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23850. * Test :
  23851. * Is the cullable object bounding sphere center in the frustum ?
  23852. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23853. */
  23854. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23855. /**
  23856. * No billboard
  23857. */
  23858. static readonly BILLBOARDMODE_NONE: number;
  23859. /** Billboard on X axis */
  23860. static readonly BILLBOARDMODE_X: number;
  23861. /** Billboard on Y axis */
  23862. static readonly BILLBOARDMODE_Y: number;
  23863. /** Billboard on Z axis */
  23864. static readonly BILLBOARDMODE_Z: number;
  23865. /** Billboard on all axes */
  23866. static readonly BILLBOARDMODE_ALL: number;
  23867. private _facetData;
  23868. /**
  23869. * The culling strategy to use to check whether the mesh must be rendered or not.
  23870. * This value can be changed at any time and will be used on the next render mesh selection.
  23871. * The possible values are :
  23872. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23873. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23874. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23875. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23876. * Please read each static variable documentation to get details about the culling process.
  23877. * */
  23878. cullingStrategy: number;
  23879. /**
  23880. * Gets the number of facets in the mesh
  23881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23882. */
  23883. readonly facetNb: number;
  23884. /**
  23885. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23887. */
  23888. partitioningSubdivisions: number;
  23889. /**
  23890. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23891. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23893. */
  23894. partitioningBBoxRatio: number;
  23895. /**
  23896. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23897. * Works only for updatable meshes.
  23898. * Doesn't work with multi-materials
  23899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23900. */
  23901. mustDepthSortFacets: boolean;
  23902. /**
  23903. * The location (Vector3) where the facet depth sort must be computed from.
  23904. * By default, the active camera position.
  23905. * Used only when facet depth sort is enabled
  23906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23907. */
  23908. facetDepthSortFrom: Vector3;
  23909. /**
  23910. * gets a boolean indicating if facetData is enabled
  23911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23912. */
  23913. readonly isFacetDataEnabled: boolean;
  23914. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23915. /**
  23916. * An event triggered when this mesh collides with another one
  23917. */
  23918. onCollideObservable: Observable<AbstractMesh>;
  23919. private _onCollideObserver;
  23920. /** Set a function to call when this mesh collides with another one */
  23921. onCollide: () => void;
  23922. /**
  23923. * An event triggered when the collision's position changes
  23924. */
  23925. onCollisionPositionChangeObservable: Observable<Vector3>;
  23926. private _onCollisionPositionChangeObserver;
  23927. /** Set a function to call when the collision's position changes */
  23928. onCollisionPositionChange: () => void;
  23929. /**
  23930. * An event triggered when material is changed
  23931. */
  23932. onMaterialChangedObservable: Observable<AbstractMesh>;
  23933. /**
  23934. * Gets or sets the orientation for POV movement & rotation
  23935. */
  23936. definedFacingForward: boolean;
  23937. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23938. private _visibility;
  23939. /** @hidden */ isActive: boolean;
  23940. /** @hidden */ onlyForInstances: boolean;
  23941. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23942. /**
  23943. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23944. */
  23945. /**
  23946. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23947. */
  23948. visibility: number;
  23949. /** Gets or sets the alpha index used to sort transparent meshes
  23950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23951. */
  23952. alphaIndex: number;
  23953. /**
  23954. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23955. */
  23956. isVisible: boolean;
  23957. /**
  23958. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23959. */
  23960. isPickable: boolean;
  23961. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23962. showSubMeshesBoundingBox: boolean;
  23963. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23965. */
  23966. isBlocker: boolean;
  23967. /**
  23968. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23969. */
  23970. enablePointerMoveEvents: boolean;
  23971. /**
  23972. * Specifies the rendering group id for this mesh (0 by default)
  23973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23974. */
  23975. renderingGroupId: number;
  23976. private _material;
  23977. /** Gets or sets current material */
  23978. material: Nullable<Material>;
  23979. private _receiveShadows;
  23980. /**
  23981. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23982. * @see http://doc.babylonjs.com/babylon101/shadows
  23983. */
  23984. receiveShadows: boolean;
  23985. /** Defines color to use when rendering outline */
  23986. outlineColor: Color3;
  23987. /** Define width to use when rendering outline */
  23988. outlineWidth: number;
  23989. /** Defines color to use when rendering overlay */
  23990. overlayColor: Color3;
  23991. /** Defines alpha to use when rendering overlay */
  23992. overlayAlpha: number;
  23993. private _hasVertexAlpha;
  23994. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23995. hasVertexAlpha: boolean;
  23996. private _useVertexColors;
  23997. /** 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) */
  23998. useVertexColors: boolean;
  23999. private _computeBonesUsingShaders;
  24000. /**
  24001. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24002. */
  24003. computeBonesUsingShaders: boolean;
  24004. private _numBoneInfluencers;
  24005. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24006. numBoneInfluencers: number;
  24007. private _applyFog;
  24008. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24009. applyFog: boolean;
  24010. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24011. useOctreeForRenderingSelection: boolean;
  24012. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24013. useOctreeForPicking: boolean;
  24014. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24015. useOctreeForCollisions: boolean;
  24016. private _layerMask;
  24017. /**
  24018. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24019. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24020. */
  24021. layerMask: number;
  24022. /**
  24023. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24024. */
  24025. alwaysSelectAsActiveMesh: boolean;
  24026. /**
  24027. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24028. */
  24029. doNotSyncBoundingInfo: boolean;
  24030. /**
  24031. * Gets or sets the current action manager
  24032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24033. */
  24034. actionManager: Nullable<AbstractActionManager>;
  24035. private _checkCollisions;
  24036. private _collisionMask;
  24037. private _collisionGroup;
  24038. /**
  24039. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24041. */
  24042. ellipsoid: Vector3;
  24043. /**
  24044. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24046. */
  24047. ellipsoidOffset: Vector3;
  24048. private _collider;
  24049. private _oldPositionForCollisions;
  24050. private _diffPositionForCollisions;
  24051. /**
  24052. * Gets or sets a collision mask used to mask collisions (default is -1).
  24053. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24054. */
  24055. collisionMask: number;
  24056. /**
  24057. * Gets or sets the current collision group mask (-1 by default).
  24058. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24059. */
  24060. collisionGroup: number;
  24061. /**
  24062. * Defines edge width used when edgesRenderer is enabled
  24063. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24064. */
  24065. edgesWidth: number;
  24066. /**
  24067. * Defines edge color used when edgesRenderer is enabled
  24068. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24069. */
  24070. edgesColor: Color4;
  24071. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24072. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24073. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24074. /** @hidden */ renderId: number;
  24075. /**
  24076. * Gets or sets the list of subMeshes
  24077. * @see http://doc.babylonjs.com/how_to/multi_materials
  24078. */
  24079. subMeshes: SubMesh[];
  24080. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24081. /** @hidden */ unIndexed: boolean;
  24082. /** @hidden */ lightSources: Light[];
  24083. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24084. /** @hidden */ waitingActions: Nullable<any>;
  24085. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  24086. private _skeleton;
  24087. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24088. /**
  24089. * Gets or sets a skeleton to apply skining transformations
  24090. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24091. */
  24092. skeleton: Nullable<Skeleton>;
  24093. /**
  24094. * An event triggered when the mesh is rebuilt.
  24095. */
  24096. onRebuildObservable: Observable<AbstractMesh>;
  24097. /**
  24098. * Creates a new AbstractMesh
  24099. * @param name defines the name of the mesh
  24100. * @param scene defines the hosting scene
  24101. */
  24102. constructor(name: string, scene?: Nullable<Scene>);
  24103. /**
  24104. * Returns the string "AbstractMesh"
  24105. * @returns "AbstractMesh"
  24106. */
  24107. getClassName(): string;
  24108. /**
  24109. * Gets a string representation of the current mesh
  24110. * @param fullDetails defines a boolean indicating if full details must be included
  24111. * @returns a string representation of the current mesh
  24112. */
  24113. toString(fullDetails?: boolean): string;
  24114. /**
  24115. * @hidden
  24116. */
  24117. protected _getEffectiveParent(): Nullable<Node>;
  24118. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24119. /** @hidden */ rebuild(): void;
  24120. /** @hidden */ resyncLightSources(): void;
  24121. /** @hidden */ resyncLighSource(light: Light): void;
  24122. /** @hidden */ unBindEffect(): void;
  24123. /** @hidden */ removeLightSource(light: Light): void;
  24124. private _markSubMeshesAsDirty;
  24125. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24126. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24127. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24128. /**
  24129. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24130. */
  24131. scaling: Vector3;
  24132. /**
  24133. * Returns true if the mesh is blocked. Implemented by child classes
  24134. */
  24135. readonly isBlocked: boolean;
  24136. /**
  24137. * Returns the mesh itself by default. Implemented by child classes
  24138. * @param camera defines the camera to use to pick the right LOD level
  24139. * @returns the currentAbstractMesh
  24140. */
  24141. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24142. /**
  24143. * Returns 0 by default. Implemented by child classes
  24144. * @returns an integer
  24145. */
  24146. getTotalVertices(): number;
  24147. /**
  24148. * Returns a positive integer : the total number of indices in this mesh geometry.
  24149. * @returns the numner of indices or zero if the mesh has no geometry.
  24150. */
  24151. getTotalIndices(): number;
  24152. /**
  24153. * Returns null by default. Implemented by child classes
  24154. * @returns null
  24155. */
  24156. getIndices(): Nullable<IndicesArray>;
  24157. /**
  24158. * Returns the array of the requested vertex data kind. Implemented by child classes
  24159. * @param kind defines the vertex data kind to use
  24160. * @returns null
  24161. */
  24162. getVerticesData(kind: string): Nullable<FloatArray>;
  24163. /**
  24164. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24165. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24166. * Note that a new underlying VertexBuffer object is created each call.
  24167. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24168. * @param kind defines vertex data kind:
  24169. * * VertexBuffer.PositionKind
  24170. * * VertexBuffer.UVKind
  24171. * * VertexBuffer.UV2Kind
  24172. * * VertexBuffer.UV3Kind
  24173. * * VertexBuffer.UV4Kind
  24174. * * VertexBuffer.UV5Kind
  24175. * * VertexBuffer.UV6Kind
  24176. * * VertexBuffer.ColorKind
  24177. * * VertexBuffer.MatricesIndicesKind
  24178. * * VertexBuffer.MatricesIndicesExtraKind
  24179. * * VertexBuffer.MatricesWeightsKind
  24180. * * VertexBuffer.MatricesWeightsExtraKind
  24181. * @param data defines the data source
  24182. * @param updatable defines if the data must be flagged as updatable (or static)
  24183. * @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
  24184. * @returns the current mesh
  24185. */
  24186. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24187. /**
  24188. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24189. * If the mesh has no geometry, it is simply returned as it is.
  24190. * @param kind defines vertex data kind:
  24191. * * VertexBuffer.PositionKind
  24192. * * VertexBuffer.UVKind
  24193. * * VertexBuffer.UV2Kind
  24194. * * VertexBuffer.UV3Kind
  24195. * * VertexBuffer.UV4Kind
  24196. * * VertexBuffer.UV5Kind
  24197. * * VertexBuffer.UV6Kind
  24198. * * VertexBuffer.ColorKind
  24199. * * VertexBuffer.MatricesIndicesKind
  24200. * * VertexBuffer.MatricesIndicesExtraKind
  24201. * * VertexBuffer.MatricesWeightsKind
  24202. * * VertexBuffer.MatricesWeightsExtraKind
  24203. * @param data defines the data source
  24204. * @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
  24205. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24206. * @returns the current mesh
  24207. */
  24208. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24209. /**
  24210. * Sets the mesh indices,
  24211. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24212. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24213. * @param totalVertices Defines the total number of vertices
  24214. * @returns the current mesh
  24215. */
  24216. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24217. /**
  24218. * Gets a boolean indicating if specific vertex data is present
  24219. * @param kind defines the vertex data kind to use
  24220. * @returns true is data kind is present
  24221. */
  24222. isVerticesDataPresent(kind: string): boolean;
  24223. /**
  24224. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24225. * @returns a BoundingInfo
  24226. */
  24227. getBoundingInfo(): BoundingInfo;
  24228. /**
  24229. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24230. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24231. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24232. * @returns the current mesh
  24233. */
  24234. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24235. /**
  24236. * Overwrite the current bounding info
  24237. * @param boundingInfo defines the new bounding info
  24238. * @returns the current mesh
  24239. */
  24240. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24241. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24242. readonly useBones: boolean;
  24243. /** @hidden */ preActivate(): void;
  24244. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24245. /** @hidden */ activate(renderId: number): boolean;
  24246. /** @hidden */ freeze(): void;
  24247. /** @hidden */ unFreeze(): void;
  24248. /**
  24249. * Gets the current world matrix
  24250. * @returns a Matrix
  24251. */
  24252. getWorldMatrix(): Matrix;
  24253. /** @hidden */ getWorldMatrixDeterminant(): number;
  24254. /**
  24255. * Perform relative position change from the point of view of behind the front of the mesh.
  24256. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24257. * Supports definition of mesh facing forward or backward
  24258. * @param amountRight defines the distance on the right axis
  24259. * @param amountUp defines the distance on the up axis
  24260. * @param amountForward defines the distance on the forward axis
  24261. * @returns the current mesh
  24262. */
  24263. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24264. /**
  24265. * Calculate relative position change from the point of view of behind the front of the mesh.
  24266. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24267. * Supports definition of mesh facing forward or backward
  24268. * @param amountRight defines the distance on the right axis
  24269. * @param amountUp defines the distance on the up axis
  24270. * @param amountForward defines the distance on the forward axis
  24271. * @returns the new displacement vector
  24272. */
  24273. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24274. /**
  24275. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24276. * Supports definition of mesh facing forward or backward
  24277. * @param flipBack defines the flip
  24278. * @param twirlClockwise defines the twirl
  24279. * @param tiltRight defines the tilt
  24280. * @returns the current mesh
  24281. */
  24282. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24283. /**
  24284. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24285. * Supports definition of mesh facing forward or backward.
  24286. * @param flipBack defines the flip
  24287. * @param twirlClockwise defines the twirl
  24288. * @param tiltRight defines the tilt
  24289. * @returns the new rotation vector
  24290. */
  24291. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24292. /**
  24293. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24294. * This means the mesh underlying bounding box and sphere are recomputed.
  24295. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24296. * @returns the current mesh
  24297. */
  24298. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24299. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24300. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24301. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24302. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24303. /** @hidden */
  24304. protected _afterComputeWorldMatrix(): void;
  24305. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24306. /**
  24307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24308. * A mesh is in the frustum if its bounding box intersects the frustum
  24309. * @param frustumPlanes defines the frustum to test
  24310. * @returns true if the mesh is in the frustum planes
  24311. */
  24312. isInFrustum(frustumPlanes: Plane[]): boolean;
  24313. /**
  24314. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24315. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24316. * @param frustumPlanes defines the frustum to test
  24317. * @returns true if the mesh is completely in the frustum planes
  24318. */
  24319. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24320. /**
  24321. * True if the mesh intersects another mesh or a SolidParticle object
  24322. * @param mesh defines a target mesh or SolidParticle to test
  24323. * @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)
  24324. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24325. * @returns true if there is an intersection
  24326. */
  24327. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24328. /**
  24329. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24330. * @param point defines the point to test
  24331. * @returns true if there is an intersection
  24332. */
  24333. intersectsPoint(point: Vector3): boolean;
  24334. /**
  24335. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24337. */
  24338. checkCollisions: boolean;
  24339. /**
  24340. * Gets Collider object used to compute collisions (not physics)
  24341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24342. */
  24343. readonly collider: Nullable<Collider>;
  24344. /**
  24345. * Move the mesh using collision engine
  24346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24347. * @param displacement defines the requested displacement vector
  24348. * @returns the current mesh
  24349. */
  24350. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24351. private _onCollisionPositionChange;
  24352. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24353. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24354. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24355. /** @hidden */ generatePointsArray(): boolean;
  24356. /**
  24357. * Checks if the passed Ray intersects with the mesh
  24358. * @param ray defines the ray to use
  24359. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24361. * @returns the picking info
  24362. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24363. */
  24364. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24365. /**
  24366. * Clones the current mesh
  24367. * @param name defines the mesh name
  24368. * @param newParent defines the new mesh parent
  24369. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24370. * @returns the new mesh
  24371. */
  24372. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24373. /**
  24374. * Disposes all the submeshes of the current meshnp
  24375. * @returns the current mesh
  24376. */
  24377. releaseSubMeshes(): AbstractMesh;
  24378. /**
  24379. * Releases resources associated with this abstract mesh.
  24380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24382. */
  24383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24384. /**
  24385. * Adds the passed mesh as a child to the current mesh
  24386. * @param mesh defines the child mesh
  24387. * @returns the current mesh
  24388. */
  24389. addChild(mesh: AbstractMesh): AbstractMesh;
  24390. /**
  24391. * Removes the passed mesh from the current mesh children list
  24392. * @param mesh defines the child mesh
  24393. * @returns the current mesh
  24394. */
  24395. removeChild(mesh: AbstractMesh): AbstractMesh;
  24396. /** @hidden */
  24397. private _initFacetData;
  24398. /**
  24399. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24400. * This method can be called within the render loop.
  24401. * 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
  24402. * @returns the current mesh
  24403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24404. */
  24405. updateFacetData(): AbstractMesh;
  24406. /**
  24407. * Returns the facetLocalNormals array.
  24408. * The normals are expressed in the mesh local spac
  24409. * @returns an array of Vector3
  24410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24411. */
  24412. getFacetLocalNormals(): Vector3[];
  24413. /**
  24414. * Returns the facetLocalPositions array.
  24415. * The facet positions are expressed in the mesh local space
  24416. * @returns an array of Vector3
  24417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24418. */
  24419. getFacetLocalPositions(): Vector3[];
  24420. /**
  24421. * Returns the facetLocalPartioning array
  24422. * @returns an array of array of numbers
  24423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24424. */
  24425. getFacetLocalPartitioning(): number[][];
  24426. /**
  24427. * Returns the i-th facet position in the world system.
  24428. * This method allocates a new Vector3 per call
  24429. * @param i defines the facet index
  24430. * @returns a new Vector3
  24431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24432. */
  24433. getFacetPosition(i: number): Vector3;
  24434. /**
  24435. * Sets the reference Vector3 with the i-th facet position in the world system
  24436. * @param i defines the facet index
  24437. * @param ref defines the target vector
  24438. * @returns the current mesh
  24439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24440. */
  24441. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24442. /**
  24443. * Returns the i-th facet normal in the world system.
  24444. * This method allocates a new Vector3 per call
  24445. * @param i defines the facet index
  24446. * @returns a new Vector3
  24447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24448. */
  24449. getFacetNormal(i: number): Vector3;
  24450. /**
  24451. * Sets the reference Vector3 with the i-th facet normal in the world system
  24452. * @param i defines the facet index
  24453. * @param ref defines the target vector
  24454. * @returns the current mesh
  24455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24456. */
  24457. getFacetNormalToRef(i: number, ref: Vector3): this;
  24458. /**
  24459. * 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)
  24460. * @param x defines x coordinate
  24461. * @param y defines y coordinate
  24462. * @param z defines z coordinate
  24463. * @returns the array of facet indexes
  24464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24465. */
  24466. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24467. /**
  24468. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24469. * @param projected sets as the (x,y,z) world projection on the facet
  24470. * @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
  24471. * @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
  24472. * @param x defines x coordinate
  24473. * @param y defines y coordinate
  24474. * @param z defines z coordinate
  24475. * @returns the face index if found (or null instead)
  24476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24477. */
  24478. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24479. /**
  24480. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24481. * @param projected sets as the (x,y,z) local projection on the facet
  24482. * @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
  24483. * @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
  24484. * @param x defines x coordinate
  24485. * @param y defines y coordinate
  24486. * @param z defines z coordinate
  24487. * @returns the face index if found (or null instead)
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24491. /**
  24492. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24493. * @returns the parameters
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24495. */
  24496. getFacetDataParameters(): any;
  24497. /**
  24498. * Disables the feature FacetData and frees the related memory
  24499. * @returns the current mesh
  24500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24501. */
  24502. disableFacetData(): AbstractMesh;
  24503. /**
  24504. * Updates the AbstractMesh indices array
  24505. * @param indices defines the data source
  24506. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24507. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24508. * @returns the current mesh
  24509. */
  24510. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24511. /**
  24512. * Creates new normals data for the mesh
  24513. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24514. * @returns the current mesh
  24515. */
  24516. createNormals(updatable: boolean): AbstractMesh;
  24517. /**
  24518. * Align the mesh with a normal
  24519. * @param normal defines the normal to use
  24520. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24521. * @returns the current mesh
  24522. */
  24523. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24524. /** @hidden */ checkOcclusionQuery(): boolean;
  24525. }
  24526. }
  24527. declare module BABYLON {
  24528. /**
  24529. * Interface used to define ActionEvent
  24530. */
  24531. export interface IActionEvent {
  24532. /** The mesh or sprite that triggered the action */
  24533. source: any;
  24534. /** The X mouse cursor position at the time of the event */
  24535. pointerX: number;
  24536. /** The Y mouse cursor position at the time of the event */
  24537. pointerY: number;
  24538. /** The mesh that is currently pointed at (can be null) */
  24539. meshUnderPointer: Nullable<AbstractMesh>;
  24540. /** the original (browser) event that triggered the ActionEvent */
  24541. sourceEvent?: any;
  24542. /** additional data for the event */
  24543. additionalData?: any;
  24544. }
  24545. /**
  24546. * ActionEvent is the event being sent when an action is triggered.
  24547. */
  24548. export class ActionEvent implements IActionEvent {
  24549. /** The mesh or sprite that triggered the action */
  24550. source: any;
  24551. /** The X mouse cursor position at the time of the event */
  24552. pointerX: number;
  24553. /** The Y mouse cursor position at the time of the event */
  24554. pointerY: number;
  24555. /** The mesh that is currently pointed at (can be null) */
  24556. meshUnderPointer: Nullable<AbstractMesh>;
  24557. /** the original (browser) event that triggered the ActionEvent */
  24558. sourceEvent?: any;
  24559. /** additional data for the event */
  24560. additionalData?: any;
  24561. /**
  24562. * Creates a new ActionEvent
  24563. * @param source The mesh or sprite that triggered the action
  24564. * @param pointerX The X mouse cursor position at the time of the event
  24565. * @param pointerY The Y mouse cursor position at the time of the event
  24566. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24567. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24568. * @param additionalData additional data for the event
  24569. */
  24570. constructor(
  24571. /** The mesh or sprite that triggered the action */
  24572. source: any,
  24573. /** The X mouse cursor position at the time of the event */
  24574. pointerX: number,
  24575. /** The Y mouse cursor position at the time of the event */
  24576. pointerY: number,
  24577. /** The mesh that is currently pointed at (can be null) */
  24578. meshUnderPointer: Nullable<AbstractMesh>,
  24579. /** the original (browser) event that triggered the ActionEvent */
  24580. sourceEvent?: any,
  24581. /** additional data for the event */
  24582. additionalData?: any);
  24583. /**
  24584. * Helper function to auto-create an ActionEvent from a source mesh.
  24585. * @param source The source mesh that triggered the event
  24586. * @param evt The original (browser) event
  24587. * @param additionalData additional data for the event
  24588. * @returns the new ActionEvent
  24589. */
  24590. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24591. /**
  24592. * Helper function to auto-create an ActionEvent from a source sprite
  24593. * @param source The source sprite that triggered the event
  24594. * @param scene Scene associated with the sprite
  24595. * @param evt The original (browser) event
  24596. * @param additionalData additional data for the event
  24597. * @returns the new ActionEvent
  24598. */
  24599. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24600. /**
  24601. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24602. * @param scene the scene where the event occurred
  24603. * @param evt The original (browser) event
  24604. * @returns the new ActionEvent
  24605. */
  24606. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24607. /**
  24608. * Helper function to auto-create an ActionEvent from a primitive
  24609. * @param prim defines the target primitive
  24610. * @param pointerPos defines the pointer position
  24611. * @param evt The original (browser) event
  24612. * @param additionalData additional data for the event
  24613. * @returns the new ActionEvent
  24614. */
  24615. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24616. }
  24617. }
  24618. declare module BABYLON {
  24619. /**
  24620. * Abstract class used to decouple action Manager from scene and meshes.
  24621. * Do not instantiate.
  24622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24623. */
  24624. export abstract class AbstractActionManager implements IDisposable {
  24625. /** Gets the list of active triggers */
  24626. static Triggers: {
  24627. [key: string]: number;
  24628. };
  24629. /** Gets the cursor to use when hovering items */
  24630. hoverCursor: string;
  24631. /** Gets the list of actions */
  24632. actions: IAction[];
  24633. /**
  24634. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24635. */
  24636. isRecursive: boolean;
  24637. /**
  24638. * Releases all associated resources
  24639. */
  24640. abstract dispose(): void;
  24641. /**
  24642. * Does this action manager has pointer triggers
  24643. */
  24644. abstract readonly hasPointerTriggers: boolean;
  24645. /**
  24646. * Does this action manager has pick triggers
  24647. */
  24648. abstract readonly hasPickTriggers: boolean;
  24649. /**
  24650. * Process a specific trigger
  24651. * @param trigger defines the trigger to process
  24652. * @param evt defines the event details to be processed
  24653. */
  24654. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24655. /**
  24656. * Does this action manager handles actions of any of the given triggers
  24657. * @param triggers defines the triggers to be tested
  24658. * @return a boolean indicating whether one (or more) of the triggers is handled
  24659. */
  24660. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24661. /**
  24662. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24663. * speed.
  24664. * @param triggerA defines the trigger to be tested
  24665. * @param triggerB defines the trigger to be tested
  24666. * @return a boolean indicating whether one (or more) of the triggers is handled
  24667. */
  24668. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24669. /**
  24670. * Does this action manager handles actions of a given trigger
  24671. * @param trigger defines the trigger to be tested
  24672. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24673. * @return whether the trigger is handled
  24674. */
  24675. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24676. /**
  24677. * Serialize this manager to a JSON object
  24678. * @param name defines the property name to store this manager
  24679. * @returns a JSON representation of this manager
  24680. */
  24681. abstract serialize(name: string): any;
  24682. /**
  24683. * Registers an action to this action manager
  24684. * @param action defines the action to be registered
  24685. * @return the action amended (prepared) after registration
  24686. */
  24687. abstract registerAction(action: IAction): Nullable<IAction>;
  24688. /**
  24689. * Unregisters an action to this action manager
  24690. * @param action defines the action to be unregistered
  24691. * @return a boolean indicating whether the action has been unregistered
  24692. */
  24693. abstract unregisterAction(action: IAction): Boolean;
  24694. /**
  24695. * Does exist one action manager with at least one trigger
  24696. **/
  24697. static readonly HasTriggers: boolean;
  24698. /**
  24699. * Does exist one action manager with at least one pick trigger
  24700. **/
  24701. static readonly HasPickTriggers: boolean;
  24702. /**
  24703. * Does exist one action manager that handles actions of a given trigger
  24704. * @param trigger defines the trigger to be tested
  24705. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24706. **/
  24707. static HasSpecificTrigger(trigger: number): boolean;
  24708. }
  24709. }
  24710. declare module BABYLON {
  24711. /**
  24712. * Defines how a node can be built from a string name.
  24713. */
  24714. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24715. /**
  24716. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24717. */
  24718. export class Node implements IBehaviorAware<Node> {
  24719. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24720. private static _NodeConstructors;
  24721. /**
  24722. * Add a new node constructor
  24723. * @param type defines the type name of the node to construct
  24724. * @param constructorFunc defines the constructor function
  24725. */
  24726. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24727. /**
  24728. * Returns a node constructor based on type name
  24729. * @param type defines the type name
  24730. * @param name defines the new node name
  24731. * @param scene defines the hosting scene
  24732. * @param options defines optional options to transmit to constructors
  24733. * @returns the new constructor or null
  24734. */
  24735. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24736. /**
  24737. * Gets or sets the name of the node
  24738. */
  24739. name: string;
  24740. /**
  24741. * Gets or sets the id of the node
  24742. */
  24743. id: string;
  24744. /**
  24745. * Gets or sets the unique id of the node
  24746. */
  24747. uniqueId: number;
  24748. /**
  24749. * Gets or sets a string used to store user defined state for the node
  24750. */
  24751. state: string;
  24752. /**
  24753. * Gets or sets an object used to store user defined information for the node
  24754. */
  24755. metadata: any;
  24756. /**
  24757. * For internal use only. Please do not use.
  24758. */
  24759. reservedDataStore: any;
  24760. /**
  24761. * List of inspectable custom properties (used by the Inspector)
  24762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24763. */
  24764. inspectableCustomProperties: IInspectable[];
  24765. /**
  24766. * Gets or sets a boolean used to define if the node must be serialized
  24767. */
  24768. doNotSerialize: boolean;
  24769. /** @hidden */ isDisposed: boolean;
  24770. /**
  24771. * Gets a list of Animations associated with the node
  24772. */
  24773. animations: Animation[];
  24774. protected _ranges: {
  24775. [name: string]: Nullable<AnimationRange>;
  24776. };
  24777. /**
  24778. * Callback raised when the node is ready to be used
  24779. */
  24780. onReady: Nullable<(node: Node) => void>;
  24781. private _isEnabled;
  24782. private _isParentEnabled;
  24783. private _isReady;
  24784. /** @hidden */ currentRenderId: number;
  24785. private _parentUpdateId;
  24786. /** @hidden */ childUpdateId: number;
  24787. /** @hidden */ waitingParentId: Nullable<string>;
  24788. /** @hidden */ scene: Scene;
  24789. /** @hidden */ cache: any;
  24790. private _parentNode;
  24791. private _children;
  24792. /** @hidden */ worldMatrix: Matrix;
  24793. /** @hidden */ worldMatrixDeterminant: number;
  24794. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24795. /** @hidden */
  24796. private _sceneRootNodesIndex;
  24797. /**
  24798. * Gets a boolean indicating if the node has been disposed
  24799. * @returns true if the node was disposed
  24800. */
  24801. isDisposed(): boolean;
  24802. /**
  24803. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24804. * @see https://doc.babylonjs.com/how_to/parenting
  24805. */
  24806. parent: Nullable<Node>;
  24807. private addToSceneRootNodes;
  24808. private removeFromSceneRootNodes;
  24809. private _animationPropertiesOverride;
  24810. /**
  24811. * Gets or sets the animation properties override
  24812. */
  24813. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24814. /**
  24815. * Gets a string idenfifying the name of the class
  24816. * @returns "Node" string
  24817. */
  24818. getClassName(): string;
  24819. /** @hidden */ protected readonly _isNode: boolean;
  24820. /**
  24821. * An event triggered when the mesh is disposed
  24822. */
  24823. onDisposeObservable: Observable<Node>;
  24824. private _onDisposeObserver;
  24825. /**
  24826. * Sets a callback that will be raised when the node will be disposed
  24827. */
  24828. onDispose: () => void;
  24829. /**
  24830. * Creates a new Node
  24831. * @param name the name and id to be given to this node
  24832. * @param scene the scene this node will be added to
  24833. * @param addToRootNodes the node will be added to scene.rootNodes
  24834. */
  24835. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24836. /**
  24837. * Gets the scene of the node
  24838. * @returns a scene
  24839. */
  24840. getScene(): Scene;
  24841. /**
  24842. * Gets the engine of the node
  24843. * @returns a Engine
  24844. */
  24845. getEngine(): Engine;
  24846. private _behaviors;
  24847. /**
  24848. * Attach a behavior to the node
  24849. * @see http://doc.babylonjs.com/features/behaviour
  24850. * @param behavior defines the behavior to attach
  24851. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24852. * @returns the current Node
  24853. */
  24854. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24855. /**
  24856. * Remove an attached behavior
  24857. * @see http://doc.babylonjs.com/features/behaviour
  24858. * @param behavior defines the behavior to attach
  24859. * @returns the current Node
  24860. */
  24861. removeBehavior(behavior: Behavior<Node>): Node;
  24862. /**
  24863. * Gets the list of attached behaviors
  24864. * @see http://doc.babylonjs.com/features/behaviour
  24865. */
  24866. readonly behaviors: Behavior<Node>[];
  24867. /**
  24868. * Gets an attached behavior by name
  24869. * @param name defines the name of the behavior to look for
  24870. * @see http://doc.babylonjs.com/features/behaviour
  24871. * @returns null if behavior was not found else the requested behavior
  24872. */
  24873. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24874. /**
  24875. * Returns the latest update of the World matrix
  24876. * @returns a Matrix
  24877. */
  24878. getWorldMatrix(): Matrix;
  24879. /** @hidden */ getWorldMatrixDeterminant(): number;
  24880. /**
  24881. * Returns directly the latest state of the mesh World matrix.
  24882. * A Matrix is returned.
  24883. */
  24884. readonly worldMatrixFromCache: Matrix;
  24885. /** @hidden */ initCache(): void;
  24886. /** @hidden */
  24887. updateCache(force?: boolean): void;
  24888. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24889. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24890. /** @hidden */ isSynchronized(): boolean;
  24891. /** @hidden */ markSyncedWithParent(): void;
  24892. /** @hidden */
  24893. isSynchronizedWithParent(): boolean;
  24894. /** @hidden */
  24895. isSynchronized(): boolean;
  24896. /**
  24897. * Is this node ready to be used/rendered
  24898. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24899. * @return true if the node is ready
  24900. */
  24901. isReady(completeCheck?: boolean): boolean;
  24902. /**
  24903. * Is this node enabled?
  24904. * 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
  24905. * @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
  24906. * @return whether this node (and its parent) is enabled
  24907. */
  24908. isEnabled(checkAncestors?: boolean): boolean;
  24909. /** @hidden */
  24910. protected _syncParentEnabledState(): void;
  24911. /**
  24912. * Set the enabled state of this node
  24913. * @param value defines the new enabled state
  24914. */
  24915. setEnabled(value: boolean): void;
  24916. /**
  24917. * Is this node a descendant of the given node?
  24918. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24919. * @param ancestor defines the parent node to inspect
  24920. * @returns a boolean indicating if this node is a descendant of the given node
  24921. */
  24922. isDescendantOf(ancestor: Node): boolean;
  24923. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24924. /**
  24925. * Will return all nodes that have this node as ascendant
  24926. * @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
  24927. * @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
  24928. * @return all children nodes of all types
  24929. */
  24930. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24931. /**
  24932. * Get all child-meshes of this node
  24933. * @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)
  24934. * @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
  24935. * @returns an array of AbstractMesh
  24936. */
  24937. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24938. /**
  24939. * Get all direct children of this node
  24940. * @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
  24941. * @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)
  24942. * @returns an array of Node
  24943. */
  24944. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24945. /** @hidden */ setReady(state: boolean): void;
  24946. /**
  24947. * Get an animation by name
  24948. * @param name defines the name of the animation to look for
  24949. * @returns null if not found else the requested animation
  24950. */
  24951. getAnimationByName(name: string): Nullable<Animation>;
  24952. /**
  24953. * Creates an animation range for this node
  24954. * @param name defines the name of the range
  24955. * @param from defines the starting key
  24956. * @param to defines the end key
  24957. */
  24958. createAnimationRange(name: string, from: number, to: number): void;
  24959. /**
  24960. * Delete a specific animation range
  24961. * @param name defines the name of the range to delete
  24962. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24963. */
  24964. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24965. /**
  24966. * Get an animation range by name
  24967. * @param name defines the name of the animation range to look for
  24968. * @returns null if not found else the requested animation range
  24969. */
  24970. getAnimationRange(name: string): Nullable<AnimationRange>;
  24971. /**
  24972. * Gets the list of all animation ranges defined on this node
  24973. * @returns an array
  24974. */
  24975. getAnimationRanges(): Nullable<AnimationRange>[];
  24976. /**
  24977. * Will start the animation sequence
  24978. * @param name defines the range frames for animation sequence
  24979. * @param loop defines if the animation should loop (false by default)
  24980. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24981. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24982. * @returns the object created for this animation. If range does not exist, it will return null
  24983. */
  24984. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24985. /**
  24986. * Serialize animation ranges into a JSON compatible object
  24987. * @returns serialization object
  24988. */
  24989. serializeAnimationRanges(): any;
  24990. /**
  24991. * Computes the world matrix of the node
  24992. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24993. * @returns the world matrix
  24994. */
  24995. computeWorldMatrix(force?: boolean): Matrix;
  24996. /**
  24997. * Releases resources associated with this node.
  24998. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24999. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25000. */
  25001. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25002. /**
  25003. * Parse animation range data from a serialization object and store them into a given node
  25004. * @param node defines where to store the animation ranges
  25005. * @param parsedNode defines the serialization object to read data from
  25006. * @param scene defines the hosting scene
  25007. */
  25008. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25009. /**
  25010. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25011. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25012. * @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
  25013. * @returns the new bounding vectors
  25014. */
  25015. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25016. min: Vector3;
  25017. max: Vector3;
  25018. };
  25019. }
  25020. }
  25021. declare module BABYLON {
  25022. /**
  25023. * @hidden
  25024. */
  25025. export class _IAnimationState {
  25026. key: number;
  25027. repeatCount: number;
  25028. workValue?: any;
  25029. loopMode?: number;
  25030. offsetValue?: any;
  25031. highLimitValue?: any;
  25032. }
  25033. /**
  25034. * Class used to store any kind of animation
  25035. */
  25036. export class Animation {
  25037. /**Name of the animation */
  25038. name: string;
  25039. /**Property to animate */
  25040. targetProperty: string;
  25041. /**The frames per second of the animation */
  25042. framePerSecond: number;
  25043. /**The data type of the animation */
  25044. dataType: number;
  25045. /**The loop mode of the animation */
  25046. loopMode?: number | undefined;
  25047. /**Specifies if blending should be enabled */
  25048. enableBlending?: boolean | undefined;
  25049. /**
  25050. * Use matrix interpolation instead of using direct key value when animating matrices
  25051. */
  25052. static AllowMatricesInterpolation: boolean;
  25053. /**
  25054. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25055. */
  25056. static AllowMatrixDecomposeForInterpolation: boolean;
  25057. /**
  25058. * Stores the key frames of the animation
  25059. */
  25060. private _keys;
  25061. /**
  25062. * Stores the easing function of the animation
  25063. */
  25064. private _easingFunction;
  25065. /**
  25066. * @hidden Internal use only
  25067. */ runtimeAnimations: RuntimeAnimation[];
  25068. /**
  25069. * The set of event that will be linked to this animation
  25070. */
  25071. private _events;
  25072. /**
  25073. * Stores an array of target property paths
  25074. */
  25075. targetPropertyPath: string[];
  25076. /**
  25077. * Stores the blending speed of the animation
  25078. */
  25079. blendingSpeed: number;
  25080. /**
  25081. * Stores the animation ranges for the animation
  25082. */
  25083. private _ranges;
  25084. /**
  25085. * @hidden Internal use
  25086. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25087. /**
  25088. * Sets up an animation
  25089. * @param property The property to animate
  25090. * @param animationType The animation type to apply
  25091. * @param framePerSecond The frames per second of the animation
  25092. * @param easingFunction The easing function used in the animation
  25093. * @returns The created animation
  25094. */
  25095. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25096. /**
  25097. * Create and start an animation on a node
  25098. * @param name defines the name of the global animation that will be run on all nodes
  25099. * @param node defines the root node where the animation will take place
  25100. * @param targetProperty defines property to animate
  25101. * @param framePerSecond defines the number of frame per second yo use
  25102. * @param totalFrame defines the number of frames in total
  25103. * @param from defines the initial value
  25104. * @param to defines the final value
  25105. * @param loopMode defines which loop mode you want to use (off by default)
  25106. * @param easingFunction defines the easing function to use (linear by default)
  25107. * @param onAnimationEnd defines the callback to call when animation end
  25108. * @returns the animatable created for this animation
  25109. */
  25110. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25111. /**
  25112. * Create and start an animation on a node and its descendants
  25113. * @param name defines the name of the global animation that will be run on all nodes
  25114. * @param node defines the root node where the animation will take place
  25115. * @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
  25116. * @param targetProperty defines property to animate
  25117. * @param framePerSecond defines the number of frame per second to use
  25118. * @param totalFrame defines the number of frames in total
  25119. * @param from defines the initial value
  25120. * @param to defines the final value
  25121. * @param loopMode defines which loop mode you want to use (off by default)
  25122. * @param easingFunction defines the easing function to use (linear by default)
  25123. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25124. * @returns the list of animatables created for all nodes
  25125. * @example https://www.babylonjs-playground.com/#MH0VLI
  25126. */
  25127. 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[]>;
  25128. /**
  25129. * Creates a new animation, merges it with the existing animations and starts it
  25130. * @param name Name of the animation
  25131. * @param node Node which contains the scene that begins the animations
  25132. * @param targetProperty Specifies which property to animate
  25133. * @param framePerSecond The frames per second of the animation
  25134. * @param totalFrame The total number of frames
  25135. * @param from The frame at the beginning of the animation
  25136. * @param to The frame at the end of the animation
  25137. * @param loopMode Specifies the loop mode of the animation
  25138. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25139. * @param onAnimationEnd Callback to run once the animation is complete
  25140. * @returns Nullable animation
  25141. */
  25142. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25143. /**
  25144. * Transition property of an host to the target Value
  25145. * @param property The property to transition
  25146. * @param targetValue The target Value of the property
  25147. * @param host The object where the property to animate belongs
  25148. * @param scene Scene used to run the animation
  25149. * @param frameRate Framerate (in frame/s) to use
  25150. * @param transition The transition type we want to use
  25151. * @param duration The duration of the animation, in milliseconds
  25152. * @param onAnimationEnd Callback trigger at the end of the animation
  25153. * @returns Nullable animation
  25154. */
  25155. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25156. /**
  25157. * Return the array of runtime animations currently using this animation
  25158. */
  25159. readonly runtimeAnimations: RuntimeAnimation[];
  25160. /**
  25161. * Specifies if any of the runtime animations are currently running
  25162. */
  25163. readonly hasRunningRuntimeAnimations: boolean;
  25164. /**
  25165. * Initializes the animation
  25166. * @param name Name of the animation
  25167. * @param targetProperty Property to animate
  25168. * @param framePerSecond The frames per second of the animation
  25169. * @param dataType The data type of the animation
  25170. * @param loopMode The loop mode of the animation
  25171. * @param enableBlending Specifies if blending should be enabled
  25172. */
  25173. constructor(
  25174. /**Name of the animation */
  25175. name: string,
  25176. /**Property to animate */
  25177. targetProperty: string,
  25178. /**The frames per second of the animation */
  25179. framePerSecond: number,
  25180. /**The data type of the animation */
  25181. dataType: number,
  25182. /**The loop mode of the animation */
  25183. loopMode?: number | undefined,
  25184. /**Specifies if blending should be enabled */
  25185. enableBlending?: boolean | undefined);
  25186. /**
  25187. * Converts the animation to a string
  25188. * @param fullDetails support for multiple levels of logging within scene loading
  25189. * @returns String form of the animation
  25190. */
  25191. toString(fullDetails?: boolean): string;
  25192. /**
  25193. * Add an event to this animation
  25194. * @param event Event to add
  25195. */
  25196. addEvent(event: AnimationEvent): void;
  25197. /**
  25198. * Remove all events found at the given frame
  25199. * @param frame The frame to remove events from
  25200. */
  25201. removeEvents(frame: number): void;
  25202. /**
  25203. * Retrieves all the events from the animation
  25204. * @returns Events from the animation
  25205. */
  25206. getEvents(): AnimationEvent[];
  25207. /**
  25208. * Creates an animation range
  25209. * @param name Name of the animation range
  25210. * @param from Starting frame of the animation range
  25211. * @param to Ending frame of the animation
  25212. */
  25213. createRange(name: string, from: number, to: number): void;
  25214. /**
  25215. * Deletes an animation range by name
  25216. * @param name Name of the animation range to delete
  25217. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25218. */
  25219. deleteRange(name: string, deleteFrames?: boolean): void;
  25220. /**
  25221. * Gets the animation range by name, or null if not defined
  25222. * @param name Name of the animation range
  25223. * @returns Nullable animation range
  25224. */
  25225. getRange(name: string): Nullable<AnimationRange>;
  25226. /**
  25227. * Gets the key frames from the animation
  25228. * @returns The key frames of the animation
  25229. */
  25230. getKeys(): Array<IAnimationKey>;
  25231. /**
  25232. * Gets the highest frame rate of the animation
  25233. * @returns Highest frame rate of the animation
  25234. */
  25235. getHighestFrame(): number;
  25236. /**
  25237. * Gets the easing function of the animation
  25238. * @returns Easing function of the animation
  25239. */
  25240. getEasingFunction(): IEasingFunction;
  25241. /**
  25242. * Sets the easing function of the animation
  25243. * @param easingFunction A custom mathematical formula for animation
  25244. */
  25245. setEasingFunction(easingFunction: EasingFunction): void;
  25246. /**
  25247. * Interpolates a scalar linearly
  25248. * @param startValue Start value of the animation curve
  25249. * @param endValue End value of the animation curve
  25250. * @param gradient Scalar amount to interpolate
  25251. * @returns Interpolated scalar value
  25252. */
  25253. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25254. /**
  25255. * Interpolates a scalar cubically
  25256. * @param startValue Start value of the animation curve
  25257. * @param outTangent End tangent of the animation
  25258. * @param endValue End value of the animation curve
  25259. * @param inTangent Start tangent of the animation curve
  25260. * @param gradient Scalar amount to interpolate
  25261. * @returns Interpolated scalar value
  25262. */
  25263. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25264. /**
  25265. * Interpolates a quaternion using a spherical linear interpolation
  25266. * @param startValue Start value of the animation curve
  25267. * @param endValue End value of the animation curve
  25268. * @param gradient Scalar amount to interpolate
  25269. * @returns Interpolated quaternion value
  25270. */
  25271. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25272. /**
  25273. * Interpolates a quaternion cubically
  25274. * @param startValue Start value of the animation curve
  25275. * @param outTangent End tangent of the animation curve
  25276. * @param endValue End value of the animation curve
  25277. * @param inTangent Start tangent of the animation curve
  25278. * @param gradient Scalar amount to interpolate
  25279. * @returns Interpolated quaternion value
  25280. */
  25281. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25282. /**
  25283. * Interpolates a Vector3 linearl
  25284. * @param startValue Start value of the animation curve
  25285. * @param endValue End value of the animation curve
  25286. * @param gradient Scalar amount to interpolate
  25287. * @returns Interpolated scalar value
  25288. */
  25289. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25290. /**
  25291. * Interpolates a Vector3 cubically
  25292. * @param startValue Start value of the animation curve
  25293. * @param outTangent End tangent of the animation
  25294. * @param endValue End value of the animation curve
  25295. * @param inTangent Start tangent of the animation curve
  25296. * @param gradient Scalar amount to interpolate
  25297. * @returns InterpolatedVector3 value
  25298. */
  25299. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25300. /**
  25301. * Interpolates a Vector2 linearly
  25302. * @param startValue Start value of the animation curve
  25303. * @param endValue End value of the animation curve
  25304. * @param gradient Scalar amount to interpolate
  25305. * @returns Interpolated Vector2 value
  25306. */
  25307. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25308. /**
  25309. * Interpolates a Vector2 cubically
  25310. * @param startValue Start value of the animation curve
  25311. * @param outTangent End tangent of the animation
  25312. * @param endValue End value of the animation curve
  25313. * @param inTangent Start tangent of the animation curve
  25314. * @param gradient Scalar amount to interpolate
  25315. * @returns Interpolated Vector2 value
  25316. */
  25317. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25318. /**
  25319. * Interpolates a size linearly
  25320. * @param startValue Start value of the animation curve
  25321. * @param endValue End value of the animation curve
  25322. * @param gradient Scalar amount to interpolate
  25323. * @returns Interpolated Size value
  25324. */
  25325. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25326. /**
  25327. * Interpolates a Color3 linearly
  25328. * @param startValue Start value of the animation curve
  25329. * @param endValue End value of the animation curve
  25330. * @param gradient Scalar amount to interpolate
  25331. * @returns Interpolated Color3 value
  25332. */
  25333. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25334. /**
  25335. * @hidden Internal use only
  25336. */ getKeyValue(value: any): any;
  25337. /**
  25338. * @hidden Internal use only
  25339. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25340. /**
  25341. * Defines the function to use to interpolate matrices
  25342. * @param startValue defines the start matrix
  25343. * @param endValue defines the end matrix
  25344. * @param gradient defines the gradient between both matrices
  25345. * @param result defines an optional target matrix where to store the interpolation
  25346. * @returns the interpolated matrix
  25347. */
  25348. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25349. /**
  25350. * Makes a copy of the animation
  25351. * @returns Cloned animation
  25352. */
  25353. clone(): Animation;
  25354. /**
  25355. * Sets the key frames of the animation
  25356. * @param values The animation key frames to set
  25357. */
  25358. setKeys(values: Array<IAnimationKey>): void;
  25359. /**
  25360. * Serializes the animation to an object
  25361. * @returns Serialized object
  25362. */
  25363. serialize(): any;
  25364. /**
  25365. * Float animation type
  25366. */
  25367. private static _ANIMATIONTYPE_FLOAT;
  25368. /**
  25369. * Vector3 animation type
  25370. */
  25371. private static _ANIMATIONTYPE_VECTOR3;
  25372. /**
  25373. * Quaternion animation type
  25374. */
  25375. private static _ANIMATIONTYPE_QUATERNION;
  25376. /**
  25377. * Matrix animation type
  25378. */
  25379. private static _ANIMATIONTYPE_MATRIX;
  25380. /**
  25381. * Color3 animation type
  25382. */
  25383. private static _ANIMATIONTYPE_COLOR3;
  25384. /**
  25385. * Vector2 animation type
  25386. */
  25387. private static _ANIMATIONTYPE_VECTOR2;
  25388. /**
  25389. * Size animation type
  25390. */
  25391. private static _ANIMATIONTYPE_SIZE;
  25392. /**
  25393. * Relative Loop Mode
  25394. */
  25395. private static _ANIMATIONLOOPMODE_RELATIVE;
  25396. /**
  25397. * Cycle Loop Mode
  25398. */
  25399. private static _ANIMATIONLOOPMODE_CYCLE;
  25400. /**
  25401. * Constant Loop Mode
  25402. */
  25403. private static _ANIMATIONLOOPMODE_CONSTANT;
  25404. /**
  25405. * Get the float animation type
  25406. */
  25407. static readonly ANIMATIONTYPE_FLOAT: number;
  25408. /**
  25409. * Get the Vector3 animation type
  25410. */
  25411. static readonly ANIMATIONTYPE_VECTOR3: number;
  25412. /**
  25413. * Get the Vector2 animation type
  25414. */
  25415. static readonly ANIMATIONTYPE_VECTOR2: number;
  25416. /**
  25417. * Get the Size animation type
  25418. */
  25419. static readonly ANIMATIONTYPE_SIZE: number;
  25420. /**
  25421. * Get the Quaternion animation type
  25422. */
  25423. static readonly ANIMATIONTYPE_QUATERNION: number;
  25424. /**
  25425. * Get the Matrix animation type
  25426. */
  25427. static readonly ANIMATIONTYPE_MATRIX: number;
  25428. /**
  25429. * Get the Color3 animation type
  25430. */
  25431. static readonly ANIMATIONTYPE_COLOR3: number;
  25432. /**
  25433. * Get the Relative Loop Mode
  25434. */
  25435. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25436. /**
  25437. * Get the Cycle Loop Mode
  25438. */
  25439. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25440. /**
  25441. * Get the Constant Loop Mode
  25442. */
  25443. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25444. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25445. /**
  25446. * Parses an animation object and creates an animation
  25447. * @param parsedAnimation Parsed animation object
  25448. * @returns Animation object
  25449. */
  25450. static Parse(parsedAnimation: any): Animation;
  25451. /**
  25452. * Appends the serialized animations from the source animations
  25453. * @param source Source containing the animations
  25454. * @param destination Target to store the animations
  25455. */
  25456. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25457. }
  25458. }
  25459. declare module BABYLON {
  25460. /**
  25461. * Base class of all the textures in babylon.
  25462. * It groups all the common properties the materials, post process, lights... might need
  25463. * in order to make a correct use of the texture.
  25464. */
  25465. export class BaseTexture implements IAnimatable {
  25466. /**
  25467. * Default anisotropic filtering level for the application.
  25468. * It is set to 4 as a good tradeoff between perf and quality.
  25469. */
  25470. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25471. /**
  25472. * Gets or sets the unique id of the texture
  25473. */
  25474. uniqueId: number;
  25475. /**
  25476. * Define the name of the texture.
  25477. */
  25478. name: string;
  25479. /**
  25480. * Gets or sets an object used to store user defined information.
  25481. */
  25482. metadata: any;
  25483. /**
  25484. * For internal use only. Please do not use.
  25485. */
  25486. reservedDataStore: any;
  25487. private _hasAlpha;
  25488. /**
  25489. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25490. */
  25491. hasAlpha: boolean;
  25492. /**
  25493. * Defines if the alpha value should be determined via the rgb values.
  25494. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25495. */
  25496. getAlphaFromRGB: boolean;
  25497. /**
  25498. * Intensity or strength of the texture.
  25499. * It is commonly used by materials to fine tune the intensity of the texture
  25500. */
  25501. level: number;
  25502. /**
  25503. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25504. * This is part of the texture as textures usually maps to one uv set.
  25505. */
  25506. coordinatesIndex: number;
  25507. private _coordinatesMode;
  25508. /**
  25509. * How a texture is mapped.
  25510. *
  25511. * | Value | Type | Description |
  25512. * | ----- | ----------------------------------- | ----------- |
  25513. * | 0 | EXPLICIT_MODE | |
  25514. * | 1 | SPHERICAL_MODE | |
  25515. * | 2 | PLANAR_MODE | |
  25516. * | 3 | CUBIC_MODE | |
  25517. * | 4 | PROJECTION_MODE | |
  25518. * | 5 | SKYBOX_MODE | |
  25519. * | 6 | INVCUBIC_MODE | |
  25520. * | 7 | EQUIRECTANGULAR_MODE | |
  25521. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25522. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25523. */
  25524. coordinatesMode: number;
  25525. /**
  25526. * | Value | Type | Description |
  25527. * | ----- | ------------------ | ----------- |
  25528. * | 0 | CLAMP_ADDRESSMODE | |
  25529. * | 1 | WRAP_ADDRESSMODE | |
  25530. * | 2 | MIRROR_ADDRESSMODE | |
  25531. */
  25532. wrapU: number;
  25533. /**
  25534. * | Value | Type | Description |
  25535. * | ----- | ------------------ | ----------- |
  25536. * | 0 | CLAMP_ADDRESSMODE | |
  25537. * | 1 | WRAP_ADDRESSMODE | |
  25538. * | 2 | MIRROR_ADDRESSMODE | |
  25539. */
  25540. wrapV: number;
  25541. /**
  25542. * | Value | Type | Description |
  25543. * | ----- | ------------------ | ----------- |
  25544. * | 0 | CLAMP_ADDRESSMODE | |
  25545. * | 1 | WRAP_ADDRESSMODE | |
  25546. * | 2 | MIRROR_ADDRESSMODE | |
  25547. */
  25548. wrapR: number;
  25549. /**
  25550. * With compliant hardware and browser (supporting anisotropic filtering)
  25551. * this defines the level of anisotropic filtering in the texture.
  25552. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25553. */
  25554. anisotropicFilteringLevel: number;
  25555. /**
  25556. * Define if the texture is a cube texture or if false a 2d texture.
  25557. */
  25558. isCube: boolean;
  25559. /**
  25560. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25561. */
  25562. is3D: boolean;
  25563. /**
  25564. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25565. * HDR texture are usually stored in linear space.
  25566. * This only impacts the PBR and Background materials
  25567. */
  25568. gammaSpace: boolean;
  25569. /**
  25570. * Gets whether or not the texture contains RGBD data.
  25571. */
  25572. readonly isRGBD: boolean;
  25573. /**
  25574. * Is Z inverted in the texture (useful in a cube texture).
  25575. */
  25576. invertZ: boolean;
  25577. /**
  25578. * Are mip maps generated for this texture or not.
  25579. */
  25580. readonly noMipmap: boolean;
  25581. /**
  25582. * @hidden
  25583. */
  25584. lodLevelInAlpha: boolean;
  25585. /**
  25586. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25587. */
  25588. lodGenerationOffset: number;
  25589. /**
  25590. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25591. */
  25592. lodGenerationScale: number;
  25593. /**
  25594. * Define if the texture is a render target.
  25595. */
  25596. isRenderTarget: boolean;
  25597. /**
  25598. * Define the unique id of the texture in the scene.
  25599. */
  25600. readonly uid: string;
  25601. /**
  25602. * Return a string representation of the texture.
  25603. * @returns the texture as a string
  25604. */
  25605. toString(): string;
  25606. /**
  25607. * Get the class name of the texture.
  25608. * @returns "BaseTexture"
  25609. */
  25610. getClassName(): string;
  25611. /**
  25612. * Define the list of animation attached to the texture.
  25613. */
  25614. animations: Animation[];
  25615. /**
  25616. * An event triggered when the texture is disposed.
  25617. */
  25618. onDisposeObservable: Observable<BaseTexture>;
  25619. private _onDisposeObserver;
  25620. /**
  25621. * Callback triggered when the texture has been disposed.
  25622. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25623. */
  25624. onDispose: () => void;
  25625. /**
  25626. * Define the current state of the loading sequence when in delayed load mode.
  25627. */
  25628. delayLoadState: number;
  25629. private _scene;
  25630. /** @hidden */ texture: Nullable<InternalTexture>;
  25631. private _uid;
  25632. /**
  25633. * Define if the texture is preventinga material to render or not.
  25634. * If not and the texture is not ready, the engine will use a default black texture instead.
  25635. */
  25636. readonly isBlocking: boolean;
  25637. /**
  25638. * Instantiates a new BaseTexture.
  25639. * Base class of all the textures in babylon.
  25640. * It groups all the common properties the materials, post process, lights... might need
  25641. * in order to make a correct use of the texture.
  25642. * @param scene Define the scene the texture blongs to
  25643. */
  25644. constructor(scene: Nullable<Scene>);
  25645. /**
  25646. * Get the scene the texture belongs to.
  25647. * @returns the scene or null if undefined
  25648. */
  25649. getScene(): Nullable<Scene>;
  25650. /**
  25651. * Get the texture transform matrix used to offset tile the texture for istance.
  25652. * @returns the transformation matrix
  25653. */
  25654. getTextureMatrix(): Matrix;
  25655. /**
  25656. * Get the texture reflection matrix used to rotate/transform the reflection.
  25657. * @returns the reflection matrix
  25658. */
  25659. getReflectionTextureMatrix(): Matrix;
  25660. /**
  25661. * Get the underlying lower level texture from Babylon.
  25662. * @returns the insternal texture
  25663. */
  25664. getInternalTexture(): Nullable<InternalTexture>;
  25665. /**
  25666. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25667. * @returns true if ready or not blocking
  25668. */
  25669. isReadyOrNotBlocking(): boolean;
  25670. /**
  25671. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25672. * @returns true if fully ready
  25673. */
  25674. isReady(): boolean;
  25675. private _cachedSize;
  25676. /**
  25677. * Get the size of the texture.
  25678. * @returns the texture size.
  25679. */
  25680. getSize(): ISize;
  25681. /**
  25682. * Get the base size of the texture.
  25683. * It can be different from the size if the texture has been resized for POT for instance
  25684. * @returns the base size
  25685. */
  25686. getBaseSize(): ISize;
  25687. /**
  25688. * Update the sampling mode of the texture.
  25689. * Default is Trilinear mode.
  25690. *
  25691. * | Value | Type | Description |
  25692. * | ----- | ------------------ | ----------- |
  25693. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25694. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25695. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25696. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25697. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25698. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25699. * | 7 | NEAREST_LINEAR | |
  25700. * | 8 | NEAREST_NEAREST | |
  25701. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25702. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25703. * | 11 | LINEAR_LINEAR | |
  25704. * | 12 | LINEAR_NEAREST | |
  25705. *
  25706. * > _mag_: magnification filter (close to the viewer)
  25707. * > _min_: minification filter (far from the viewer)
  25708. * > _mip_: filter used between mip map levels
  25709. *@param samplingMode Define the new sampling mode of the texture
  25710. */
  25711. updateSamplingMode(samplingMode: number): void;
  25712. /**
  25713. * Scales the texture if is `canRescale()`
  25714. * @param ratio the resize factor we want to use to rescale
  25715. */
  25716. scale(ratio: number): void;
  25717. /**
  25718. * Get if the texture can rescale.
  25719. */
  25720. readonly canRescale: boolean;
  25721. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25722. /** @hidden */ rebuild(): void;
  25723. /**
  25724. * Triggers the load sequence in delayed load mode.
  25725. */
  25726. delayLoad(): void;
  25727. /**
  25728. * Clones the texture.
  25729. * @returns the cloned texture
  25730. */
  25731. clone(): Nullable<BaseTexture>;
  25732. /**
  25733. * Get the texture underlying type (INT, FLOAT...)
  25734. */
  25735. readonly textureType: number;
  25736. /**
  25737. * Get the texture underlying format (RGB, RGBA...)
  25738. */
  25739. readonly textureFormat: number;
  25740. /**
  25741. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25742. * This will returns an RGBA array buffer containing either in values (0-255) or
  25743. * float values (0-1) depending of the underlying buffer type.
  25744. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25745. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25746. * @param buffer defines a user defined buffer to fill with data (can be null)
  25747. * @returns The Array buffer containing the pixels data.
  25748. */
  25749. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25750. /**
  25751. * Release and destroy the underlying lower level texture aka internalTexture.
  25752. */
  25753. releaseInternalTexture(): void;
  25754. /**
  25755. * Get the polynomial representation of the texture data.
  25756. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25757. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25758. */
  25759. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25760. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25761. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25762. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25763. /**
  25764. * Dispose the texture and release its associated resources.
  25765. */
  25766. dispose(): void;
  25767. /**
  25768. * Serialize the texture into a JSON representation that can be parsed later on.
  25769. * @returns the JSON representation of the texture
  25770. */
  25771. serialize(): any;
  25772. /**
  25773. * Helper function to be called back once a list of texture contains only ready textures.
  25774. * @param textures Define the list of textures to wait for
  25775. * @param callback Define the callback triggered once the entire list will be ready
  25776. */
  25777. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25778. }
  25779. }
  25780. declare module BABYLON {
  25781. /**
  25782. * Uniform buffer objects.
  25783. *
  25784. * Handles blocks of uniform on the GPU.
  25785. *
  25786. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25787. *
  25788. * For more information, please refer to :
  25789. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25790. */
  25791. export class UniformBuffer {
  25792. private _engine;
  25793. private _buffer;
  25794. private _data;
  25795. private _bufferData;
  25796. private _dynamic?;
  25797. private _uniformLocations;
  25798. private _uniformSizes;
  25799. private _uniformLocationPointer;
  25800. private _needSync;
  25801. private _noUBO;
  25802. private _currentEffect;
  25803. private static _MAX_UNIFORM_SIZE;
  25804. private static _tempBuffer;
  25805. /**
  25806. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25807. * This is dynamic to allow compat with webgl 1 and 2.
  25808. * You will need to pass the name of the uniform as well as the value.
  25809. */
  25810. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25811. /**
  25812. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25813. * This is dynamic to allow compat with webgl 1 and 2.
  25814. * You will need to pass the name of the uniform as well as the value.
  25815. */
  25816. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25817. /**
  25818. * Lambda to Update a single float in a uniform buffer.
  25819. * This is dynamic to allow compat with webgl 1 and 2.
  25820. * You will need to pass the name of the uniform as well as the value.
  25821. */
  25822. updateFloat: (name: string, x: number) => void;
  25823. /**
  25824. * Lambda to Update a vec2 of float in a uniform buffer.
  25825. * This is dynamic to allow compat with webgl 1 and 2.
  25826. * You will need to pass the name of the uniform as well as the value.
  25827. */
  25828. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25829. /**
  25830. * Lambda to Update a vec3 of float in a uniform buffer.
  25831. * This is dynamic to allow compat with webgl 1 and 2.
  25832. * You will need to pass the name of the uniform as well as the value.
  25833. */
  25834. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25835. /**
  25836. * Lambda to Update a vec4 of float in a uniform buffer.
  25837. * This is dynamic to allow compat with webgl 1 and 2.
  25838. * You will need to pass the name of the uniform as well as the value.
  25839. */
  25840. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25841. /**
  25842. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25843. * This is dynamic to allow compat with webgl 1 and 2.
  25844. * You will need to pass the name of the uniform as well as the value.
  25845. */
  25846. updateMatrix: (name: string, mat: Matrix) => void;
  25847. /**
  25848. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25849. * This is dynamic to allow compat with webgl 1 and 2.
  25850. * You will need to pass the name of the uniform as well as the value.
  25851. */
  25852. updateVector3: (name: string, vector: Vector3) => void;
  25853. /**
  25854. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25855. * This is dynamic to allow compat with webgl 1 and 2.
  25856. * You will need to pass the name of the uniform as well as the value.
  25857. */
  25858. updateVector4: (name: string, vector: Vector4) => void;
  25859. /**
  25860. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25861. * This is dynamic to allow compat with webgl 1 and 2.
  25862. * You will need to pass the name of the uniform as well as the value.
  25863. */
  25864. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25865. /**
  25866. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25867. * This is dynamic to allow compat with webgl 1 and 2.
  25868. * You will need to pass the name of the uniform as well as the value.
  25869. */
  25870. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25871. /**
  25872. * Instantiates a new Uniform buffer objects.
  25873. *
  25874. * Handles blocks of uniform on the GPU.
  25875. *
  25876. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25877. *
  25878. * For more information, please refer to :
  25879. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25880. * @param engine Define the engine the buffer is associated with
  25881. * @param data Define the data contained in the buffer
  25882. * @param dynamic Define if the buffer is updatable
  25883. */
  25884. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25885. /**
  25886. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25887. * or just falling back on setUniformXXX calls.
  25888. */
  25889. readonly useUbo: boolean;
  25890. /**
  25891. * Indicates if the WebGL underlying uniform buffer is in sync
  25892. * with the javascript cache data.
  25893. */
  25894. readonly isSync: boolean;
  25895. /**
  25896. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25897. * Also, a dynamic UniformBuffer will disable cache verification and always
  25898. * update the underlying WebGL uniform buffer to the GPU.
  25899. * @returns if Dynamic, otherwise false
  25900. */
  25901. isDynamic(): boolean;
  25902. /**
  25903. * The data cache on JS side.
  25904. * @returns the underlying data as a float array
  25905. */
  25906. getData(): Float32Array;
  25907. /**
  25908. * The underlying WebGL Uniform buffer.
  25909. * @returns the webgl buffer
  25910. */
  25911. getBuffer(): Nullable<DataBuffer>;
  25912. /**
  25913. * std140 layout specifies how to align data within an UBO structure.
  25914. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25915. * for specs.
  25916. */
  25917. private _fillAlignment;
  25918. /**
  25919. * Adds an uniform in the buffer.
  25920. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25921. * for the layout to be correct !
  25922. * @param name Name of the uniform, as used in the uniform block in the shader.
  25923. * @param size Data size, or data directly.
  25924. */
  25925. addUniform(name: string, size: number | number[]): void;
  25926. /**
  25927. * Adds a Matrix 4x4 to the uniform buffer.
  25928. * @param name Name of the uniform, as used in the uniform block in the shader.
  25929. * @param mat A 4x4 matrix.
  25930. */
  25931. addMatrix(name: string, mat: Matrix): void;
  25932. /**
  25933. * Adds a vec2 to the uniform buffer.
  25934. * @param name Name of the uniform, as used in the uniform block in the shader.
  25935. * @param x Define the x component value of the vec2
  25936. * @param y Define the y component value of the vec2
  25937. */
  25938. addFloat2(name: string, x: number, y: number): void;
  25939. /**
  25940. * Adds a vec3 to the uniform buffer.
  25941. * @param name Name of the uniform, as used in the uniform block in the shader.
  25942. * @param x Define the x component value of the vec3
  25943. * @param y Define the y component value of the vec3
  25944. * @param z Define the z component value of the vec3
  25945. */
  25946. addFloat3(name: string, x: number, y: number, z: number): void;
  25947. /**
  25948. * Adds a vec3 to the uniform buffer.
  25949. * @param name Name of the uniform, as used in the uniform block in the shader.
  25950. * @param color Define the vec3 from a Color
  25951. */
  25952. addColor3(name: string, color: Color3): void;
  25953. /**
  25954. * Adds a vec4 to the uniform buffer.
  25955. * @param name Name of the uniform, as used in the uniform block in the shader.
  25956. * @param color Define the rgb components from a Color
  25957. * @param alpha Define the a component of the vec4
  25958. */
  25959. addColor4(name: string, color: Color3, alpha: number): void;
  25960. /**
  25961. * Adds a vec3 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. * @param vector Define the vec3 components from a Vector
  25964. */
  25965. addVector3(name: string, vector: Vector3): void;
  25966. /**
  25967. * Adds a Matrix 3x3 to the uniform buffer.
  25968. * @param name Name of the uniform, as used in the uniform block in the shader.
  25969. */
  25970. addMatrix3x3(name: string): void;
  25971. /**
  25972. * Adds a Matrix 2x2 to the uniform buffer.
  25973. * @param name Name of the uniform, as used in the uniform block in the shader.
  25974. */
  25975. addMatrix2x2(name: string): void;
  25976. /**
  25977. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25978. */
  25979. create(): void;
  25980. /** @hidden */ rebuild(): void;
  25981. /**
  25982. * Updates the WebGL Uniform Buffer on the GPU.
  25983. * If the `dynamic` flag is set to true, no cache comparison is done.
  25984. * Otherwise, the buffer will be updated only if the cache differs.
  25985. */
  25986. update(): void;
  25987. /**
  25988. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25989. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25990. * @param data Define the flattened data
  25991. * @param size Define the size of the data.
  25992. */
  25993. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25994. private _updateMatrix3x3ForUniform;
  25995. private _updateMatrix3x3ForEffect;
  25996. private _updateMatrix2x2ForEffect;
  25997. private _updateMatrix2x2ForUniform;
  25998. private _updateFloatForEffect;
  25999. private _updateFloatForUniform;
  26000. private _updateFloat2ForEffect;
  26001. private _updateFloat2ForUniform;
  26002. private _updateFloat3ForEffect;
  26003. private _updateFloat3ForUniform;
  26004. private _updateFloat4ForEffect;
  26005. private _updateFloat4ForUniform;
  26006. private _updateMatrixForEffect;
  26007. private _updateMatrixForUniform;
  26008. private _updateVector3ForEffect;
  26009. private _updateVector3ForUniform;
  26010. private _updateVector4ForEffect;
  26011. private _updateVector4ForUniform;
  26012. private _updateColor3ForEffect;
  26013. private _updateColor3ForUniform;
  26014. private _updateColor4ForEffect;
  26015. private _updateColor4ForUniform;
  26016. /**
  26017. * Sets a sampler uniform on the effect.
  26018. * @param name Define the name of the sampler.
  26019. * @param texture Define the texture to set in the sampler
  26020. */
  26021. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26022. /**
  26023. * Directly updates the value of the uniform in the cache AND on the GPU.
  26024. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26025. * @param data Define the flattened data
  26026. */
  26027. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26028. /**
  26029. * Binds this uniform buffer to an effect.
  26030. * @param effect Define the effect to bind the buffer to
  26031. * @param name Name of the uniform block in the shader.
  26032. */
  26033. bindToEffect(effect: Effect, name: string): void;
  26034. /**
  26035. * Disposes the uniform buffer.
  26036. */
  26037. dispose(): void;
  26038. }
  26039. }
  26040. declare module BABYLON {
  26041. /**
  26042. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26044. */
  26045. export class Analyser {
  26046. /**
  26047. * Gets or sets the smoothing
  26048. * @ignorenaming
  26049. */
  26050. SMOOTHING: number;
  26051. /**
  26052. * Gets or sets the FFT table size
  26053. * @ignorenaming
  26054. */
  26055. FFT_SIZE: number;
  26056. /**
  26057. * Gets or sets the bar graph amplitude
  26058. * @ignorenaming
  26059. */
  26060. BARGRAPHAMPLITUDE: number;
  26061. /**
  26062. * Gets or sets the position of the debug canvas
  26063. * @ignorenaming
  26064. */
  26065. DEBUGCANVASPOS: {
  26066. x: number;
  26067. y: number;
  26068. };
  26069. /**
  26070. * Gets or sets the debug canvas size
  26071. * @ignorenaming
  26072. */
  26073. DEBUGCANVASSIZE: {
  26074. width: number;
  26075. height: number;
  26076. };
  26077. private _byteFreqs;
  26078. private _byteTime;
  26079. private _floatFreqs;
  26080. private _webAudioAnalyser;
  26081. private _debugCanvas;
  26082. private _debugCanvasContext;
  26083. private _scene;
  26084. private _registerFunc;
  26085. private _audioEngine;
  26086. /**
  26087. * Creates a new analyser
  26088. * @param scene defines hosting scene
  26089. */
  26090. constructor(scene: Scene);
  26091. /**
  26092. * Get the number of data values you will have to play with for the visualization
  26093. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26094. * @returns a number
  26095. */
  26096. getFrequencyBinCount(): number;
  26097. /**
  26098. * Gets the current frequency data as a byte array
  26099. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26100. * @returns a Uint8Array
  26101. */
  26102. getByteFrequencyData(): Uint8Array;
  26103. /**
  26104. * Gets the current waveform as a byte array
  26105. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26106. * @returns a Uint8Array
  26107. */
  26108. getByteTimeDomainData(): Uint8Array;
  26109. /**
  26110. * Gets the current frequency data as a float array
  26111. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26112. * @returns a Float32Array
  26113. */
  26114. getFloatFrequencyData(): Float32Array;
  26115. /**
  26116. * Renders the debug canvas
  26117. */
  26118. drawDebugCanvas(): void;
  26119. /**
  26120. * Stops rendering the debug canvas and removes it
  26121. */
  26122. stopDebugCanvas(): void;
  26123. /**
  26124. * Connects two audio nodes
  26125. * @param inputAudioNode defines first node to connect
  26126. * @param outputAudioNode defines second node to connect
  26127. */
  26128. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26129. /**
  26130. * Releases all associated resources
  26131. */
  26132. dispose(): void;
  26133. }
  26134. }
  26135. declare module BABYLON {
  26136. /**
  26137. * This represents an audio engine and it is responsible
  26138. * to play, synchronize and analyse sounds throughout the application.
  26139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26140. */
  26141. export interface IAudioEngine extends IDisposable {
  26142. /**
  26143. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26144. */
  26145. readonly canUseWebAudio: boolean;
  26146. /**
  26147. * Gets the current AudioContext if available.
  26148. */
  26149. readonly audioContext: Nullable<AudioContext>;
  26150. /**
  26151. * The master gain node defines the global audio volume of your audio engine.
  26152. */
  26153. readonly masterGain: GainNode;
  26154. /**
  26155. * Gets whether or not mp3 are supported by your browser.
  26156. */
  26157. readonly isMP3supported: boolean;
  26158. /**
  26159. * Gets whether or not ogg are supported by your browser.
  26160. */
  26161. readonly isOGGsupported: boolean;
  26162. /**
  26163. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26164. * @ignoreNaming
  26165. */
  26166. WarnedWebAudioUnsupported: boolean;
  26167. /**
  26168. * Defines if the audio engine relies on a custom unlocked button.
  26169. * In this case, the embedded button will not be displayed.
  26170. */
  26171. useCustomUnlockedButton: boolean;
  26172. /**
  26173. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26174. */
  26175. readonly unlocked: boolean;
  26176. /**
  26177. * Event raised when audio has been unlocked on the browser.
  26178. */
  26179. onAudioUnlockedObservable: Observable<AudioEngine>;
  26180. /**
  26181. * Event raised when audio has been locked on the browser.
  26182. */
  26183. onAudioLockedObservable: Observable<AudioEngine>;
  26184. /**
  26185. * Flags the audio engine in Locked state.
  26186. * This happens due to new browser policies preventing audio to autoplay.
  26187. */
  26188. lock(): void;
  26189. /**
  26190. * Unlocks the audio engine once a user action has been done on the dom.
  26191. * This is helpful to resume play once browser policies have been satisfied.
  26192. */
  26193. unlock(): void;
  26194. }
  26195. /**
  26196. * This represents the default audio engine used in babylon.
  26197. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26199. */
  26200. export class AudioEngine implements IAudioEngine {
  26201. private _audioContext;
  26202. private _audioContextInitialized;
  26203. private _muteButton;
  26204. private _hostElement;
  26205. /**
  26206. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26207. */
  26208. canUseWebAudio: boolean;
  26209. /**
  26210. * The master gain node defines the global audio volume of your audio engine.
  26211. */
  26212. masterGain: GainNode;
  26213. /**
  26214. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26215. * @ignoreNaming
  26216. */
  26217. WarnedWebAudioUnsupported: boolean;
  26218. /**
  26219. * Gets whether or not mp3 are supported by your browser.
  26220. */
  26221. isMP3supported: boolean;
  26222. /**
  26223. * Gets whether or not ogg are supported by your browser.
  26224. */
  26225. isOGGsupported: boolean;
  26226. /**
  26227. * Gets whether audio has been unlocked on the device.
  26228. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26229. * a user interaction has happened.
  26230. */
  26231. unlocked: boolean;
  26232. /**
  26233. * Defines if the audio engine relies on a custom unlocked button.
  26234. * In this case, the embedded button will not be displayed.
  26235. */
  26236. useCustomUnlockedButton: boolean;
  26237. /**
  26238. * Event raised when audio has been unlocked on the browser.
  26239. */
  26240. onAudioUnlockedObservable: Observable<AudioEngine>;
  26241. /**
  26242. * Event raised when audio has been locked on the browser.
  26243. */
  26244. onAudioLockedObservable: Observable<AudioEngine>;
  26245. /**
  26246. * Gets the current AudioContext if available.
  26247. */
  26248. readonly audioContext: Nullable<AudioContext>;
  26249. private _connectedAnalyser;
  26250. /**
  26251. * Instantiates a new audio engine.
  26252. *
  26253. * There should be only one per page as some browsers restrict the number
  26254. * of audio contexts you can create.
  26255. * @param hostElement defines the host element where to display the mute icon if necessary
  26256. */
  26257. constructor(hostElement?: Nullable<HTMLElement>);
  26258. /**
  26259. * Flags the audio engine in Locked state.
  26260. * This happens due to new browser policies preventing audio to autoplay.
  26261. */
  26262. lock(): void;
  26263. /**
  26264. * Unlocks the audio engine once a user action has been done on the dom.
  26265. * This is helpful to resume play once browser policies have been satisfied.
  26266. */
  26267. unlock(): void;
  26268. private _resumeAudioContext;
  26269. private _initializeAudioContext;
  26270. private _tryToRun;
  26271. private _triggerRunningState;
  26272. private _triggerSuspendedState;
  26273. private _displayMuteButton;
  26274. private _moveButtonToTopLeft;
  26275. private _onResize;
  26276. private _hideMuteButton;
  26277. /**
  26278. * Destroy and release the resources associated with the audio ccontext.
  26279. */
  26280. dispose(): void;
  26281. /**
  26282. * Gets the global volume sets on the master gain.
  26283. * @returns the global volume if set or -1 otherwise
  26284. */
  26285. getGlobalVolume(): number;
  26286. /**
  26287. * Sets the global volume of your experience (sets on the master gain).
  26288. * @param newVolume Defines the new global volume of the application
  26289. */
  26290. setGlobalVolume(newVolume: number): void;
  26291. /**
  26292. * Connect the audio engine to an audio analyser allowing some amazing
  26293. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26295. * @param analyser The analyser to connect to the engine
  26296. */
  26297. connectToAnalyser(analyser: Analyser): void;
  26298. }
  26299. }
  26300. declare module BABYLON {
  26301. /**
  26302. * Interface used to present a loading screen while loading a scene
  26303. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26304. */
  26305. export interface ILoadingScreen {
  26306. /**
  26307. * Function called to display the loading screen
  26308. */
  26309. displayLoadingUI: () => void;
  26310. /**
  26311. * Function called to hide the loading screen
  26312. */
  26313. hideLoadingUI: () => void;
  26314. /**
  26315. * Gets or sets the color to use for the background
  26316. */
  26317. loadingUIBackgroundColor: string;
  26318. /**
  26319. * Gets or sets the text to display while loading
  26320. */
  26321. loadingUIText: string;
  26322. }
  26323. /**
  26324. * Class used for the default loading screen
  26325. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26326. */
  26327. export class DefaultLoadingScreen implements ILoadingScreen {
  26328. private _renderingCanvas;
  26329. private _loadingText;
  26330. private _loadingDivBackgroundColor;
  26331. private _loadingDiv;
  26332. private _loadingTextDiv;
  26333. /**
  26334. * Creates a new default loading screen
  26335. * @param _renderingCanvas defines the canvas used to render the scene
  26336. * @param _loadingText defines the default text to display
  26337. * @param _loadingDivBackgroundColor defines the default background color
  26338. */
  26339. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26340. /**
  26341. * Function called to display the loading screen
  26342. */
  26343. displayLoadingUI(): void;
  26344. /**
  26345. * Function called to hide the loading screen
  26346. */
  26347. hideLoadingUI(): void;
  26348. /**
  26349. * Gets or sets the text to display while loading
  26350. */
  26351. loadingUIText: string;
  26352. /**
  26353. * Gets or sets the color to use for the background
  26354. */
  26355. loadingUIBackgroundColor: string;
  26356. private _resizeLoadingUI;
  26357. }
  26358. }
  26359. declare module BABYLON {
  26360. /** @hidden */
  26361. export class WebGLPipelineContext implements IPipelineContext {
  26362. engine: Engine;
  26363. program: Nullable<WebGLProgram>;
  26364. context?: WebGLRenderingContext;
  26365. vertexShader?: WebGLShader;
  26366. fragmentShader?: WebGLShader;
  26367. isParallelCompiled: boolean;
  26368. onCompiled?: () => void;
  26369. transformFeedback?: WebGLTransformFeedback | null;
  26370. readonly isAsync: boolean;
  26371. readonly isReady: boolean;
  26372. }
  26373. }
  26374. declare module BABYLON {
  26375. /** @hidden */
  26376. export class WebGLDataBuffer extends DataBuffer {
  26377. private _buffer;
  26378. constructor(resource: WebGLBuffer);
  26379. readonly underlyingResource: any;
  26380. }
  26381. }
  26382. declare module BABYLON {
  26383. /**
  26384. * Settings for finer control over video usage
  26385. */
  26386. export interface VideoTextureSettings {
  26387. /**
  26388. * Applies `autoplay` to video, if specified
  26389. */
  26390. autoPlay?: boolean;
  26391. /**
  26392. * Applies `loop` to video, if specified
  26393. */
  26394. loop?: boolean;
  26395. /**
  26396. * Automatically updates internal texture from video at every frame in the render loop
  26397. */
  26398. autoUpdateTexture: boolean;
  26399. /**
  26400. * Image src displayed during the video loading or until the user interacts with the video.
  26401. */
  26402. poster?: string;
  26403. }
  26404. /**
  26405. * If you want to display a video in your scene, this is the special texture for that.
  26406. * This special texture works similar to other textures, with the exception of a few parameters.
  26407. * @see https://doc.babylonjs.com/how_to/video_texture
  26408. */
  26409. export class VideoTexture extends Texture {
  26410. /**
  26411. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26412. */
  26413. readonly autoUpdateTexture: boolean;
  26414. /**
  26415. * The video instance used by the texture internally
  26416. */
  26417. readonly video: HTMLVideoElement;
  26418. private _onUserActionRequestedObservable;
  26419. /**
  26420. * Event triggerd when a dom action is required by the user to play the video.
  26421. * This happens due to recent changes in browser policies preventing video to auto start.
  26422. */
  26423. readonly onUserActionRequestedObservable: Observable<Texture>;
  26424. private _generateMipMaps;
  26425. private _engine;
  26426. private _stillImageCaptured;
  26427. private _displayingPosterTexture;
  26428. private _settings;
  26429. private _createInternalTextureOnEvent;
  26430. /**
  26431. * Creates a video texture.
  26432. * If you want to display a video in your scene, this is the special texture for that.
  26433. * This special texture works similar to other textures, with the exception of a few parameters.
  26434. * @see https://doc.babylonjs.com/how_to/video_texture
  26435. * @param name optional name, will detect from video source, if not defined
  26436. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26437. * @param scene is obviously the current scene.
  26438. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26439. * @param invertY is false by default but can be used to invert video on Y axis
  26440. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26441. * @param settings allows finer control over video usage
  26442. */
  26443. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26444. private _getName;
  26445. private _getVideo;
  26446. private _createInternalTexture;
  26447. private reset;
  26448. /**
  26449. * @hidden Internal method to initiate `update`.
  26450. */ rebuild(): void;
  26451. /**
  26452. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26453. */
  26454. update(): void;
  26455. /**
  26456. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26457. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26458. */
  26459. updateTexture(isVisible: boolean): void;
  26460. protected _updateInternalTexture: () => void;
  26461. /**
  26462. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26463. * @param url New url.
  26464. */
  26465. updateURL(url: string): void;
  26466. /**
  26467. * Dispose the texture and release its associated resources.
  26468. */
  26469. dispose(): void;
  26470. /**
  26471. * Creates a video texture straight from a stream.
  26472. * @param scene Define the scene the texture should be created in
  26473. * @param stream Define the stream the texture should be created from
  26474. * @returns The created video texture as a promise
  26475. */
  26476. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26477. /**
  26478. * Creates a video texture straight from your WebCam video feed.
  26479. * @param scene Define the scene the texture should be created in
  26480. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26481. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26482. * @returns The created video texture as a promise
  26483. */
  26484. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26485. minWidth: number;
  26486. maxWidth: number;
  26487. minHeight: number;
  26488. maxHeight: number;
  26489. deviceId: string;
  26490. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26491. /**
  26492. * Creates a video texture straight from your WebCam video feed.
  26493. * @param scene Define the scene the texture should be created in
  26494. * @param onReady Define a callback to triggered once the texture will be ready
  26495. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26496. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26497. */
  26498. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26499. minWidth: number;
  26500. maxWidth: number;
  26501. minHeight: number;
  26502. maxHeight: number;
  26503. deviceId: string;
  26504. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26505. }
  26506. }
  26507. declare module BABYLON {
  26508. /**
  26509. * Interface for attribute information associated with buffer instanciation
  26510. */
  26511. export class InstancingAttributeInfo {
  26512. /**
  26513. * Index/offset of the attribute in the vertex shader
  26514. */
  26515. index: number;
  26516. /**
  26517. * size of the attribute, 1, 2, 3 or 4
  26518. */
  26519. attributeSize: number;
  26520. /**
  26521. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26522. * default is FLOAT
  26523. */
  26524. attribyteType: number;
  26525. /**
  26526. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26527. */
  26528. normalized: boolean;
  26529. /**
  26530. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26531. */
  26532. offset: number;
  26533. /**
  26534. * Name of the GLSL attribute, for debugging purpose only
  26535. */
  26536. attributeName: string;
  26537. }
  26538. /**
  26539. * Define options used to create a depth texture
  26540. */
  26541. export class DepthTextureCreationOptions {
  26542. /** Specifies whether or not a stencil should be allocated in the texture */
  26543. generateStencil?: boolean;
  26544. /** Specifies whether or not bilinear filtering is enable on the texture */
  26545. bilinearFiltering?: boolean;
  26546. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26547. comparisonFunction?: number;
  26548. /** Specifies if the created texture is a cube texture */
  26549. isCube?: boolean;
  26550. }
  26551. /**
  26552. * Class used to describe the capabilities of the engine relatively to the current browser
  26553. */
  26554. export class EngineCapabilities {
  26555. /** Maximum textures units per fragment shader */
  26556. maxTexturesImageUnits: number;
  26557. /** Maximum texture units per vertex shader */
  26558. maxVertexTextureImageUnits: number;
  26559. /** Maximum textures units in the entire pipeline */
  26560. maxCombinedTexturesImageUnits: number;
  26561. /** Maximum texture size */
  26562. maxTextureSize: number;
  26563. /** Maximum cube texture size */
  26564. maxCubemapTextureSize: number;
  26565. /** Maximum render texture size */
  26566. maxRenderTextureSize: number;
  26567. /** Maximum number of vertex attributes */
  26568. maxVertexAttribs: number;
  26569. /** Maximum number of varyings */
  26570. maxVaryingVectors: number;
  26571. /** Maximum number of uniforms per vertex shader */
  26572. maxVertexUniformVectors: number;
  26573. /** Maximum number of uniforms per fragment shader */
  26574. maxFragmentUniformVectors: number;
  26575. /** Defines if standard derivates (dx/dy) are supported */
  26576. standardDerivatives: boolean;
  26577. /** Defines if s3tc texture compression is supported */
  26578. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26579. /** Defines if pvrtc texture compression is supported */
  26580. pvrtc: any;
  26581. /** Defines if etc1 texture compression is supported */
  26582. etc1: any;
  26583. /** Defines if etc2 texture compression is supported */
  26584. etc2: any;
  26585. /** Defines if astc texture compression is supported */
  26586. astc: any;
  26587. /** Defines if float textures are supported */
  26588. textureFloat: boolean;
  26589. /** Defines if vertex array objects are supported */
  26590. vertexArrayObject: boolean;
  26591. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26592. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26593. /** Gets the maximum level of anisotropy supported */
  26594. maxAnisotropy: number;
  26595. /** Defines if instancing is supported */
  26596. instancedArrays: boolean;
  26597. /** Defines if 32 bits indices are supported */
  26598. uintIndices: boolean;
  26599. /** Defines if high precision shaders are supported */
  26600. highPrecisionShaderSupported: boolean;
  26601. /** Defines if depth reading in the fragment shader is supported */
  26602. fragmentDepthSupported: boolean;
  26603. /** Defines if float texture linear filtering is supported*/
  26604. textureFloatLinearFiltering: boolean;
  26605. /** Defines if rendering to float textures is supported */
  26606. textureFloatRender: boolean;
  26607. /** Defines if half float textures are supported*/
  26608. textureHalfFloat: boolean;
  26609. /** Defines if half float texture linear filtering is supported*/
  26610. textureHalfFloatLinearFiltering: boolean;
  26611. /** Defines if rendering to half float textures is supported */
  26612. textureHalfFloatRender: boolean;
  26613. /** Defines if textureLOD shader command is supported */
  26614. textureLOD: boolean;
  26615. /** Defines if draw buffers extension is supported */
  26616. drawBuffersExtension: boolean;
  26617. /** Defines if depth textures are supported */
  26618. depthTextureExtension: boolean;
  26619. /** Defines if float color buffer are supported */
  26620. colorBufferFloat: boolean;
  26621. /** Gets disjoint timer query extension (null if not supported) */
  26622. timerQuery: EXT_disjoint_timer_query;
  26623. /** Defines if timestamp can be used with timer query */
  26624. canUseTimestampForTimerQuery: boolean;
  26625. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26626. multiview: any;
  26627. /** Function used to let the system compiles shaders in background */
  26628. parallelShaderCompile: {
  26629. COMPLETION_STATUS_KHR: number;
  26630. };
  26631. }
  26632. /** Interface defining initialization parameters for Engine class */
  26633. export interface EngineOptions extends WebGLContextAttributes {
  26634. /**
  26635. * Defines if the engine should no exceed a specified device ratio
  26636. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26637. */
  26638. limitDeviceRatio?: number;
  26639. /**
  26640. * Defines if webvr should be enabled automatically
  26641. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26642. */
  26643. autoEnableWebVR?: boolean;
  26644. /**
  26645. * Defines if webgl2 should be turned off even if supported
  26646. * @see http://doc.babylonjs.com/features/webgl2
  26647. */
  26648. disableWebGL2Support?: boolean;
  26649. /**
  26650. * Defines if webaudio should be initialized as well
  26651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26652. */
  26653. audioEngine?: boolean;
  26654. /**
  26655. * Defines if animations should run using a deterministic lock step
  26656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26657. */
  26658. deterministicLockstep?: boolean;
  26659. /** Defines the maximum steps to use with deterministic lock step mode */
  26660. lockstepMaxSteps?: number;
  26661. /**
  26662. * Defines that engine should ignore context lost events
  26663. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26664. */
  26665. doNotHandleContextLost?: boolean;
  26666. /**
  26667. * Defines that engine should ignore modifying touch action attribute and style
  26668. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26669. */
  26670. doNotHandleTouchAction?: boolean;
  26671. /**
  26672. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26673. */
  26674. useHighPrecisionFloats?: boolean;
  26675. }
  26676. /**
  26677. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26678. */
  26679. export class Engine {
  26680. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26681. static ExceptionList: ({
  26682. key: string;
  26683. capture: string;
  26684. captureConstraint: number;
  26685. targets: string[];
  26686. } | {
  26687. key: string;
  26688. capture: null;
  26689. captureConstraint: null;
  26690. targets: string[];
  26691. })[];
  26692. /** Gets the list of created engines */
  26693. static readonly Instances: Engine[];
  26694. /**
  26695. * Gets the latest created engine
  26696. */
  26697. static readonly LastCreatedEngine: Nullable<Engine>;
  26698. /**
  26699. * Gets the latest created scene
  26700. */
  26701. static readonly LastCreatedScene: Nullable<Scene>;
  26702. /**
  26703. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26704. * @param flag defines which part of the materials must be marked as dirty
  26705. * @param predicate defines a predicate used to filter which materials should be affected
  26706. */
  26707. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26708. /**
  26709. * Hidden
  26710. */ private static _TextureLoaders: IInternalTextureLoader[];
  26711. /** Defines that alpha blending is disabled */
  26712. static readonly ALPHA_DISABLE: number;
  26713. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26714. static readonly ALPHA_ADD: number;
  26715. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26716. static readonly ALPHA_COMBINE: number;
  26717. /** Defines that alpha blending to DEST - SRC * DEST */
  26718. static readonly ALPHA_SUBTRACT: number;
  26719. /** Defines that alpha blending to SRC * DEST */
  26720. static readonly ALPHA_MULTIPLY: number;
  26721. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26722. static readonly ALPHA_MAXIMIZED: number;
  26723. /** Defines that alpha blending to SRC + DEST */
  26724. static readonly ALPHA_ONEONE: number;
  26725. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26726. static readonly ALPHA_PREMULTIPLIED: number;
  26727. /**
  26728. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26729. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26730. */
  26731. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26732. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26733. static readonly ALPHA_INTERPOLATE: number;
  26734. /**
  26735. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26736. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26737. */
  26738. static readonly ALPHA_SCREENMODE: number;
  26739. /** Defines that the ressource is not delayed*/
  26740. static readonly DELAYLOADSTATE_NONE: number;
  26741. /** Defines that the ressource was successfully delay loaded */
  26742. static readonly DELAYLOADSTATE_LOADED: number;
  26743. /** Defines that the ressource is currently delay loading */
  26744. static readonly DELAYLOADSTATE_LOADING: number;
  26745. /** Defines that the ressource is delayed and has not started loading */
  26746. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26747. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26748. static readonly NEVER: number;
  26749. /** 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 */
  26750. static readonly ALWAYS: number;
  26751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26752. static readonly LESS: number;
  26753. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26754. static readonly EQUAL: number;
  26755. /** 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 */
  26756. static readonly LEQUAL: number;
  26757. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26758. static readonly GREATER: number;
  26759. /** 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 */
  26760. static readonly GEQUAL: number;
  26761. /** 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 */
  26762. static readonly NOTEQUAL: number;
  26763. /** Passed to stencilOperation to specify that stencil value must be kept */
  26764. static readonly KEEP: number;
  26765. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26766. static readonly REPLACE: number;
  26767. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26768. static readonly INCR: number;
  26769. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26770. static readonly DECR: number;
  26771. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26772. static readonly INVERT: number;
  26773. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26774. static readonly INCR_WRAP: number;
  26775. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26776. static readonly DECR_WRAP: number;
  26777. /** Texture is not repeating outside of 0..1 UVs */
  26778. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26779. /** Texture is repeating outside of 0..1 UVs */
  26780. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26781. /** Texture is repeating and mirrored */
  26782. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26783. /** ALPHA */
  26784. static readonly TEXTUREFORMAT_ALPHA: number;
  26785. /** LUMINANCE */
  26786. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26787. /** LUMINANCE_ALPHA */
  26788. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26789. /** RGB */
  26790. static readonly TEXTUREFORMAT_RGB: number;
  26791. /** RGBA */
  26792. static readonly TEXTUREFORMAT_RGBA: number;
  26793. /** RED */
  26794. static readonly TEXTUREFORMAT_RED: number;
  26795. /** RED (2nd reference) */
  26796. static readonly TEXTUREFORMAT_R: number;
  26797. /** RG */
  26798. static readonly TEXTUREFORMAT_RG: number;
  26799. /** RED_INTEGER */
  26800. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26801. /** RED_INTEGER (2nd reference) */
  26802. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26803. /** RG_INTEGER */
  26804. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26805. /** RGB_INTEGER */
  26806. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26807. /** RGBA_INTEGER */
  26808. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26809. /** UNSIGNED_BYTE */
  26810. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26811. /** UNSIGNED_BYTE (2nd reference) */
  26812. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26813. /** FLOAT */
  26814. static readonly TEXTURETYPE_FLOAT: number;
  26815. /** HALF_FLOAT */
  26816. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26817. /** BYTE */
  26818. static readonly TEXTURETYPE_BYTE: number;
  26819. /** SHORT */
  26820. static readonly TEXTURETYPE_SHORT: number;
  26821. /** UNSIGNED_SHORT */
  26822. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26823. /** INT */
  26824. static readonly TEXTURETYPE_INT: number;
  26825. /** UNSIGNED_INT */
  26826. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26827. /** UNSIGNED_SHORT_4_4_4_4 */
  26828. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26829. /** UNSIGNED_SHORT_5_5_5_1 */
  26830. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26831. /** UNSIGNED_SHORT_5_6_5 */
  26832. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26833. /** UNSIGNED_INT_2_10_10_10_REV */
  26834. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26835. /** UNSIGNED_INT_24_8 */
  26836. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26837. /** UNSIGNED_INT_10F_11F_11F_REV */
  26838. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26839. /** UNSIGNED_INT_5_9_9_9_REV */
  26840. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26841. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26842. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26843. /** nearest is mag = nearest and min = nearest and mip = linear */
  26844. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26846. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26847. /** Trilinear is mag = linear and min = linear and mip = linear */
  26848. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26849. /** nearest is mag = nearest and min = nearest and mip = linear */
  26850. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26851. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26852. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26853. /** Trilinear is mag = linear and min = linear and mip = linear */
  26854. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26855. /** mag = nearest and min = nearest and mip = nearest */
  26856. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26857. /** mag = nearest and min = linear and mip = nearest */
  26858. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26859. /** mag = nearest and min = linear and mip = linear */
  26860. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26861. /** mag = nearest and min = linear and mip = none */
  26862. static readonly TEXTURE_NEAREST_LINEAR: number;
  26863. /** mag = nearest and min = nearest and mip = none */
  26864. static readonly TEXTURE_NEAREST_NEAREST: number;
  26865. /** mag = linear and min = nearest and mip = nearest */
  26866. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26867. /** mag = linear and min = nearest and mip = linear */
  26868. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26869. /** mag = linear and min = linear and mip = none */
  26870. static readonly TEXTURE_LINEAR_LINEAR: number;
  26871. /** mag = linear and min = nearest and mip = none */
  26872. static readonly TEXTURE_LINEAR_NEAREST: number;
  26873. /** Explicit coordinates mode */
  26874. static readonly TEXTURE_EXPLICIT_MODE: number;
  26875. /** Spherical coordinates mode */
  26876. static readonly TEXTURE_SPHERICAL_MODE: number;
  26877. /** Planar coordinates mode */
  26878. static readonly TEXTURE_PLANAR_MODE: number;
  26879. /** Cubic coordinates mode */
  26880. static readonly TEXTURE_CUBIC_MODE: number;
  26881. /** Projection coordinates mode */
  26882. static readonly TEXTURE_PROJECTION_MODE: number;
  26883. /** Skybox coordinates mode */
  26884. static readonly TEXTURE_SKYBOX_MODE: number;
  26885. /** Inverse Cubic coordinates mode */
  26886. static readonly TEXTURE_INVCUBIC_MODE: number;
  26887. /** Equirectangular coordinates mode */
  26888. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26889. /** Equirectangular Fixed coordinates mode */
  26890. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26891. /** Equirectangular Fixed Mirrored coordinates mode */
  26892. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26893. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26894. static readonly SCALEMODE_FLOOR: number;
  26895. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26896. static readonly SCALEMODE_NEAREST: number;
  26897. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26898. static readonly SCALEMODE_CEILING: number;
  26899. /**
  26900. * Returns the current npm package of the sdk
  26901. */
  26902. static readonly NpmPackage: string;
  26903. /**
  26904. * Returns the current version of the framework
  26905. */
  26906. static readonly Version: string;
  26907. /**
  26908. * Returns a string describing the current engine
  26909. */
  26910. readonly description: string;
  26911. /**
  26912. * Gets or sets the epsilon value used by collision engine
  26913. */
  26914. static CollisionsEpsilon: number;
  26915. /**
  26916. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26917. */
  26918. static ShadersRepository: string;
  26919. /**
  26920. * Method called to create the default loading screen.
  26921. * This can be overriden in your own app.
  26922. * @param canvas The rendering canvas element
  26923. * @returns The loading screen
  26924. */
  26925. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26926. /**
  26927. * Method called to create the default rescale post process on each engine.
  26928. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26929. /**
  26930. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26931. */
  26932. forcePOTTextures: boolean;
  26933. /**
  26934. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26935. */
  26936. isFullscreen: boolean;
  26937. /**
  26938. * Gets a boolean indicating if the pointer is currently locked
  26939. */
  26940. isPointerLock: boolean;
  26941. /**
  26942. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26943. */
  26944. cullBackFaces: boolean;
  26945. /**
  26946. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26947. */
  26948. renderEvenInBackground: boolean;
  26949. /**
  26950. * Gets or sets a boolean indicating that cache can be kept between frames
  26951. */
  26952. preventCacheWipeBetweenFrames: boolean;
  26953. /**
  26954. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26955. **/
  26956. enableOfflineSupport: boolean;
  26957. /**
  26958. * 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)
  26959. **/
  26960. disableManifestCheck: boolean;
  26961. /**
  26962. * Gets the list of created scenes
  26963. */
  26964. scenes: Scene[];
  26965. /**
  26966. * Event raised when a new scene is created
  26967. */
  26968. onNewSceneAddedObservable: Observable<Scene>;
  26969. /**
  26970. * Gets the list of created postprocesses
  26971. */
  26972. postProcesses: PostProcess[];
  26973. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26974. validateShaderPrograms: boolean;
  26975. /**
  26976. * Observable event triggered each time the rendering canvas is resized
  26977. */
  26978. onResizeObservable: Observable<Engine>;
  26979. /**
  26980. * Observable event triggered each time the canvas loses focus
  26981. */
  26982. onCanvasBlurObservable: Observable<Engine>;
  26983. /**
  26984. * Observable event triggered each time the canvas gains focus
  26985. */
  26986. onCanvasFocusObservable: Observable<Engine>;
  26987. /**
  26988. * Observable event triggered each time the canvas receives pointerout event
  26989. */
  26990. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26991. /**
  26992. * Observable event triggered before each texture is initialized
  26993. */
  26994. onBeforeTextureInitObservable: Observable<Texture>;
  26995. /**
  26996. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26997. */
  26998. disableUniformBuffers: boolean;
  26999. /** @hidden */ uniformBuffers: UniformBuffer[];
  27000. /**
  27001. * Gets a boolean indicating that the engine supports uniform buffers
  27002. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27003. */
  27004. readonly supportsUniformBuffers: boolean;
  27005. /**
  27006. * Observable raised when the engine begins a new frame
  27007. */
  27008. onBeginFrameObservable: Observable<Engine>;
  27009. /**
  27010. * If set, will be used to request the next animation frame for the render loop
  27011. */
  27012. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27013. /**
  27014. * Observable raised when the engine ends the current frame
  27015. */
  27016. onEndFrameObservable: Observable<Engine>;
  27017. /**
  27018. * Observable raised when the engine is about to compile a shader
  27019. */
  27020. onBeforeShaderCompilationObservable: Observable<Engine>;
  27021. /**
  27022. * Observable raised when the engine has jsut compiled a shader
  27023. */
  27024. onAfterShaderCompilationObservable: Observable<Engine>;
  27025. /** @hidden */ gl: WebGLRenderingContext;
  27026. private _renderingCanvas;
  27027. private _windowIsBackground;
  27028. private _webGLVersion;
  27029. protected _highPrecisionShadersAllowed: boolean;
  27030. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27031. /**
  27032. * Gets a boolean indicating that only power of 2 textures are supported
  27033. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27034. */
  27035. readonly needPOTTextures: boolean;
  27036. /** @hidden */ badOS: boolean;
  27037. /** @hidden */ badDesktopOS: boolean;
  27038. /**
  27039. * Gets the audio engine
  27040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27041. * @ignorenaming
  27042. */
  27043. static audioEngine: IAudioEngine;
  27044. /**
  27045. * Default AudioEngine factory responsible of creating the Audio Engine.
  27046. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27047. */
  27048. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27049. /**
  27050. * Default offline support factory responsible of creating a tool used to store data locally.
  27051. * By default, this will create a Database object if the workload has been embedded.
  27052. */
  27053. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27054. private _onFocus;
  27055. private _onBlur;
  27056. private _onCanvasPointerOut;
  27057. private _onCanvasBlur;
  27058. private _onCanvasFocus;
  27059. private _onFullscreenChange;
  27060. private _onPointerLockChange;
  27061. private _hardwareScalingLevel;
  27062. /** @hidden */ caps: EngineCapabilities;
  27063. private _pointerLockRequested;
  27064. private _isStencilEnable;
  27065. private _colorWrite;
  27066. private _loadingScreen;
  27067. /** @hidden */ drawCalls: PerfCounter;
  27068. private _glVersion;
  27069. private _glRenderer;
  27070. private _glVendor;
  27071. private _videoTextureSupported;
  27072. private _renderingQueueLaunched;
  27073. private _activeRenderLoops;
  27074. private _deterministicLockstep;
  27075. private _lockstepMaxSteps;
  27076. /**
  27077. * Observable signaled when a context lost event is raised
  27078. */
  27079. onContextLostObservable: Observable<Engine>;
  27080. /**
  27081. * Observable signaled when a context restored event is raised
  27082. */
  27083. onContextRestoredObservable: Observable<Engine>;
  27084. private _onContextLost;
  27085. private _onContextRestored;
  27086. private _contextWasLost;
  27087. /** @hidden */ doNotHandleContextLost: boolean;
  27088. /**
  27089. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27091. */
  27092. doNotHandleContextLost: boolean;
  27093. private _performanceMonitor;
  27094. private _fps;
  27095. private _deltaTime;
  27096. /**
  27097. * Turn this value on if you want to pause FPS computation when in background
  27098. */
  27099. disablePerformanceMonitorInBackground: boolean;
  27100. /**
  27101. * Gets the performance monitor attached to this engine
  27102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27103. */
  27104. readonly performanceMonitor: PerformanceMonitor;
  27105. /**
  27106. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27107. */
  27108. disableVertexArrayObjects: boolean;
  27109. /** @hidden */
  27110. protected _depthCullingState: _DepthCullingState;
  27111. /** @hidden */
  27112. protected _stencilState: _StencilState;
  27113. /** @hidden */
  27114. protected _alphaState: _AlphaState;
  27115. /** @hidden */
  27116. protected _alphaMode: number;
  27117. /** @hidden */ internalTexturesCache: InternalTexture[];
  27118. /** @hidden */
  27119. protected _activeChannel: number;
  27120. private _currentTextureChannel;
  27121. /** @hidden */
  27122. protected _boundTexturesCache: {
  27123. [key: string]: Nullable<InternalTexture>;
  27124. };
  27125. /** @hidden */
  27126. protected _currentEffect: Nullable<Effect>;
  27127. /** @hidden */
  27128. protected _currentProgram: Nullable<WebGLProgram>;
  27129. private _compiledEffects;
  27130. private _vertexAttribArraysEnabled;
  27131. /** @hidden */
  27132. protected _cachedViewport: Nullable<Viewport>;
  27133. private _cachedVertexArrayObject;
  27134. /** @hidden */
  27135. protected _cachedVertexBuffers: any;
  27136. /** @hidden */
  27137. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27138. /** @hidden */
  27139. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27140. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27141. private _uintIndicesCurrentlySet;
  27142. private _currentBoundBuffer;
  27143. /** @hidden */
  27144. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27145. private _currentBufferPointers;
  27146. private _currentInstanceLocations;
  27147. private _currentInstanceBuffers;
  27148. private _textureUnits;
  27149. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27150. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27151. private _rescalePostProcess;
  27152. private _dummyFramebuffer;
  27153. private _externalData;
  27154. /** @hidden */ bindedRenderFunction: any;
  27155. private _vaoRecordInProgress;
  27156. private _mustWipeVertexAttributes;
  27157. private _emptyTexture;
  27158. private _emptyCubeTexture;
  27159. private _emptyTexture3D;
  27160. /** @hidden */ frameHandler: number;
  27161. private _nextFreeTextureSlots;
  27162. private _maxSimultaneousTextures;
  27163. private _activeRequests;
  27164. private _texturesSupported;
  27165. /** @hidden */ textureFormatInUse: Nullable<string>;
  27166. /**
  27167. * Gets the list of texture formats supported
  27168. */
  27169. readonly texturesSupported: Array<string>;
  27170. /**
  27171. * Gets the list of texture formats in use
  27172. */
  27173. readonly textureFormatInUse: Nullable<string>;
  27174. /**
  27175. * Gets the current viewport
  27176. */
  27177. readonly currentViewport: Nullable<Viewport>;
  27178. /**
  27179. * Gets the default empty texture
  27180. */
  27181. readonly emptyTexture: InternalTexture;
  27182. /**
  27183. * Gets the default empty 3D texture
  27184. */
  27185. readonly emptyTexture3D: InternalTexture;
  27186. /**
  27187. * Gets the default empty cube texture
  27188. */
  27189. readonly emptyCubeTexture: InternalTexture;
  27190. /**
  27191. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27192. */
  27193. readonly premultipliedAlpha: boolean;
  27194. /**
  27195. * Creates a new engine
  27196. * @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
  27197. * @param antialias defines enable antialiasing (default: false)
  27198. * @param options defines further options to be sent to the getContext() function
  27199. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27200. */
  27201. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27202. /**
  27203. * Initializes a webVR display and starts listening to display change events
  27204. * The onVRDisplayChangedObservable will be notified upon these changes
  27205. * @returns The onVRDisplayChangedObservable
  27206. */
  27207. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27208. /** @hidden */ prepareVRComponent(): void;
  27209. /** @hidden */ connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27210. /** @hidden */ submitVRFrame(): void;
  27211. /**
  27212. * Call this function to leave webVR mode
  27213. * Will do nothing if webVR is not supported or if there is no webVR device
  27214. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27215. */
  27216. disableVR(): void;
  27217. /**
  27218. * Gets a boolean indicating that the system is in VR mode and is presenting
  27219. * @returns true if VR mode is engaged
  27220. */
  27221. isVRPresenting(): boolean;
  27222. /** @hidden */ requestVRFrame(): void;
  27223. private _disableTouchAction;
  27224. private _rebuildInternalTextures;
  27225. private _rebuildEffects;
  27226. /**
  27227. * Gets a boolean indicating if all created effects are ready
  27228. * @returns true if all effects are ready
  27229. */
  27230. areAllEffectsReady(): boolean;
  27231. private _rebuildBuffers;
  27232. private _initGLContext;
  27233. /**
  27234. * Gets version of the current webGL context
  27235. */
  27236. readonly webGLVersion: number;
  27237. /**
  27238. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27239. */
  27240. readonly isStencilEnable: boolean;
  27241. /** @hidden */ prepareWorkingCanvas(): void;
  27242. /**
  27243. * Reset the texture cache to empty state
  27244. */
  27245. resetTextureCache(): void;
  27246. /**
  27247. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27249. * @returns true if engine is in deterministic lock step mode
  27250. */
  27251. isDeterministicLockStep(): boolean;
  27252. /**
  27253. * Gets the max steps when engine is running in deterministic lock step
  27254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27255. * @returns the max steps
  27256. */
  27257. getLockstepMaxSteps(): number;
  27258. /**
  27259. * Gets an object containing information about the current webGL context
  27260. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27261. */
  27262. getGlInfo(): {
  27263. vendor: string;
  27264. renderer: string;
  27265. version: string;
  27266. };
  27267. /**
  27268. * Gets current aspect ratio
  27269. * @param camera defines the camera to use to get the aspect ratio
  27270. * @param useScreen defines if screen size must be used (or the current render target if any)
  27271. * @returns a number defining the aspect ratio
  27272. */
  27273. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27274. /**
  27275. * Gets current screen aspect ratio
  27276. * @returns a number defining the aspect ratio
  27277. */
  27278. getScreenAspectRatio(): number;
  27279. /**
  27280. * Gets the current render width
  27281. * @param useScreen defines if screen size must be used (or the current render target if any)
  27282. * @returns a number defining the current render width
  27283. */
  27284. getRenderWidth(useScreen?: boolean): number;
  27285. /**
  27286. * Gets the current render height
  27287. * @param useScreen defines if screen size must be used (or the current render target if any)
  27288. * @returns a number defining the current render height
  27289. */
  27290. getRenderHeight(useScreen?: boolean): number;
  27291. /**
  27292. * Gets the HTML canvas attached with the current webGL context
  27293. * @returns a HTML canvas
  27294. */
  27295. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27296. /**
  27297. * Gets the client rect of the HTML canvas attached with the current webGL context
  27298. * @returns a client rectanglee
  27299. */
  27300. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27301. /**
  27302. * Defines the hardware scaling level.
  27303. * By default the hardware scaling level is computed from the window device ratio.
  27304. * 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.
  27305. * @param level defines the level to use
  27306. */
  27307. setHardwareScalingLevel(level: number): void;
  27308. /**
  27309. * Gets the current hardware scaling level.
  27310. * By default the hardware scaling level is computed from the window device ratio.
  27311. * 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.
  27312. * @returns a number indicating the current hardware scaling level
  27313. */
  27314. getHardwareScalingLevel(): number;
  27315. /**
  27316. * Gets the list of loaded textures
  27317. * @returns an array containing all loaded textures
  27318. */
  27319. getLoadedTexturesCache(): InternalTexture[];
  27320. /**
  27321. * Gets the object containing all engine capabilities
  27322. * @returns the EngineCapabilities object
  27323. */
  27324. getCaps(): EngineCapabilities;
  27325. /**
  27326. * Gets the current depth function
  27327. * @returns a number defining the depth function
  27328. */
  27329. getDepthFunction(): Nullable<number>;
  27330. /**
  27331. * Sets the current depth function
  27332. * @param depthFunc defines the function to use
  27333. */
  27334. setDepthFunction(depthFunc: number): void;
  27335. /**
  27336. * Sets the current depth function to GREATER
  27337. */
  27338. setDepthFunctionToGreater(): void;
  27339. /**
  27340. * Sets the current depth function to GEQUAL
  27341. */
  27342. setDepthFunctionToGreaterOrEqual(): void;
  27343. /**
  27344. * Sets the current depth function to LESS
  27345. */
  27346. setDepthFunctionToLess(): void;
  27347. private _cachedStencilBuffer;
  27348. private _cachedStencilFunction;
  27349. private _cachedStencilMask;
  27350. private _cachedStencilOperationPass;
  27351. private _cachedStencilOperationFail;
  27352. private _cachedStencilOperationDepthFail;
  27353. private _cachedStencilReference;
  27354. /**
  27355. * Caches the the state of the stencil buffer
  27356. */
  27357. cacheStencilState(): void;
  27358. /**
  27359. * Restores the state of the stencil buffer
  27360. */
  27361. restoreStencilState(): void;
  27362. /**
  27363. * Sets the current depth function to LEQUAL
  27364. */
  27365. setDepthFunctionToLessOrEqual(): void;
  27366. /**
  27367. * Gets a boolean indicating if stencil buffer is enabled
  27368. * @returns the current stencil buffer state
  27369. */
  27370. getStencilBuffer(): boolean;
  27371. /**
  27372. * Enable or disable the stencil buffer
  27373. * @param enable defines if the stencil buffer must be enabled or disabled
  27374. */
  27375. setStencilBuffer(enable: boolean): void;
  27376. /**
  27377. * Gets the current stencil mask
  27378. * @returns a number defining the new stencil mask to use
  27379. */
  27380. getStencilMask(): number;
  27381. /**
  27382. * Sets the current stencil mask
  27383. * @param mask defines the new stencil mask to use
  27384. */
  27385. setStencilMask(mask: number): void;
  27386. /**
  27387. * Gets the current stencil function
  27388. * @returns a number defining the stencil function to use
  27389. */
  27390. getStencilFunction(): number;
  27391. /**
  27392. * Gets the current stencil reference value
  27393. * @returns a number defining the stencil reference value to use
  27394. */
  27395. getStencilFunctionReference(): number;
  27396. /**
  27397. * Gets the current stencil mask
  27398. * @returns a number defining the stencil mask to use
  27399. */
  27400. getStencilFunctionMask(): number;
  27401. /**
  27402. * Sets the current stencil function
  27403. * @param stencilFunc defines the new stencil function to use
  27404. */
  27405. setStencilFunction(stencilFunc: number): void;
  27406. /**
  27407. * Sets the current stencil reference
  27408. * @param reference defines the new stencil reference to use
  27409. */
  27410. setStencilFunctionReference(reference: number): void;
  27411. /**
  27412. * Sets the current stencil mask
  27413. * @param mask defines the new stencil mask to use
  27414. */
  27415. setStencilFunctionMask(mask: number): void;
  27416. /**
  27417. * Gets the current stencil operation when stencil fails
  27418. * @returns a number defining stencil operation to use when stencil fails
  27419. */
  27420. getStencilOperationFail(): number;
  27421. /**
  27422. * Gets the current stencil operation when depth fails
  27423. * @returns a number defining stencil operation to use when depth fails
  27424. */
  27425. getStencilOperationDepthFail(): number;
  27426. /**
  27427. * Gets the current stencil operation when stencil passes
  27428. * @returns a number defining stencil operation to use when stencil passes
  27429. */
  27430. getStencilOperationPass(): number;
  27431. /**
  27432. * Sets the stencil operation to use when stencil fails
  27433. * @param operation defines the stencil operation to use when stencil fails
  27434. */
  27435. setStencilOperationFail(operation: number): void;
  27436. /**
  27437. * Sets the stencil operation to use when depth fails
  27438. * @param operation defines the stencil operation to use when depth fails
  27439. */
  27440. setStencilOperationDepthFail(operation: number): void;
  27441. /**
  27442. * Sets the stencil operation to use when stencil passes
  27443. * @param operation defines the stencil operation to use when stencil passes
  27444. */
  27445. setStencilOperationPass(operation: number): void;
  27446. /**
  27447. * Sets a boolean indicating if the dithering state is enabled or disabled
  27448. * @param value defines the dithering state
  27449. */
  27450. setDitheringState(value: boolean): void;
  27451. /**
  27452. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27453. * @param value defines the rasterizer state
  27454. */
  27455. setRasterizerState(value: boolean): void;
  27456. /**
  27457. * stop executing a render loop function and remove it from the execution array
  27458. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27459. */
  27460. stopRenderLoop(renderFunction?: () => void): void;
  27461. /** @hidden */ renderLoop(): void;
  27462. /**
  27463. * Register and execute a render loop. The engine can have more than one render function
  27464. * @param renderFunction defines the function to continuously execute
  27465. */
  27466. runRenderLoop(renderFunction: () => void): void;
  27467. /**
  27468. * Toggle full screen mode
  27469. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27470. */
  27471. switchFullscreen(requestPointerLock: boolean): void;
  27472. /**
  27473. * Enters full screen mode
  27474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27475. */
  27476. enterFullscreen(requestPointerLock: boolean): void;
  27477. /**
  27478. * Exits full screen mode
  27479. */
  27480. exitFullscreen(): void;
  27481. /**
  27482. * Clear the current render buffer or the current render target (if any is set up)
  27483. * @param color defines the color to use
  27484. * @param backBuffer defines if the back buffer must be cleared
  27485. * @param depth defines if the depth buffer must be cleared
  27486. * @param stencil defines if the stencil buffer must be cleared
  27487. */
  27488. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27489. /**
  27490. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27491. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27492. * @param y defines the y-coordinate of the corner of the clear rectangle
  27493. * @param width defines the width of the clear rectangle
  27494. * @param height defines the height of the clear rectangle
  27495. * @param clearColor defines the clear color
  27496. */
  27497. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27498. /**
  27499. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27500. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27501. * @param y defines the y-coordinate of the corner of the clear rectangle
  27502. * @param width defines the width of the clear rectangle
  27503. * @param height defines the height of the clear rectangle
  27504. */
  27505. enableScissor(x: number, y: number, width: number, height: number): void;
  27506. /**
  27507. * Disable previously set scissor test rectangle
  27508. */
  27509. disableScissor(): void;
  27510. private _viewportCached;
  27511. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27512. /**
  27513. * Set the WebGL's viewport
  27514. * @param viewport defines the viewport element to be used
  27515. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27516. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27517. */
  27518. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27519. /**
  27520. * Directly set the WebGL Viewport
  27521. * @param x defines the x coordinate of the viewport (in screen space)
  27522. * @param y defines the y coordinate of the viewport (in screen space)
  27523. * @param width defines the width of the viewport (in screen space)
  27524. * @param height defines the height of the viewport (in screen space)
  27525. * @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
  27526. */
  27527. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27528. /**
  27529. * Begin a new frame
  27530. */
  27531. beginFrame(): void;
  27532. /**
  27533. * Enf the current frame
  27534. */
  27535. endFrame(): void;
  27536. /**
  27537. * Resize the view according to the canvas' size
  27538. */
  27539. resize(): void;
  27540. /**
  27541. * Force a specific size of the canvas
  27542. * @param width defines the new canvas' width
  27543. * @param height defines the new canvas' height
  27544. */
  27545. setSize(width: number, height: number): void;
  27546. /**
  27547. * Binds the frame buffer to the specified texture.
  27548. * @param texture The texture to render to or null for the default canvas
  27549. * @param faceIndex The face of the texture to render to in case of cube texture
  27550. * @param requiredWidth The width of the target to render to
  27551. * @param requiredHeight The height of the target to render to
  27552. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27553. * @param depthStencilTexture The depth stencil texture to use to render
  27554. * @param lodLevel defines le lod level to bind to the frame buffer
  27555. */
  27556. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27557. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27558. /**
  27559. * Unbind the current render target texture from the webGL context
  27560. * @param texture defines the render target texture to unbind
  27561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27563. */
  27564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27565. /**
  27566. * Force the mipmap generation for the given render target texture
  27567. * @param texture defines the render target texture to use
  27568. */
  27569. generateMipMapsForCubemap(texture: InternalTexture): void;
  27570. /**
  27571. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27572. */
  27573. flushFramebuffer(): void;
  27574. /**
  27575. * Unbind the current render target and bind the default framebuffer
  27576. */
  27577. restoreDefaultFramebuffer(): void;
  27578. /**
  27579. * Create an uniform buffer
  27580. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27581. * @param elements defines the content of the uniform buffer
  27582. * @returns the webGL uniform buffer
  27583. */
  27584. createUniformBuffer(elements: FloatArray): DataBuffer;
  27585. /**
  27586. * Create a dynamic uniform buffer
  27587. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27588. * @param elements defines the content of the uniform buffer
  27589. * @returns the webGL uniform buffer
  27590. */
  27591. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27592. /**
  27593. * Update an existing uniform buffer
  27594. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27595. * @param uniformBuffer defines the target uniform buffer
  27596. * @param elements defines the content to update
  27597. * @param offset defines the offset in the uniform buffer where update should start
  27598. * @param count defines the size of the data to update
  27599. */
  27600. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27601. private _resetVertexBufferBinding;
  27602. /**
  27603. * Creates a vertex buffer
  27604. * @param data the data for the vertex buffer
  27605. * @returns the new WebGL static buffer
  27606. */
  27607. createVertexBuffer(data: DataArray): DataBuffer;
  27608. /**
  27609. * Creates a dynamic vertex buffer
  27610. * @param data the data for the dynamic vertex buffer
  27611. * @returns the new WebGL dynamic buffer
  27612. */
  27613. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27614. /**
  27615. * Update a dynamic index buffer
  27616. * @param indexBuffer defines the target index buffer
  27617. * @param indices defines the data to update
  27618. * @param offset defines the offset in the target index buffer where update should start
  27619. */
  27620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27621. /**
  27622. * Updates a dynamic vertex buffer.
  27623. * @param vertexBuffer the vertex buffer to update
  27624. * @param data the data used to update the vertex buffer
  27625. * @param byteOffset the byte offset of the data
  27626. * @param byteLength the byte length of the data
  27627. */
  27628. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27629. private _resetIndexBufferBinding;
  27630. /**
  27631. * Creates a new index buffer
  27632. * @param indices defines the content of the index buffer
  27633. * @param updatable defines if the index buffer must be updatable
  27634. * @returns a new webGL buffer
  27635. */
  27636. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27637. /**
  27638. * Bind a webGL buffer to the webGL context
  27639. * @param buffer defines the buffer to bind
  27640. */
  27641. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27642. /**
  27643. * Bind an uniform buffer to the current webGL context
  27644. * @param buffer defines the buffer to bind
  27645. */
  27646. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27647. /**
  27648. * Bind a buffer to the current webGL context at a given location
  27649. * @param buffer defines the buffer to bind
  27650. * @param location defines the index where to bind the buffer
  27651. */
  27652. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27653. /**
  27654. * Bind a specific block at a given index in a specific shader program
  27655. * @param pipelineContext defines the pipeline context to use
  27656. * @param blockName defines the block name
  27657. * @param index defines the index where to bind the block
  27658. */
  27659. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27660. private bindIndexBuffer;
  27661. private bindBuffer;
  27662. /**
  27663. * update the bound buffer with the given data
  27664. * @param data defines the data to update
  27665. */
  27666. updateArrayBuffer(data: Float32Array): void;
  27667. private _vertexAttribPointer;
  27668. private _bindIndexBufferWithCache;
  27669. private _bindVertexBuffersAttributes;
  27670. /**
  27671. * Records a vertex array object
  27672. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27673. * @param vertexBuffers defines the list of vertex buffers to store
  27674. * @param indexBuffer defines the index buffer to store
  27675. * @param effect defines the effect to store
  27676. * @returns the new vertex array object
  27677. */
  27678. recordVertexArrayObject(vertexBuffers: {
  27679. [key: string]: VertexBuffer;
  27680. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27681. /**
  27682. * Bind a specific vertex array object
  27683. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27684. * @param vertexArrayObject defines the vertex array object to bind
  27685. * @param indexBuffer defines the index buffer to bind
  27686. */
  27687. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27688. /**
  27689. * Bind webGl buffers directly to the webGL context
  27690. * @param vertexBuffer defines the vertex buffer to bind
  27691. * @param indexBuffer defines the index buffer to bind
  27692. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27693. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27694. * @param effect defines the effect associated with the vertex buffer
  27695. */
  27696. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27697. private _unbindVertexArrayObject;
  27698. /**
  27699. * Bind a list of vertex buffers to the webGL context
  27700. * @param vertexBuffers defines the list of vertex buffers to bind
  27701. * @param indexBuffer defines the index buffer to bind
  27702. * @param effect defines the effect associated with the vertex buffers
  27703. */
  27704. bindBuffers(vertexBuffers: {
  27705. [key: string]: Nullable<VertexBuffer>;
  27706. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27707. /**
  27708. * Unbind all instance attributes
  27709. */
  27710. unbindInstanceAttributes(): void;
  27711. /**
  27712. * Release and free the memory of a vertex array object
  27713. * @param vao defines the vertex array object to delete
  27714. */
  27715. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27716. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27717. /**
  27718. * Creates a webGL buffer to use with instanciation
  27719. * @param capacity defines the size of the buffer
  27720. * @returns the webGL buffer
  27721. */
  27722. createInstancesBuffer(capacity: number): DataBuffer;
  27723. /**
  27724. * Delete a webGL buffer used with instanciation
  27725. * @param buffer defines the webGL buffer to delete
  27726. */
  27727. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27728. /**
  27729. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27730. * @param instancesBuffer defines the webGL buffer to update and bind
  27731. * @param data defines the data to store in the buffer
  27732. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27733. */
  27734. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27735. /**
  27736. * Apply all cached states (depth, culling, stencil and alpha)
  27737. */
  27738. applyStates(): void;
  27739. /**
  27740. * Send a draw order
  27741. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27742. * @param indexStart defines the starting index
  27743. * @param indexCount defines the number of index to draw
  27744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27745. */
  27746. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27747. /**
  27748. * Draw a list of points
  27749. * @param verticesStart defines the index of first vertex to draw
  27750. * @param verticesCount defines the count of vertices to draw
  27751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27752. */
  27753. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27754. /**
  27755. * Draw a list of unindexed primitives
  27756. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27757. * @param verticesStart defines the index of first vertex to draw
  27758. * @param verticesCount defines the count of vertices to draw
  27759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27760. */
  27761. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27762. /**
  27763. * Draw a list of indexed primitives
  27764. * @param fillMode defines the primitive to use
  27765. * @param indexStart defines the starting index
  27766. * @param indexCount defines the number of index to draw
  27767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27768. */
  27769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27770. /**
  27771. * Draw a list of unindexed primitives
  27772. * @param fillMode defines the primitive to use
  27773. * @param verticesStart defines the index of first vertex to draw
  27774. * @param verticesCount defines the count of vertices to draw
  27775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27776. */
  27777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27778. private _drawMode;
  27779. /** @hidden */ releaseEffect(effect: Effect): void;
  27780. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27781. /**
  27782. * Create a new effect (used to store vertex/fragment shaders)
  27783. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27784. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27785. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27786. * @param samplers defines an array of string used to represent textures
  27787. * @param defines defines the string containing the defines to use to compile the shaders
  27788. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27789. * @param onCompiled defines a function to call when the effect creation is successful
  27790. * @param onError defines a function to call when the effect creation has failed
  27791. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27792. * @returns the new Effect
  27793. */
  27794. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  27795. private _compileShader;
  27796. private _compileRawShader;
  27797. /**
  27798. * Directly creates a webGL program
  27799. * @param pipelineContext defines the pipeline context to attach to
  27800. * @param vertexCode defines the vertex shader code to use
  27801. * @param fragmentCode defines the fragment shader code to use
  27802. * @param context defines the webGL context to use (if not set, the current one will be used)
  27803. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27804. * @returns the new webGL program
  27805. */
  27806. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27807. /**
  27808. * Creates a webGL program
  27809. * @param pipelineContext defines the pipeline context to attach to
  27810. * @param vertexCode defines the vertex shader code to use
  27811. * @param fragmentCode defines the fragment shader code to use
  27812. * @param defines defines the string containing the defines to use to compile the shaders
  27813. * @param context defines the webGL context to use (if not set, the current one will be used)
  27814. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27815. * @returns the new webGL program
  27816. */
  27817. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27818. /**
  27819. * Creates a new pipeline context
  27820. * @returns the new pipeline
  27821. */
  27822. createPipelineContext(): WebGLPipelineContext;
  27823. private _createShaderProgram;
  27824. private _finalizePipelineContext;
  27825. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27826. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27827. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27828. /**
  27829. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27830. * @param pipelineContext defines the pipeline context to use
  27831. * @param uniformsNames defines the list of uniform names
  27832. * @returns an array of webGL uniform locations
  27833. */
  27834. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27835. /**
  27836. * Gets the lsit of active attributes for a given webGL program
  27837. * @param pipelineContext defines the pipeline context to use
  27838. * @param attributesNames defines the list of attribute names to get
  27839. * @returns an array of indices indicating the offset of each attribute
  27840. */
  27841. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27842. /**
  27843. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27844. * @param effect defines the effect to activate
  27845. */
  27846. enableEffect(effect: Nullable<Effect>): void;
  27847. /**
  27848. * Set the value of an uniform to an array of int32
  27849. * @param uniform defines the webGL uniform location where to store the value
  27850. * @param array defines the array of int32 to store
  27851. */
  27852. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27853. /**
  27854. * Set the value of an uniform to an array of int32 (stored as vec2)
  27855. * @param uniform defines the webGL uniform location where to store the value
  27856. * @param array defines the array of int32 to store
  27857. */
  27858. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27859. /**
  27860. * Set the value of an uniform to an array of int32 (stored as vec3)
  27861. * @param uniform defines the webGL uniform location where to store the value
  27862. * @param array defines the array of int32 to store
  27863. */
  27864. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27865. /**
  27866. * Set the value of an uniform to an array of int32 (stored as vec4)
  27867. * @param uniform defines the webGL uniform location where to store the value
  27868. * @param array defines the array of int32 to store
  27869. */
  27870. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27871. /**
  27872. * Set the value of an uniform to an array of float32
  27873. * @param uniform defines the webGL uniform location where to store the value
  27874. * @param array defines the array of float32 to store
  27875. */
  27876. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27877. /**
  27878. * Set the value of an uniform to an array of float32 (stored as vec2)
  27879. * @param uniform defines the webGL uniform location where to store the value
  27880. * @param array defines the array of float32 to store
  27881. */
  27882. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27883. /**
  27884. * Set the value of an uniform to an array of float32 (stored as vec3)
  27885. * @param uniform defines the webGL uniform location where to store the value
  27886. * @param array defines the array of float32 to store
  27887. */
  27888. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27889. /**
  27890. * Set the value of an uniform to an array of float32 (stored as vec4)
  27891. * @param uniform defines the webGL uniform location where to store the value
  27892. * @param array defines the array of float32 to store
  27893. */
  27894. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27895. /**
  27896. * Set the value of an uniform to an array of number
  27897. * @param uniform defines the webGL uniform location where to store the value
  27898. * @param array defines the array of number to store
  27899. */
  27900. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27901. /**
  27902. * Set the value of an uniform to an array of number (stored as vec2)
  27903. * @param uniform defines the webGL uniform location where to store the value
  27904. * @param array defines the array of number to store
  27905. */
  27906. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27907. /**
  27908. * Set the value of an uniform to an array of number (stored as vec3)
  27909. * @param uniform defines the webGL uniform location where to store the value
  27910. * @param array defines the array of number to store
  27911. */
  27912. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27913. /**
  27914. * Set the value of an uniform to an array of number (stored as vec4)
  27915. * @param uniform defines the webGL uniform location where to store the value
  27916. * @param array defines the array of number to store
  27917. */
  27918. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27919. /**
  27920. * Set the value of an uniform to an array of float32 (stored as matrices)
  27921. * @param uniform defines the webGL uniform location where to store the value
  27922. * @param matrices defines the array of float32 to store
  27923. */
  27924. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27925. /**
  27926. * Set the value of an uniform to a matrix
  27927. * @param uniform defines the webGL uniform location where to store the value
  27928. * @param matrix defines the matrix to store
  27929. */
  27930. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27931. /**
  27932. * Set the value of an uniform to a matrix (3x3)
  27933. * @param uniform defines the webGL uniform location where to store the value
  27934. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27935. */
  27936. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27937. /**
  27938. * Set the value of an uniform to a matrix (2x2)
  27939. * @param uniform defines the webGL uniform location where to store the value
  27940. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27941. */
  27942. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27943. /**
  27944. * Set the value of an uniform to a number (int)
  27945. * @param uniform defines the webGL uniform location where to store the value
  27946. * @param value defines the int number to store
  27947. */
  27948. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27949. /**
  27950. * Set the value of an uniform to a number (float)
  27951. * @param uniform defines the webGL uniform location where to store the value
  27952. * @param value defines the float number to store
  27953. */
  27954. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27955. /**
  27956. * Set the value of an uniform to a vec2
  27957. * @param uniform defines the webGL uniform location where to store the value
  27958. * @param x defines the 1st component of the value
  27959. * @param y defines the 2nd component of the value
  27960. */
  27961. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27962. /**
  27963. * Set the value of an uniform to a vec3
  27964. * @param uniform defines the webGL uniform location where to store the value
  27965. * @param x defines the 1st component of the value
  27966. * @param y defines the 2nd component of the value
  27967. * @param z defines the 3rd component of the value
  27968. */
  27969. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27970. /**
  27971. * Set the value of an uniform to a boolean
  27972. * @param uniform defines the webGL uniform location where to store the value
  27973. * @param bool defines the boolean to store
  27974. */
  27975. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27976. /**
  27977. * Set the value of an uniform to a vec4
  27978. * @param uniform defines the webGL uniform location where to store the value
  27979. * @param x defines the 1st component of the value
  27980. * @param y defines the 2nd component of the value
  27981. * @param z defines the 3rd component of the value
  27982. * @param w defines the 4th component of the value
  27983. */
  27984. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27985. /**
  27986. * Set the value of an uniform to a Color3
  27987. * @param uniform defines the webGL uniform location where to store the value
  27988. * @param color3 defines the color to store
  27989. */
  27990. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27991. /**
  27992. * Set the value of an uniform to a Color3 and an alpha value
  27993. * @param uniform defines the webGL uniform location where to store the value
  27994. * @param color3 defines the color to store
  27995. * @param alpha defines the alpha component to store
  27996. */
  27997. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27998. /**
  27999. * Sets a Color4 on a uniform variable
  28000. * @param uniform defines the uniform location
  28001. * @param color4 defines the value to be set
  28002. */
  28003. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28004. /**
  28005. * Set various states to the webGL context
  28006. * @param culling defines backface culling state
  28007. * @param zOffset defines the value to apply to zOffset (0 by default)
  28008. * @param force defines if states must be applied even if cache is up to date
  28009. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28010. */
  28011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28012. /**
  28013. * Set the z offset to apply to current rendering
  28014. * @param value defines the offset to apply
  28015. */
  28016. setZOffset(value: number): void;
  28017. /**
  28018. * Gets the current value of the zOffset
  28019. * @returns the current zOffset state
  28020. */
  28021. getZOffset(): number;
  28022. /**
  28023. * Enable or disable depth buffering
  28024. * @param enable defines the state to set
  28025. */
  28026. setDepthBuffer(enable: boolean): void;
  28027. /**
  28028. * Gets a boolean indicating if depth writing is enabled
  28029. * @returns the current depth writing state
  28030. */
  28031. getDepthWrite(): boolean;
  28032. /**
  28033. * Enable or disable depth writing
  28034. * @param enable defines the state to set
  28035. */
  28036. setDepthWrite(enable: boolean): void;
  28037. /**
  28038. * Enable or disable color writing
  28039. * @param enable defines the state to set
  28040. */
  28041. setColorWrite(enable: boolean): void;
  28042. /**
  28043. * Gets a boolean indicating if color writing is enabled
  28044. * @returns the current color writing state
  28045. */
  28046. getColorWrite(): boolean;
  28047. /**
  28048. * Sets alpha constants used by some alpha blending modes
  28049. * @param r defines the red component
  28050. * @param g defines the green component
  28051. * @param b defines the blue component
  28052. * @param a defines the alpha component
  28053. */
  28054. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28055. /**
  28056. * Sets the current alpha mode
  28057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28059. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28060. */
  28061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28062. /**
  28063. * Gets the current alpha mode
  28064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28065. * @returns the current alpha mode
  28066. */
  28067. getAlphaMode(): number;
  28068. /**
  28069. * Clears the list of texture accessible through engine.
  28070. * This can help preventing texture load conflict due to name collision.
  28071. */
  28072. clearInternalTexturesCache(): void;
  28073. /**
  28074. * Force the entire cache to be cleared
  28075. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28076. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28077. */
  28078. wipeCaches(bruteForce?: boolean): void;
  28079. /**
  28080. * Set the compressed texture format to use, based on the formats you have, and the formats
  28081. * supported by the hardware / browser.
  28082. *
  28083. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28084. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28085. * to API arguments needed to compressed textures. This puts the burden on the container
  28086. * generator to house the arcane code for determining these for current & future formats.
  28087. *
  28088. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28089. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28090. *
  28091. * Note: The result of this call is not taken into account when a texture is base64.
  28092. *
  28093. * @param formatsAvailable defines the list of those format families you have created
  28094. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28095. *
  28096. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28097. * @returns The extension selected.
  28098. */
  28099. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28100. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28101. min: number;
  28102. mag: number;
  28103. };
  28104. /** @hidden */ createTexture(): WebGLTexture;
  28105. /**
  28106. * Usually called from Texture.ts.
  28107. * Passed information to create a WebGLTexture
  28108. * @param urlArg defines a value which contains one of the following:
  28109. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28110. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28111. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28112. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28113. * @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)
  28114. * @param scene needed for loading to the correct scene
  28115. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28116. * @param onLoad optional callback to be called upon successful completion
  28117. * @param onError optional callback to be called upon failure
  28118. * @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
  28119. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28120. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28121. * @param forcedExtension defines the extension to use to pick the right loader
  28122. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28123. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28124. */
  28125. 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;
  28126. private _rescaleTexture;
  28127. private _unpackFlipYCached;
  28128. /**
  28129. * In case you are sharing the context with other applications, it might
  28130. * be interested to not cache the unpack flip y state to ensure a consistent
  28131. * value would be set.
  28132. */
  28133. enableUnpackFlipYCached: boolean;
  28134. /** @hidden */ unpackFlipY(value: boolean): void;
  28135. /** @hidden */ getUnpackAlignement(): number;
  28136. /**
  28137. * Creates a dynamic texture
  28138. * @param width defines the width of the texture
  28139. * @param height defines the height of the texture
  28140. * @param generateMipMaps defines if the engine should generate the mip levels
  28141. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28142. * @returns the dynamic texture inside an InternalTexture
  28143. */
  28144. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28145. /**
  28146. * Update the sampling mode of a given texture
  28147. * @param samplingMode defines the required sampling mode
  28148. * @param texture defines the texture to update
  28149. */
  28150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28151. /**
  28152. * Update the content of a dynamic texture
  28153. * @param texture defines the texture to update
  28154. * @param canvas defines the canvas containing the source
  28155. * @param invertY defines if data must be stored with Y axis inverted
  28156. * @param premulAlpha defines if alpha is stored as premultiplied
  28157. * @param format defines the format of the data
  28158. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28159. */
  28160. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28161. /**
  28162. * Update a video texture
  28163. * @param texture defines the texture to update
  28164. * @param video defines the video element to use
  28165. * @param invertY defines if data must be stored with Y axis inverted
  28166. */
  28167. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28168. /**
  28169. * Updates a depth texture Comparison Mode and Function.
  28170. * If the comparison Function is equal to 0, the mode will be set to none.
  28171. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28172. * @param texture The texture to set the comparison function for
  28173. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28174. */
  28175. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28176. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28177. width: number;
  28178. height: number;
  28179. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28180. /**
  28181. * Creates a depth stencil texture.
  28182. * This is only available in WebGL 2 or with the depth texture extension available.
  28183. * @param size The size of face edge in the texture.
  28184. * @param options The options defining the texture.
  28185. * @returns The texture
  28186. */
  28187. createDepthStencilTexture(size: number | {
  28188. width: number;
  28189. height: number;
  28190. }, options: DepthTextureCreationOptions): InternalTexture;
  28191. /**
  28192. * Creates a depth stencil texture.
  28193. * This is only available in WebGL 2 or with the depth texture extension available.
  28194. * @param size The size of face edge in the texture.
  28195. * @param options The options defining the texture.
  28196. * @returns The texture
  28197. */
  28198. private _createDepthStencilTexture;
  28199. /**
  28200. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28201. * @param renderTarget The render target to set the frame buffer for
  28202. */
  28203. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28204. /**
  28205. * Creates a new render target texture
  28206. * @param size defines the size of the texture
  28207. * @param options defines the options used to create the texture
  28208. * @returns a new render target texture stored in an InternalTexture
  28209. */
  28210. createRenderTargetTexture(size: number | {
  28211. width: number;
  28212. height: number;
  28213. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28214. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28215. /**
  28216. * Updates the sample count of a render target texture
  28217. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28218. * @param texture defines the texture to update
  28219. * @param samples defines the sample count to set
  28220. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28221. */
  28222. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28223. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28224. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28225. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28226. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28227. /**
  28228. * @hidden
  28229. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28230. private _prepareWebGLTextureContinuation;
  28231. private _prepareWebGLTexture;
  28232. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28233. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28234. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28235. private setProgram;
  28236. private _boundUniforms;
  28237. /**
  28238. * Binds an effect to the webGL context
  28239. * @param effect defines the effect to bind
  28240. */
  28241. bindSamplers(effect: Effect): void;
  28242. private _activateCurrentTexture;
  28243. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28244. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28245. /**
  28246. * Sets a texture to the webGL context from a postprocess
  28247. * @param channel defines the channel to use
  28248. * @param postProcess defines the source postprocess
  28249. */
  28250. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28251. /**
  28252. * Binds the output of the passed in post process to the texture channel specified
  28253. * @param channel The channel the texture should be bound to
  28254. * @param postProcess The post process which's output should be bound
  28255. */
  28256. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28257. /**
  28258. * Unbind all textures from the webGL context
  28259. */
  28260. unbindAllTextures(): void;
  28261. /**
  28262. * Sets a texture to the according uniform.
  28263. * @param channel The texture channel
  28264. * @param uniform The uniform to set
  28265. * @param texture The texture to apply
  28266. */
  28267. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28268. /**
  28269. * Sets a depth stencil texture from a render target to the according uniform.
  28270. * @param channel The texture channel
  28271. * @param uniform The uniform to set
  28272. * @param texture The render target texture containing the depth stencil texture to apply
  28273. */
  28274. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28275. private _bindSamplerUniformToChannel;
  28276. private _getTextureWrapMode;
  28277. private _setTexture;
  28278. /**
  28279. * Sets an array of texture to the webGL context
  28280. * @param channel defines the channel where the texture array must be set
  28281. * @param uniform defines the associated uniform location
  28282. * @param textures defines the array of textures to bind
  28283. */
  28284. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28285. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28286. private _setTextureParameterFloat;
  28287. private _setTextureParameterInteger;
  28288. /**
  28289. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28290. * @param x defines the x coordinate of the rectangle where pixels must be read
  28291. * @param y defines the y coordinate of the rectangle where pixels must be read
  28292. * @param width defines the width of the rectangle where pixels must be read
  28293. * @param height defines the height of the rectangle where pixels must be read
  28294. * @returns a Uint8Array containing RGBA colors
  28295. */
  28296. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28297. /**
  28298. * Add an externaly attached data from its key.
  28299. * This method call will fail and return false, if such key already exists.
  28300. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28301. * @param key the unique key that identifies the data
  28302. * @param data the data object to associate to the key for this Engine instance
  28303. * @return true if no such key were already present and the data was added successfully, false otherwise
  28304. */
  28305. addExternalData<T>(key: string, data: T): boolean;
  28306. /**
  28307. * Get an externaly attached data from its key
  28308. * @param key the unique key that identifies the data
  28309. * @return the associated data, if present (can be null), or undefined if not present
  28310. */
  28311. getExternalData<T>(key: string): T;
  28312. /**
  28313. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28314. * @param key the unique key that identifies the data
  28315. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28316. * @return the associated data, can be null if the factory returned null.
  28317. */
  28318. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28319. /**
  28320. * Remove an externaly attached data from the Engine instance
  28321. * @param key the unique key that identifies the data
  28322. * @return true if the data was successfully removed, false if it doesn't exist
  28323. */
  28324. removeExternalData(key: string): boolean;
  28325. /**
  28326. * Unbind all vertex attributes from the webGL context
  28327. */
  28328. unbindAllAttributes(): void;
  28329. /**
  28330. * 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
  28331. */
  28332. releaseEffects(): void;
  28333. /**
  28334. * Dispose and release all associated resources
  28335. */
  28336. dispose(): void;
  28337. /**
  28338. * Display the loading screen
  28339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28340. */
  28341. displayLoadingUI(): void;
  28342. /**
  28343. * Hide the loading screen
  28344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28345. */
  28346. hideLoadingUI(): void;
  28347. /**
  28348. * Gets the current loading screen object
  28349. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28350. */
  28351. /**
  28352. * Sets the current loading screen object
  28353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28354. */
  28355. loadingScreen: ILoadingScreen;
  28356. /**
  28357. * Sets the current loading screen text
  28358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28359. */
  28360. loadingUIText: string;
  28361. /**
  28362. * Sets the current loading screen background color
  28363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28364. */
  28365. loadingUIBackgroundColor: string;
  28366. /**
  28367. * Attach a new callback raised when context lost event is fired
  28368. * @param callback defines the callback to call
  28369. */
  28370. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28371. /**
  28372. * Attach a new callback raised when context restored event is fired
  28373. * @param callback defines the callback to call
  28374. */
  28375. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28376. /**
  28377. * Gets the source code of the vertex shader associated with a specific webGL program
  28378. * @param program defines the program to use
  28379. * @returns a string containing the source code of the vertex shader associated with the program
  28380. */
  28381. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28382. /**
  28383. * Gets the source code of the fragment shader associated with a specific webGL program
  28384. * @param program defines the program to use
  28385. * @returns a string containing the source code of the fragment shader associated with the program
  28386. */
  28387. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28388. /**
  28389. * Get the current error code of the webGL context
  28390. * @returns the error code
  28391. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28392. */
  28393. getError(): number;
  28394. /**
  28395. * Gets the current framerate
  28396. * @returns a number representing the framerate
  28397. */
  28398. getFps(): number;
  28399. /**
  28400. * Gets the time spent between current and previous frame
  28401. * @returns a number representing the delta time in ms
  28402. */
  28403. getDeltaTime(): number;
  28404. private _measureFps;
  28405. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28406. private _canRenderToFloatFramebuffer;
  28407. private _canRenderToHalfFloatFramebuffer;
  28408. private _canRenderToFramebuffer;
  28409. /** @hidden */ getWebGLTextureType(type: number): number;
  28410. /** @hidden */ getInternalFormat(format: number): number;
  28411. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28412. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28413. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28414. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28415. /**
  28416. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28417. * @returns true if the engine can be created
  28418. * @ignorenaming
  28419. */
  28420. static isSupported(): boolean;
  28421. }
  28422. }
  28423. declare module BABYLON {
  28424. /**
  28425. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28426. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28427. */
  28428. export class EffectFallbacks {
  28429. private _defines;
  28430. private _currentRank;
  28431. private _maxRank;
  28432. private _mesh;
  28433. /**
  28434. * Removes the fallback from the bound mesh.
  28435. */
  28436. unBindMesh(): void;
  28437. /**
  28438. * Adds a fallback on the specified property.
  28439. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28440. * @param define The name of the define in the shader
  28441. */
  28442. addFallback(rank: number, define: string): void;
  28443. /**
  28444. * Sets the mesh to use CPU skinning when needing to fallback.
  28445. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28446. * @param mesh The mesh to use the fallbacks.
  28447. */
  28448. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28449. /**
  28450. * Checks to see if more fallbacks are still availible.
  28451. */
  28452. readonly isMoreFallbacks: boolean;
  28453. /**
  28454. * Removes the defines that shoould be removed when falling back.
  28455. * @param currentDefines defines the current define statements for the shader.
  28456. * @param effect defines the current effect we try to compile
  28457. * @returns The resulting defines with defines of the current rank removed.
  28458. */
  28459. reduce(currentDefines: string, effect: Effect): string;
  28460. }
  28461. /**
  28462. * Options to be used when creating an effect.
  28463. */
  28464. export class EffectCreationOptions {
  28465. /**
  28466. * Atrributes that will be used in the shader.
  28467. */
  28468. attributes: string[];
  28469. /**
  28470. * Uniform varible names that will be set in the shader.
  28471. */
  28472. uniformsNames: string[];
  28473. /**
  28474. * Uniform buffer varible names that will be set in the shader.
  28475. */
  28476. uniformBuffersNames: string[];
  28477. /**
  28478. * Sampler texture variable names that will be set in the shader.
  28479. */
  28480. samplers: string[];
  28481. /**
  28482. * Define statements that will be set in the shader.
  28483. */
  28484. defines: any;
  28485. /**
  28486. * Possible fallbacks for this effect to improve performance when needed.
  28487. */
  28488. fallbacks: Nullable<EffectFallbacks>;
  28489. /**
  28490. * Callback that will be called when the shader is compiled.
  28491. */
  28492. onCompiled: Nullable<(effect: Effect) => void>;
  28493. /**
  28494. * Callback that will be called if an error occurs during shader compilation.
  28495. */
  28496. onError: Nullable<(effect: Effect, errors: string) => void>;
  28497. /**
  28498. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28499. */
  28500. indexParameters: any;
  28501. /**
  28502. * Max number of lights that can be used in the shader.
  28503. */
  28504. maxSimultaneousLights: number;
  28505. /**
  28506. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28507. */
  28508. transformFeedbackVaryings: Nullable<string[]>;
  28509. }
  28510. /**
  28511. * Effect containing vertex and fragment shader that can be executed on an object.
  28512. */
  28513. export class Effect implements IDisposable {
  28514. /**
  28515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28516. */
  28517. static ShadersRepository: string;
  28518. /**
  28519. * Name of the effect.
  28520. */
  28521. name: any;
  28522. /**
  28523. * String container all the define statements that should be set on the shader.
  28524. */
  28525. defines: string;
  28526. /**
  28527. * Callback that will be called when the shader is compiled.
  28528. */
  28529. onCompiled: Nullable<(effect: Effect) => void>;
  28530. /**
  28531. * Callback that will be called if an error occurs during shader compilation.
  28532. */
  28533. onError: Nullable<(effect: Effect, errors: string) => void>;
  28534. /**
  28535. * Callback that will be called when effect is bound.
  28536. */
  28537. onBind: Nullable<(effect: Effect) => void>;
  28538. /**
  28539. * Unique ID of the effect.
  28540. */
  28541. uniqueId: number;
  28542. /**
  28543. * Observable that will be called when the shader is compiled.
  28544. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28545. */
  28546. onCompileObservable: Observable<Effect>;
  28547. /**
  28548. * Observable that will be called if an error occurs during shader compilation.
  28549. */
  28550. onErrorObservable: Observable<Effect>;
  28551. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28552. /**
  28553. * Observable that will be called when effect is bound.
  28554. */
  28555. readonly onBindObservable: Observable<Effect>;
  28556. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28557. private static _uniqueIdSeed;
  28558. private _engine;
  28559. private _uniformBuffersNames;
  28560. private _uniformsNames;
  28561. private _samplerList;
  28562. private _samplers;
  28563. private _isReady;
  28564. private _compilationError;
  28565. private _attributesNames;
  28566. private _attributes;
  28567. private _uniforms;
  28568. /**
  28569. * Key for the effect.
  28570. * @hidden
  28571. */ key: string;
  28572. private _indexParameters;
  28573. private _fallbacks;
  28574. private _vertexSourceCode;
  28575. private _fragmentSourceCode;
  28576. private _vertexSourceCodeOverride;
  28577. private _fragmentSourceCodeOverride;
  28578. private _transformFeedbackVaryings;
  28579. /**
  28580. * Compiled shader to webGL program.
  28581. * @hidden
  28582. */ pipelineContext: IPipelineContext;
  28583. private _valueCache;
  28584. private static _baseCache;
  28585. /**
  28586. * Instantiates an effect.
  28587. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28588. * @param baseName Name of the effect.
  28589. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28590. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28591. * @param samplers List of sampler variables that will be passed to the shader.
  28592. * @param engine Engine to be used to render the effect
  28593. * @param defines Define statements to be added to the shader.
  28594. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28595. * @param onCompiled Callback that will be called when the shader is compiled.
  28596. * @param onError Callback that will be called if an error occurs during shader compilation.
  28597. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28598. */
  28599. 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);
  28600. /**
  28601. * Unique key for this effect
  28602. */
  28603. readonly key: string;
  28604. /**
  28605. * If the effect has been compiled and prepared.
  28606. * @returns if the effect is compiled and prepared.
  28607. */
  28608. isReady(): boolean;
  28609. /**
  28610. * The engine the effect was initialized with.
  28611. * @returns the engine.
  28612. */
  28613. getEngine(): Engine;
  28614. /**
  28615. * The pipeline context for this effect
  28616. * @returns the associated pipeline context
  28617. */
  28618. getPipelineContext(): IPipelineContext;
  28619. /**
  28620. * The set of names of attribute variables for the shader.
  28621. * @returns An array of attribute names.
  28622. */
  28623. getAttributesNames(): string[];
  28624. /**
  28625. * Returns the attribute at the given index.
  28626. * @param index The index of the attribute.
  28627. * @returns The location of the attribute.
  28628. */
  28629. getAttributeLocation(index: number): number;
  28630. /**
  28631. * Returns the attribute based on the name of the variable.
  28632. * @param name of the attribute to look up.
  28633. * @returns the attribute location.
  28634. */
  28635. getAttributeLocationByName(name: string): number;
  28636. /**
  28637. * The number of attributes.
  28638. * @returns the numnber of attributes.
  28639. */
  28640. getAttributesCount(): number;
  28641. /**
  28642. * Gets the index of a uniform variable.
  28643. * @param uniformName of the uniform to look up.
  28644. * @returns the index.
  28645. */
  28646. getUniformIndex(uniformName: string): number;
  28647. /**
  28648. * Returns the attribute based on the name of the variable.
  28649. * @param uniformName of the uniform to look up.
  28650. * @returns the location of the uniform.
  28651. */
  28652. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28653. /**
  28654. * Returns an array of sampler variable names
  28655. * @returns The array of sampler variable neames.
  28656. */
  28657. getSamplers(): string[];
  28658. /**
  28659. * The error from the last compilation.
  28660. * @returns the error string.
  28661. */
  28662. getCompilationError(): string;
  28663. /**
  28664. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28665. * @param func The callback to be used.
  28666. */
  28667. executeWhenCompiled(func: (effect: Effect) => void): void;
  28668. private _checkIsReady;
  28669. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28670. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28671. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28672. private _processShaderConversion;
  28673. private _processIncludes;
  28674. private _processPrecision;
  28675. /**
  28676. * Recompiles the webGL program
  28677. * @param vertexSourceCode The source code for the vertex shader.
  28678. * @param fragmentSourceCode The source code for the fragment shader.
  28679. * @param onCompiled Callback called when completed.
  28680. * @param onError Callback called on error.
  28681. * @hidden
  28682. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28683. /**
  28684. * Prepares the effect
  28685. * @hidden
  28686. */ prepareEffect(): void;
  28687. /**
  28688. * Checks if the effect is supported. (Must be called after compilation)
  28689. */
  28690. readonly isSupported: boolean;
  28691. /**
  28692. * Binds a texture to the engine to be used as output of the shader.
  28693. * @param channel Name of the output variable.
  28694. * @param texture Texture to bind.
  28695. * @hidden
  28696. */ bindTexture(channel: string, texture: InternalTexture): void;
  28697. /**
  28698. * Sets a texture on the engine to be used in the shader.
  28699. * @param channel Name of the sampler variable.
  28700. * @param texture Texture to set.
  28701. */
  28702. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28703. /**
  28704. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28705. * @param channel Name of the sampler variable.
  28706. * @param texture Texture to set.
  28707. */
  28708. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28709. /**
  28710. * Sets an array of textures on the engine to be used in the shader.
  28711. * @param channel Name of the variable.
  28712. * @param textures Textures to set.
  28713. */
  28714. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28715. /**
  28716. * 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)
  28717. * @param channel Name of the sampler variable.
  28718. * @param postProcess Post process to get the input texture from.
  28719. */
  28720. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28721. /**
  28722. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28723. * 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)
  28724. * @param channel Name of the sampler variable.
  28725. * @param postProcess Post process to get the output texture from.
  28726. */
  28727. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28728. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28729. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28730. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28731. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28732. /**
  28733. * Binds a buffer to a uniform.
  28734. * @param buffer Buffer to bind.
  28735. * @param name Name of the uniform variable to bind to.
  28736. */
  28737. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28738. /**
  28739. * Binds block to a uniform.
  28740. * @param blockName Name of the block to bind.
  28741. * @param index Index to bind.
  28742. */
  28743. bindUniformBlock(blockName: string, index: number): void;
  28744. /**
  28745. * Sets an interger value on a uniform variable.
  28746. * @param uniformName Name of the variable.
  28747. * @param value Value to be set.
  28748. * @returns this effect.
  28749. */
  28750. setInt(uniformName: string, value: number): Effect;
  28751. /**
  28752. * Sets an int array on a uniform variable.
  28753. * @param uniformName Name of the variable.
  28754. * @param array array to be set.
  28755. * @returns this effect.
  28756. */
  28757. setIntArray(uniformName: string, array: Int32Array): Effect;
  28758. /**
  28759. * 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)
  28760. * @param uniformName Name of the variable.
  28761. * @param array array to be set.
  28762. * @returns this effect.
  28763. */
  28764. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28765. /**
  28766. * 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)
  28767. * @param uniformName Name of the variable.
  28768. * @param array array to be set.
  28769. * @returns this effect.
  28770. */
  28771. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28772. /**
  28773. * 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)
  28774. * @param uniformName Name of the variable.
  28775. * @param array array to be set.
  28776. * @returns this effect.
  28777. */
  28778. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28779. /**
  28780. * Sets an float array on a uniform variable.
  28781. * @param uniformName Name of the variable.
  28782. * @param array array to be set.
  28783. * @returns this effect.
  28784. */
  28785. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28786. /**
  28787. * 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)
  28788. * @param uniformName Name of the variable.
  28789. * @param array array to be set.
  28790. * @returns this effect.
  28791. */
  28792. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28793. /**
  28794. * 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)
  28795. * @param uniformName Name of the variable.
  28796. * @param array array to be set.
  28797. * @returns this effect.
  28798. */
  28799. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28800. /**
  28801. * 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)
  28802. * @param uniformName Name of the variable.
  28803. * @param array array to be set.
  28804. * @returns this effect.
  28805. */
  28806. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28807. /**
  28808. * Sets an array on a uniform variable.
  28809. * @param uniformName Name of the variable.
  28810. * @param array array to be set.
  28811. * @returns this effect.
  28812. */
  28813. setArray(uniformName: string, array: number[]): Effect;
  28814. /**
  28815. * 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)
  28816. * @param uniformName Name of the variable.
  28817. * @param array array to be set.
  28818. * @returns this effect.
  28819. */
  28820. setArray2(uniformName: string, array: number[]): Effect;
  28821. /**
  28822. * 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)
  28823. * @param uniformName Name of the variable.
  28824. * @param array array to be set.
  28825. * @returns this effect.
  28826. */
  28827. setArray3(uniformName: string, array: number[]): Effect;
  28828. /**
  28829. * 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)
  28830. * @param uniformName Name of the variable.
  28831. * @param array array to be set.
  28832. * @returns this effect.
  28833. */
  28834. setArray4(uniformName: string, array: number[]): Effect;
  28835. /**
  28836. * Sets matrices on a uniform variable.
  28837. * @param uniformName Name of the variable.
  28838. * @param matrices matrices to be set.
  28839. * @returns this effect.
  28840. */
  28841. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28842. /**
  28843. * Sets matrix on a uniform variable.
  28844. * @param uniformName Name of the variable.
  28845. * @param matrix matrix to be set.
  28846. * @returns this effect.
  28847. */
  28848. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28849. /**
  28850. * 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)
  28851. * @param uniformName Name of the variable.
  28852. * @param matrix matrix to be set.
  28853. * @returns this effect.
  28854. */
  28855. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28856. /**
  28857. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28858. * @param uniformName Name of the variable.
  28859. * @param matrix matrix to be set.
  28860. * @returns this effect.
  28861. */
  28862. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28863. /**
  28864. * Sets a float on a uniform variable.
  28865. * @param uniformName Name of the variable.
  28866. * @param value value to be set.
  28867. * @returns this effect.
  28868. */
  28869. setFloat(uniformName: string, value: number): Effect;
  28870. /**
  28871. * Sets a boolean on a uniform variable.
  28872. * @param uniformName Name of the variable.
  28873. * @param bool value to be set.
  28874. * @returns this effect.
  28875. */
  28876. setBool(uniformName: string, bool: boolean): Effect;
  28877. /**
  28878. * Sets a Vector2 on a uniform variable.
  28879. * @param uniformName Name of the variable.
  28880. * @param vector2 vector2 to be set.
  28881. * @returns this effect.
  28882. */
  28883. setVector2(uniformName: string, vector2: Vector2): Effect;
  28884. /**
  28885. * Sets a float2 on a uniform variable.
  28886. * @param uniformName Name of the variable.
  28887. * @param x First float in float2.
  28888. * @param y Second float in float2.
  28889. * @returns this effect.
  28890. */
  28891. setFloat2(uniformName: string, x: number, y: number): Effect;
  28892. /**
  28893. * Sets a Vector3 on a uniform variable.
  28894. * @param uniformName Name of the variable.
  28895. * @param vector3 Value to be set.
  28896. * @returns this effect.
  28897. */
  28898. setVector3(uniformName: string, vector3: Vector3): Effect;
  28899. /**
  28900. * Sets a float3 on a uniform variable.
  28901. * @param uniformName Name of the variable.
  28902. * @param x First float in float3.
  28903. * @param y Second float in float3.
  28904. * @param z Third float in float3.
  28905. * @returns this effect.
  28906. */
  28907. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28908. /**
  28909. * Sets a Vector4 on a uniform variable.
  28910. * @param uniformName Name of the variable.
  28911. * @param vector4 Value to be set.
  28912. * @returns this effect.
  28913. */
  28914. setVector4(uniformName: string, vector4: Vector4): Effect;
  28915. /**
  28916. * Sets a float4 on a uniform variable.
  28917. * @param uniformName Name of the variable.
  28918. * @param x First float in float4.
  28919. * @param y Second float in float4.
  28920. * @param z Third float in float4.
  28921. * @param w Fourth float in float4.
  28922. * @returns this effect.
  28923. */
  28924. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28925. /**
  28926. * Sets a Color3 on a uniform variable.
  28927. * @param uniformName Name of the variable.
  28928. * @param color3 Value to be set.
  28929. * @returns this effect.
  28930. */
  28931. setColor3(uniformName: string, color3: Color3): Effect;
  28932. /**
  28933. * Sets a Color4 on a uniform variable.
  28934. * @param uniformName Name of the variable.
  28935. * @param color3 Value to be set.
  28936. * @param alpha Alpha value to be set.
  28937. * @returns this effect.
  28938. */
  28939. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28940. /**
  28941. * Sets a Color4 on a uniform variable
  28942. * @param uniformName defines the name of the variable
  28943. * @param color4 defines the value to be set
  28944. * @returns this effect.
  28945. */
  28946. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28947. /** Release all associated resources */
  28948. dispose(): void;
  28949. /**
  28950. * This function will add a new shader to the shader store
  28951. * @param name the name of the shader
  28952. * @param pixelShader optional pixel shader content
  28953. * @param vertexShader optional vertex shader content
  28954. */
  28955. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28956. /**
  28957. * Store of each shader (The can be looked up using effect.key)
  28958. */
  28959. static ShadersStore: {
  28960. [key: string]: string;
  28961. };
  28962. /**
  28963. * Store of each included file for a shader (The can be looked up using effect.key)
  28964. */
  28965. static IncludesShadersStore: {
  28966. [key: string]: string;
  28967. };
  28968. /**
  28969. * Resets the cache of effects.
  28970. */
  28971. static ResetCache(): void;
  28972. }
  28973. }
  28974. declare module BABYLON {
  28975. /**
  28976. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28977. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28978. * 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;
  28979. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28980. */
  28981. export class ColorCurves {
  28982. private _dirty;
  28983. private _tempColor;
  28984. private _globalCurve;
  28985. private _highlightsCurve;
  28986. private _midtonesCurve;
  28987. private _shadowsCurve;
  28988. private _positiveCurve;
  28989. private _negativeCurve;
  28990. private _globalHue;
  28991. private _globalDensity;
  28992. private _globalSaturation;
  28993. private _globalExposure;
  28994. /**
  28995. * Gets the global Hue value.
  28996. * 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).
  28997. */
  28998. /**
  28999. * Sets the global Hue value.
  29000. * 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).
  29001. */
  29002. globalHue: number;
  29003. /**
  29004. * Gets the global Density value.
  29005. * 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.
  29006. * Values less than zero provide a filter of opposite hue.
  29007. */
  29008. /**
  29009. * Sets the global Density value.
  29010. * 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.
  29011. * Values less than zero provide a filter of opposite hue.
  29012. */
  29013. globalDensity: number;
  29014. /**
  29015. * Gets the global Saturation value.
  29016. * 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.
  29017. */
  29018. /**
  29019. * Sets the global Saturation value.
  29020. * 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.
  29021. */
  29022. globalSaturation: number;
  29023. /**
  29024. * Gets the global Exposure value.
  29025. * 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.
  29026. */
  29027. /**
  29028. * Sets the global Exposure value.
  29029. * 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.
  29030. */
  29031. globalExposure: number;
  29032. private _highlightsHue;
  29033. private _highlightsDensity;
  29034. private _highlightsSaturation;
  29035. private _highlightsExposure;
  29036. /**
  29037. * Gets the highlights Hue value.
  29038. * 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).
  29039. */
  29040. /**
  29041. * Sets the highlights Hue value.
  29042. * 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).
  29043. */
  29044. highlightsHue: number;
  29045. /**
  29046. * Gets the highlights Density value.
  29047. * 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.
  29048. * Values less than zero provide a filter of opposite hue.
  29049. */
  29050. /**
  29051. * Sets the highlights Density value.
  29052. * 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.
  29053. * Values less than zero provide a filter of opposite hue.
  29054. */
  29055. highlightsDensity: number;
  29056. /**
  29057. * Gets the highlights Saturation value.
  29058. * 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.
  29059. */
  29060. /**
  29061. * Sets the highlights Saturation value.
  29062. * 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.
  29063. */
  29064. highlightsSaturation: number;
  29065. /**
  29066. * Gets the highlights Exposure value.
  29067. * 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.
  29068. */
  29069. /**
  29070. * Sets the highlights Exposure value.
  29071. * 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.
  29072. */
  29073. highlightsExposure: number;
  29074. private _midtonesHue;
  29075. private _midtonesDensity;
  29076. private _midtonesSaturation;
  29077. private _midtonesExposure;
  29078. /**
  29079. * Gets the midtones Hue value.
  29080. * 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).
  29081. */
  29082. /**
  29083. * Sets the midtones Hue value.
  29084. * 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).
  29085. */
  29086. midtonesHue: number;
  29087. /**
  29088. * Gets the midtones Density value.
  29089. * 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.
  29090. * Values less than zero provide a filter of opposite hue.
  29091. */
  29092. /**
  29093. * Sets the midtones Density value.
  29094. * 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.
  29095. * Values less than zero provide a filter of opposite hue.
  29096. */
  29097. midtonesDensity: number;
  29098. /**
  29099. * Gets the midtones Saturation value.
  29100. * 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.
  29101. */
  29102. /**
  29103. * Sets the midtones Saturation value.
  29104. * 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.
  29105. */
  29106. midtonesSaturation: number;
  29107. /**
  29108. * Gets the midtones Exposure value.
  29109. * 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.
  29110. */
  29111. /**
  29112. * Sets the midtones Exposure value.
  29113. * 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.
  29114. */
  29115. midtonesExposure: number;
  29116. private _shadowsHue;
  29117. private _shadowsDensity;
  29118. private _shadowsSaturation;
  29119. private _shadowsExposure;
  29120. /**
  29121. * Gets the shadows Hue value.
  29122. * 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).
  29123. */
  29124. /**
  29125. * Sets the shadows Hue value.
  29126. * 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).
  29127. */
  29128. shadowsHue: number;
  29129. /**
  29130. * Gets the shadows Density value.
  29131. * 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.
  29132. * Values less than zero provide a filter of opposite hue.
  29133. */
  29134. /**
  29135. * Sets the shadows Density value.
  29136. * 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.
  29137. * Values less than zero provide a filter of opposite hue.
  29138. */
  29139. shadowsDensity: number;
  29140. /**
  29141. * Gets the shadows Saturation value.
  29142. * 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.
  29143. */
  29144. /**
  29145. * Sets the shadows Saturation value.
  29146. * 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.
  29147. */
  29148. shadowsSaturation: number;
  29149. /**
  29150. * Gets the shadows Exposure value.
  29151. * 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.
  29152. */
  29153. /**
  29154. * Sets the shadows Exposure value.
  29155. * 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.
  29156. */
  29157. shadowsExposure: number;
  29158. /**
  29159. * Returns the class name
  29160. * @returns The class name
  29161. */
  29162. getClassName(): string;
  29163. /**
  29164. * Binds the color curves to the shader.
  29165. * @param colorCurves The color curve to bind
  29166. * @param effect The effect to bind to
  29167. * @param positiveUniform The positive uniform shader parameter
  29168. * @param neutralUniform The neutral uniform shader parameter
  29169. * @param negativeUniform The negative uniform shader parameter
  29170. */
  29171. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29172. /**
  29173. * Prepare the list of uniforms associated with the ColorCurves effects.
  29174. * @param uniformsList The list of uniforms used in the effect
  29175. */
  29176. static PrepareUniforms(uniformsList: string[]): void;
  29177. /**
  29178. * Returns color grading data based on a hue, density, saturation and exposure value.
  29179. * @param filterHue The hue of the color filter.
  29180. * @param filterDensity The density of the color filter.
  29181. * @param saturation The saturation.
  29182. * @param exposure The exposure.
  29183. * @param result The result data container.
  29184. */
  29185. private getColorGradingDataToRef;
  29186. /**
  29187. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29188. * @param value The input slider value in range [-100,100].
  29189. * @returns Adjusted value.
  29190. */
  29191. private static applyColorGradingSliderNonlinear;
  29192. /**
  29193. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29194. * @param hue The hue (H) input.
  29195. * @param saturation The saturation (S) input.
  29196. * @param brightness The brightness (B) input.
  29197. * @result An RGBA color represented as Vector4.
  29198. */
  29199. private static fromHSBToRef;
  29200. /**
  29201. * Returns a value clamped between min and max
  29202. * @param value The value to clamp
  29203. * @param min The minimum of value
  29204. * @param max The maximum of value
  29205. * @returns The clamped value.
  29206. */
  29207. private static clamp;
  29208. /**
  29209. * Clones the current color curve instance.
  29210. * @return The cloned curves
  29211. */
  29212. clone(): ColorCurves;
  29213. /**
  29214. * Serializes the current color curve instance to a json representation.
  29215. * @return a JSON representation
  29216. */
  29217. serialize(): any;
  29218. /**
  29219. * Parses the color curve from a json representation.
  29220. * @param source the JSON source to parse
  29221. * @return The parsed curves
  29222. */
  29223. static Parse(source: any): ColorCurves;
  29224. }
  29225. }
  29226. declare module BABYLON {
  29227. /**
  29228. * Interface to follow in your material defines to integrate easily the
  29229. * Image proccessing functions.
  29230. * @hidden
  29231. */
  29232. export interface IImageProcessingConfigurationDefines {
  29233. IMAGEPROCESSING: boolean;
  29234. VIGNETTE: boolean;
  29235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29236. VIGNETTEBLENDMODEOPAQUE: boolean;
  29237. TONEMAPPING: boolean;
  29238. TONEMAPPING_ACES: boolean;
  29239. CONTRAST: boolean;
  29240. EXPOSURE: boolean;
  29241. COLORCURVES: boolean;
  29242. COLORGRADING: boolean;
  29243. COLORGRADING3D: boolean;
  29244. SAMPLER3DGREENDEPTH: boolean;
  29245. SAMPLER3DBGRMAP: boolean;
  29246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29247. }
  29248. /**
  29249. * @hidden
  29250. */
  29251. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29252. IMAGEPROCESSING: boolean;
  29253. VIGNETTE: boolean;
  29254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29255. VIGNETTEBLENDMODEOPAQUE: boolean;
  29256. TONEMAPPING: boolean;
  29257. TONEMAPPING_ACES: boolean;
  29258. CONTRAST: boolean;
  29259. COLORCURVES: boolean;
  29260. COLORGRADING: boolean;
  29261. COLORGRADING3D: boolean;
  29262. SAMPLER3DGREENDEPTH: boolean;
  29263. SAMPLER3DBGRMAP: boolean;
  29264. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29265. EXPOSURE: boolean;
  29266. constructor();
  29267. }
  29268. /**
  29269. * This groups together the common properties used for image processing either in direct forward pass
  29270. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29271. * or not.
  29272. */
  29273. export class ImageProcessingConfiguration {
  29274. /**
  29275. * Default tone mapping applied in BabylonJS.
  29276. */
  29277. static readonly TONEMAPPING_STANDARD: number;
  29278. /**
  29279. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29280. * to other engines rendering to increase portability.
  29281. */
  29282. static readonly TONEMAPPING_ACES: number;
  29283. /**
  29284. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29285. */
  29286. colorCurves: Nullable<ColorCurves>;
  29287. private _colorCurvesEnabled;
  29288. /**
  29289. * Gets wether the color curves effect is enabled.
  29290. */
  29291. /**
  29292. * Sets wether the color curves effect is enabled.
  29293. */
  29294. colorCurvesEnabled: boolean;
  29295. private _colorGradingTexture;
  29296. /**
  29297. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29298. */
  29299. /**
  29300. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29301. */
  29302. colorGradingTexture: Nullable<BaseTexture>;
  29303. private _colorGradingEnabled;
  29304. /**
  29305. * Gets wether the color grading effect is enabled.
  29306. */
  29307. /**
  29308. * Sets wether the color grading effect is enabled.
  29309. */
  29310. colorGradingEnabled: boolean;
  29311. private _colorGradingWithGreenDepth;
  29312. /**
  29313. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29314. */
  29315. /**
  29316. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29317. */
  29318. colorGradingWithGreenDepth: boolean;
  29319. private _colorGradingBGR;
  29320. /**
  29321. * Gets wether the color grading texture contains BGR values.
  29322. */
  29323. /**
  29324. * Sets wether the color grading texture contains BGR values.
  29325. */
  29326. colorGradingBGR: boolean;
  29327. /** @hidden */ exposure: number;
  29328. /**
  29329. * Gets the Exposure used in the effect.
  29330. */
  29331. /**
  29332. * Sets the Exposure used in the effect.
  29333. */
  29334. exposure: number;
  29335. private _toneMappingEnabled;
  29336. /**
  29337. * Gets wether the tone mapping effect is enabled.
  29338. */
  29339. /**
  29340. * Sets wether the tone mapping effect is enabled.
  29341. */
  29342. toneMappingEnabled: boolean;
  29343. private _toneMappingType;
  29344. /**
  29345. * Gets the type of tone mapping effect.
  29346. */
  29347. /**
  29348. * Sets the type of tone mapping effect used in BabylonJS.
  29349. */
  29350. toneMappingType: number;
  29351. protected _contrast: number;
  29352. /**
  29353. * Gets the contrast used in the effect.
  29354. */
  29355. /**
  29356. * Sets the contrast used in the effect.
  29357. */
  29358. contrast: number;
  29359. /**
  29360. * Vignette stretch size.
  29361. */
  29362. vignetteStretch: number;
  29363. /**
  29364. * Vignette centre X Offset.
  29365. */
  29366. vignetteCentreX: number;
  29367. /**
  29368. * Vignette centre Y Offset.
  29369. */
  29370. vignetteCentreY: number;
  29371. /**
  29372. * Vignette weight or intensity of the vignette effect.
  29373. */
  29374. vignetteWeight: number;
  29375. /**
  29376. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29377. * if vignetteEnabled is set to true.
  29378. */
  29379. vignetteColor: Color4;
  29380. /**
  29381. * Camera field of view used by the Vignette effect.
  29382. */
  29383. vignetteCameraFov: number;
  29384. private _vignetteBlendMode;
  29385. /**
  29386. * Gets the vignette blend mode allowing different kind of effect.
  29387. */
  29388. /**
  29389. * Sets the vignette blend mode allowing different kind of effect.
  29390. */
  29391. vignetteBlendMode: number;
  29392. private _vignetteEnabled;
  29393. /**
  29394. * Gets wether the vignette effect is enabled.
  29395. */
  29396. /**
  29397. * Sets wether the vignette effect is enabled.
  29398. */
  29399. vignetteEnabled: boolean;
  29400. private _applyByPostProcess;
  29401. /**
  29402. * Gets wether the image processing is applied through a post process or not.
  29403. */
  29404. /**
  29405. * Sets wether the image processing is applied through a post process or not.
  29406. */
  29407. applyByPostProcess: boolean;
  29408. private _isEnabled;
  29409. /**
  29410. * Gets wether the image processing is enabled or not.
  29411. */
  29412. /**
  29413. * Sets wether the image processing is enabled or not.
  29414. */
  29415. isEnabled: boolean;
  29416. /**
  29417. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29418. */
  29419. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29420. /**
  29421. * Method called each time the image processing information changes requires to recompile the effect.
  29422. */
  29423. protected _updateParameters(): void;
  29424. /**
  29425. * Gets the current class name.
  29426. * @return "ImageProcessingConfiguration"
  29427. */
  29428. getClassName(): string;
  29429. /**
  29430. * Prepare the list of uniforms associated with the Image Processing effects.
  29431. * @param uniforms The list of uniforms used in the effect
  29432. * @param defines the list of defines currently in use
  29433. */
  29434. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29435. /**
  29436. * Prepare the list of samplers associated with the Image Processing effects.
  29437. * @param samplersList The list of uniforms used in the effect
  29438. * @param defines the list of defines currently in use
  29439. */
  29440. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29441. /**
  29442. * Prepare the list of defines associated to the shader.
  29443. * @param defines the list of defines to complete
  29444. * @param forPostProcess Define if we are currently in post process mode or not
  29445. */
  29446. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29447. /**
  29448. * Returns true if all the image processing information are ready.
  29449. * @returns True if ready, otherwise, false
  29450. */
  29451. isReady(): boolean;
  29452. /**
  29453. * Binds the image processing to the shader.
  29454. * @param effect The effect to bind to
  29455. * @param aspectRatio Define the current aspect ratio of the effect
  29456. */
  29457. bind(effect: Effect, aspectRatio?: number): void;
  29458. /**
  29459. * Clones the current image processing instance.
  29460. * @return The cloned image processing
  29461. */
  29462. clone(): ImageProcessingConfiguration;
  29463. /**
  29464. * Serializes the current image processing instance to a json representation.
  29465. * @return a JSON representation
  29466. */
  29467. serialize(): any;
  29468. /**
  29469. * Parses the image processing from a json representation.
  29470. * @param source the JSON source to parse
  29471. * @return The parsed image processing
  29472. */
  29473. static Parse(source: any): ImageProcessingConfiguration;
  29474. private static _VIGNETTEMODE_MULTIPLY;
  29475. private static _VIGNETTEMODE_OPAQUE;
  29476. /**
  29477. * Used to apply the vignette as a mix with the pixel color.
  29478. */
  29479. static readonly VIGNETTEMODE_MULTIPLY: number;
  29480. /**
  29481. * Used to apply the vignette as a replacement of the pixel color.
  29482. */
  29483. static readonly VIGNETTEMODE_OPAQUE: number;
  29484. }
  29485. }
  29486. declare module BABYLON {
  29487. /**
  29488. * This represents all the required information to add a fresnel effect on a material:
  29489. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29490. */
  29491. export class FresnelParameters {
  29492. private _isEnabled;
  29493. /**
  29494. * Define if the fresnel effect is enable or not.
  29495. */
  29496. isEnabled: boolean;
  29497. /**
  29498. * Define the color used on edges (grazing angle)
  29499. */
  29500. leftColor: Color3;
  29501. /**
  29502. * Define the color used on center
  29503. */
  29504. rightColor: Color3;
  29505. /**
  29506. * Define bias applied to computed fresnel term
  29507. */
  29508. bias: number;
  29509. /**
  29510. * Defined the power exponent applied to fresnel term
  29511. */
  29512. power: number;
  29513. /**
  29514. * Clones the current fresnel and its valuues
  29515. * @returns a clone fresnel configuration
  29516. */
  29517. clone(): FresnelParameters;
  29518. /**
  29519. * Serializes the current fresnel parameters to a JSON representation.
  29520. * @return the JSON serialization
  29521. */
  29522. serialize(): any;
  29523. /**
  29524. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29525. * @param parsedFresnelParameters Define the JSON representation
  29526. * @returns the parsed parameters
  29527. */
  29528. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29529. }
  29530. }
  29531. declare module BABYLON {
  29532. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29533. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29534. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29535. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29536. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29537. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29538. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29539. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29540. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29541. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29542. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29543. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29544. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29545. /**
  29546. * Decorator used to define property that can be serialized as reference to a camera
  29547. * @param sourceName defines the name of the property to decorate
  29548. */
  29549. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29550. /**
  29551. * Class used to help serialization objects
  29552. */
  29553. export class SerializationHelper {
  29554. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29555. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29556. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29557. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29558. /**
  29559. * Appends the serialized animations from the source animations
  29560. * @param source Source containing the animations
  29561. * @param destination Target to store the animations
  29562. */
  29563. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29564. /**
  29565. * Static function used to serialized a specific entity
  29566. * @param entity defines the entity to serialize
  29567. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29568. * @returns a JSON compatible object representing the serialization of the entity
  29569. */
  29570. static Serialize<T>(entity: T, serializationObject?: any): any;
  29571. /**
  29572. * Creates a new entity from a serialization data object
  29573. * @param creationFunction defines a function used to instanciated the new entity
  29574. * @param source defines the source serialization data
  29575. * @param scene defines the hosting scene
  29576. * @param rootUrl defines the root url for resources
  29577. * @returns a new entity
  29578. */
  29579. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29580. /**
  29581. * Clones an object
  29582. * @param creationFunction defines the function used to instanciate the new object
  29583. * @param source defines the source object
  29584. * @returns the cloned object
  29585. */
  29586. static Clone<T>(creationFunction: () => T, source: T): T;
  29587. /**
  29588. * Instanciates a new object based on a source one (some data will be shared between both object)
  29589. * @param creationFunction defines the function used to instanciate the new object
  29590. * @param source defines the source object
  29591. * @returns the new object
  29592. */
  29593. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29594. }
  29595. }
  29596. declare module BABYLON {
  29597. /**
  29598. * This is the base class of all the camera used in the application.
  29599. * @see http://doc.babylonjs.com/features/cameras
  29600. */
  29601. export class Camera extends Node {
  29602. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29603. /**
  29604. * This is the default projection mode used by the cameras.
  29605. * It helps recreating a feeling of perspective and better appreciate depth.
  29606. * This is the best way to simulate real life cameras.
  29607. */
  29608. static readonly PERSPECTIVE_CAMERA: number;
  29609. /**
  29610. * This helps creating camera with an orthographic mode.
  29611. * 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.
  29612. */
  29613. static readonly ORTHOGRAPHIC_CAMERA: number;
  29614. /**
  29615. * This is the default FOV mode for perspective cameras.
  29616. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29617. */
  29618. static readonly FOVMODE_VERTICAL_FIXED: number;
  29619. /**
  29620. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29621. */
  29622. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29623. /**
  29624. * This specifies ther is no need for a camera rig.
  29625. * Basically only one eye is rendered corresponding to the camera.
  29626. */
  29627. static readonly RIG_MODE_NONE: number;
  29628. /**
  29629. * Simulates a camera Rig with one blue eye and one red eye.
  29630. * This can be use with 3d blue and red glasses.
  29631. */
  29632. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29633. /**
  29634. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29635. */
  29636. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29637. /**
  29638. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29639. */
  29640. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29641. /**
  29642. * Defines that both eyes of the camera will be rendered over under each other.
  29643. */
  29644. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29645. /**
  29646. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29647. */
  29648. static readonly RIG_MODE_VR: number;
  29649. /**
  29650. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29651. */
  29652. static readonly RIG_MODE_WEBVR: number;
  29653. /**
  29654. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29655. */
  29656. static readonly RIG_MODE_CUSTOM: number;
  29657. /**
  29658. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29659. */
  29660. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29661. /**
  29662. * Define the input manager associated with the camera.
  29663. */
  29664. inputs: CameraInputsManager<Camera>;
  29665. /** @hidden */ position: Vector3;
  29666. /**
  29667. * Define the current local position of the camera in the scene
  29668. */
  29669. position: Vector3;
  29670. /**
  29671. * The vector the camera should consider as up.
  29672. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29673. */
  29674. upVector: Vector3;
  29675. /**
  29676. * Define the current limit on the left side for an orthographic camera
  29677. * In scene unit
  29678. */
  29679. orthoLeft: Nullable<number>;
  29680. /**
  29681. * Define the current limit on the right side for an orthographic camera
  29682. * In scene unit
  29683. */
  29684. orthoRight: Nullable<number>;
  29685. /**
  29686. * Define the current limit on the bottom side for an orthographic camera
  29687. * In scene unit
  29688. */
  29689. orthoBottom: Nullable<number>;
  29690. /**
  29691. * Define the current limit on the top side for an orthographic camera
  29692. * In scene unit
  29693. */
  29694. orthoTop: Nullable<number>;
  29695. /**
  29696. * Field Of View is set in Radians. (default is 0.8)
  29697. */
  29698. fov: number;
  29699. /**
  29700. * Define the minimum distance the camera can see from.
  29701. * This is important to note that the depth buffer are not infinite and the closer it starts
  29702. * the more your scene might encounter depth fighting issue.
  29703. */
  29704. minZ: number;
  29705. /**
  29706. * Define the maximum distance the camera can see to.
  29707. * This is important to note that the depth buffer are not infinite and the further it end
  29708. * the more your scene might encounter depth fighting issue.
  29709. */
  29710. maxZ: number;
  29711. /**
  29712. * Define the default inertia of the camera.
  29713. * This helps giving a smooth feeling to the camera movement.
  29714. */
  29715. inertia: number;
  29716. /**
  29717. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29718. */
  29719. mode: number;
  29720. /**
  29721. * Define wether the camera is intermediate.
  29722. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29723. */
  29724. isIntermediate: boolean;
  29725. /**
  29726. * Define the viewport of the camera.
  29727. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29728. */
  29729. viewport: Viewport;
  29730. /**
  29731. * Restricts the camera to viewing objects with the same layerMask.
  29732. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29733. */
  29734. layerMask: number;
  29735. /**
  29736. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29737. */
  29738. fovMode: number;
  29739. /**
  29740. * Rig mode of the camera.
  29741. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29742. * This is normally controlled byt the camera themselves as internal use.
  29743. */
  29744. cameraRigMode: number;
  29745. /**
  29746. * Defines the distance between both "eyes" in case of a RIG
  29747. */
  29748. interaxialDistance: number;
  29749. /**
  29750. * Defines if stereoscopic rendering is done side by side or over under.
  29751. */
  29752. isStereoscopicSideBySide: boolean;
  29753. /**
  29754. * 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
  29755. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29756. * else in the scene.
  29757. */
  29758. customRenderTargets: RenderTargetTexture[];
  29759. /**
  29760. * When set, the camera will render to this render target instead of the default canvas
  29761. */
  29762. outputRenderTarget: Nullable<RenderTargetTexture>;
  29763. /**
  29764. * Observable triggered when the camera view matrix has changed.
  29765. */
  29766. onViewMatrixChangedObservable: Observable<Camera>;
  29767. /**
  29768. * Observable triggered when the camera Projection matrix has changed.
  29769. */
  29770. onProjectionMatrixChangedObservable: Observable<Camera>;
  29771. /**
  29772. * Observable triggered when the inputs have been processed.
  29773. */
  29774. onAfterCheckInputsObservable: Observable<Camera>;
  29775. /**
  29776. * Observable triggered when reset has been called and applied to the camera.
  29777. */
  29778. onRestoreStateObservable: Observable<Camera>;
  29779. /** @hidden */ cameraRigParams: any;
  29780. /** @hidden */ rigCameras: Camera[];
  29781. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29782. protected _webvrViewMatrix: Matrix;
  29783. /** @hidden */ skipRendering: boolean;
  29784. /** @hidden */ projectionMatrix: Matrix;
  29785. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29786. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29787. protected _globalPosition: Vector3;
  29788. /** hidden */ computedViewMatrix: Matrix;
  29789. private _doNotComputeProjectionMatrix;
  29790. private _transformMatrix;
  29791. private _frustumPlanes;
  29792. private _refreshFrustumPlanes;
  29793. private _storedFov;
  29794. private _stateStored;
  29795. /**
  29796. * Instantiates a new camera object.
  29797. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29798. * @see http://doc.babylonjs.com/features/cameras
  29799. * @param name Defines the name of the camera in the scene
  29800. * @param position Defines the position of the camera
  29801. * @param scene Defines the scene the camera belongs too
  29802. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29803. */
  29804. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29805. /**
  29806. * Store current camera state (fov, position, etc..)
  29807. * @returns the camera
  29808. */
  29809. storeState(): Camera;
  29810. /**
  29811. * Restores the camera state values if it has been stored. You must call storeState() first
  29812. */
  29813. protected _restoreStateValues(): boolean;
  29814. /**
  29815. * Restored camera state. You must call storeState() first.
  29816. * @returns true if restored and false otherwise
  29817. */
  29818. restoreState(): boolean;
  29819. /**
  29820. * Gets the class name of the camera.
  29821. * @returns the class name
  29822. */
  29823. getClassName(): string;
  29824. /** @hidden */ protected readonly _isCamera: boolean;
  29825. /**
  29826. * Gets a string representation of the camera useful for debug purpose.
  29827. * @param fullDetails Defines that a more verboe level of logging is required
  29828. * @returns the string representation
  29829. */
  29830. toString(fullDetails?: boolean): string;
  29831. /**
  29832. * Gets the current world space position of the camera.
  29833. */
  29834. readonly globalPosition: Vector3;
  29835. /**
  29836. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29837. * @returns the active meshe list
  29838. */
  29839. getActiveMeshes(): SmartArray<AbstractMesh>;
  29840. /**
  29841. * Check wether a mesh is part of the current active mesh list of the camera
  29842. * @param mesh Defines the mesh to check
  29843. * @returns true if active, false otherwise
  29844. */
  29845. isActiveMesh(mesh: Mesh): boolean;
  29846. /**
  29847. * Is this camera ready to be used/rendered
  29848. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29849. * @return true if the camera is ready
  29850. */
  29851. isReady(completeCheck?: boolean): boolean;
  29852. /** @hidden */ initCache(): void;
  29853. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29854. /** @hidden */ isSynchronized(): boolean;
  29855. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29856. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29857. /**
  29858. * Attach the input controls to a specific dom element to get the input from.
  29859. * @param element Defines the element the controls should be listened from
  29860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29861. */
  29862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29863. /**
  29864. * Detach the current controls from the specified dom element.
  29865. * @param element Defines the element to stop listening the inputs from
  29866. */
  29867. detachControl(element: HTMLElement): void;
  29868. /**
  29869. * Update the camera state according to the different inputs gathered during the frame.
  29870. */
  29871. update(): void;
  29872. /** @hidden */ checkInputs(): void;
  29873. /** @hidden */
  29874. readonly rigCameras: Camera[];
  29875. /**
  29876. * Gets the post process used by the rig cameras
  29877. */
  29878. readonly rigPostProcess: Nullable<PostProcess>;
  29879. /**
  29880. * Internal, gets the first post proces.
  29881. * @returns the first post process to be run on this camera.
  29882. */ getFirstPostProcess(): Nullable<PostProcess>;
  29883. private _cascadePostProcessesToRigCams;
  29884. /**
  29885. * Attach a post process to the camera.
  29886. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29887. * @param postProcess The post process to attach to the camera
  29888. * @param insertAt The position of the post process in case several of them are in use in the scene
  29889. * @returns the position the post process has been inserted at
  29890. */
  29891. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29892. /**
  29893. * Detach a post process to the camera.
  29894. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29895. * @param postProcess The post process to detach from the camera
  29896. */
  29897. detachPostProcess(postProcess: PostProcess): void;
  29898. /**
  29899. * Gets the current world matrix of the camera
  29900. */
  29901. getWorldMatrix(): Matrix;
  29902. /** @hidden */ getViewMatrix(): Matrix;
  29903. /**
  29904. * Gets the current view matrix of the camera.
  29905. * @param force forces the camera to recompute the matrix without looking at the cached state
  29906. * @returns the view matrix
  29907. */
  29908. getViewMatrix(force?: boolean): Matrix;
  29909. /**
  29910. * Freeze the projection matrix.
  29911. * It will prevent the cache check of the camera projection compute and can speed up perf
  29912. * if no parameter of the camera are meant to change
  29913. * @param projection Defines manually a projection if necessary
  29914. */
  29915. freezeProjectionMatrix(projection?: Matrix): void;
  29916. /**
  29917. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29918. */
  29919. unfreezeProjectionMatrix(): void;
  29920. /**
  29921. * Gets the current projection matrix of the camera.
  29922. * @param force forces the camera to recompute the matrix without looking at the cached state
  29923. * @returns the projection matrix
  29924. */
  29925. getProjectionMatrix(force?: boolean): Matrix;
  29926. /**
  29927. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29928. * @returns a Matrix
  29929. */
  29930. getTransformationMatrix(): Matrix;
  29931. private _updateFrustumPlanes;
  29932. /**
  29933. * Checks if a cullable object (mesh...) is in the camera frustum
  29934. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29935. * @param target The object to check
  29936. * @returns true if the object is in frustum otherwise false
  29937. */
  29938. isInFrustum(target: ICullable): boolean;
  29939. /**
  29940. * Checks if a cullable object (mesh...) is in the camera frustum
  29941. * Unlike isInFrustum this cheks the full bounding box
  29942. * @param target The object to check
  29943. * @returns true if the object is in frustum otherwise false
  29944. */
  29945. isCompletelyInFrustum(target: ICullable): boolean;
  29946. /**
  29947. * Gets a ray in the forward direction from the camera.
  29948. * @param length Defines the length of the ray to create
  29949. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29950. * @param origin Defines the start point of the ray which defaults to the camera position
  29951. * @returns the forward ray
  29952. */
  29953. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29954. /**
  29955. * Releases resources associated with this node.
  29956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29958. */
  29959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29960. /** @hidden */ isLeftCamera: boolean;
  29961. /**
  29962. * Gets the left camera of a rig setup in case of Rigged Camera
  29963. */
  29964. readonly isLeftCamera: boolean;
  29965. /** @hidden */ isRightCamera: boolean;
  29966. /**
  29967. * Gets the right camera of a rig setup in case of Rigged Camera
  29968. */
  29969. readonly isRightCamera: boolean;
  29970. /**
  29971. * Gets the left camera of a rig setup in case of Rigged Camera
  29972. */
  29973. readonly leftCamera: Nullable<FreeCamera>;
  29974. /**
  29975. * Gets the right camera of a rig setup in case of Rigged Camera
  29976. */
  29977. readonly rightCamera: Nullable<FreeCamera>;
  29978. /**
  29979. * Gets the left camera target of a rig setup in case of Rigged Camera
  29980. * @returns the target position
  29981. */
  29982. getLeftTarget(): Nullable<Vector3>;
  29983. /**
  29984. * Gets the right camera target of a rig setup in case of Rigged Camera
  29985. * @returns the target position
  29986. */
  29987. getRightTarget(): Nullable<Vector3>;
  29988. /**
  29989. * @hidden
  29990. */
  29991. setCameraRigMode(mode: number, rigParams: any): void;
  29992. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29993. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29994. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29995. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29996. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29997. protected _updateCameraRotationMatrix(): void;
  29998. protected _updateWebVRCameraRotationMatrix(): void;
  29999. /**
  30000. * This function MUST be overwritten by the different WebVR cameras available.
  30001. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30002. * @hidden
  30003. */ getWebVRProjectionMatrix(): Matrix;
  30004. /**
  30005. * This function MUST be overwritten by the different WebVR cameras available.
  30006. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30007. * @hidden
  30008. */ getWebVRViewMatrix(): Matrix;
  30009. /** @hidden */
  30010. setCameraRigParameter(name: string, value: any): void;
  30011. /**
  30012. * needs to be overridden by children so sub has required properties to be copied
  30013. * @hidden
  30014. */
  30015. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30016. /**
  30017. * May need to be overridden by children
  30018. * @hidden
  30019. */ updateRigCameras(): void;
  30020. /** @hidden */ setupInputs(): void;
  30021. /**
  30022. * Serialiaze the camera setup to a json represention
  30023. * @returns the JSON representation
  30024. */
  30025. serialize(): any;
  30026. /**
  30027. * Clones the current camera.
  30028. * @param name The cloned camera name
  30029. * @returns the cloned camera
  30030. */
  30031. clone(name: string): Camera;
  30032. /**
  30033. * Gets the direction of the camera relative to a given local axis.
  30034. * @param localAxis Defines the reference axis to provide a relative direction.
  30035. * @return the direction
  30036. */
  30037. getDirection(localAxis: Vector3): Vector3;
  30038. /**
  30039. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30040. * @param localAxis Defines the reference axis to provide a relative direction.
  30041. * @param result Defines the vector to store the result in
  30042. */
  30043. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30044. /**
  30045. * Gets a camera constructor for a given camera type
  30046. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30047. * @param name The name of the camera the result will be able to instantiate
  30048. * @param scene The scene the result will construct the camera in
  30049. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30050. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30051. * @returns a factory method to construc the camera
  30052. */
  30053. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30054. /**
  30055. * Compute the world matrix of the camera.
  30056. * @returns the camera workd matrix
  30057. */
  30058. computeWorldMatrix(): Matrix;
  30059. /**
  30060. * Parse a JSON and creates the camera from the parsed information
  30061. * @param parsedCamera The JSON to parse
  30062. * @param scene The scene to instantiate the camera in
  30063. * @returns the newly constructed camera
  30064. */
  30065. static Parse(parsedCamera: any, scene: Scene): Camera;
  30066. }
  30067. }
  30068. declare module BABYLON {
  30069. /**
  30070. * Interface for any object that can request an animation frame
  30071. */
  30072. export interface ICustomAnimationFrameRequester {
  30073. /**
  30074. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30075. */
  30076. renderFunction?: Function;
  30077. /**
  30078. * Called to request the next frame to render to
  30079. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30080. */
  30081. requestAnimationFrame: Function;
  30082. /**
  30083. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30084. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30085. */
  30086. requestID?: number;
  30087. }
  30088. /**
  30089. * Interface containing an array of animations
  30090. */
  30091. export interface IAnimatable {
  30092. /**
  30093. * Array of animations
  30094. */
  30095. animations: Nullable<Array<Animation>>;
  30096. }
  30097. /** Interface used by value gradients (color, factor, ...) */
  30098. export interface IValueGradient {
  30099. /**
  30100. * Gets or sets the gradient value (between 0 and 1)
  30101. */
  30102. gradient: number;
  30103. }
  30104. /** Class used to store color4 gradient */
  30105. export class ColorGradient implements IValueGradient {
  30106. /**
  30107. * Gets or sets the gradient value (between 0 and 1)
  30108. */
  30109. gradient: number;
  30110. /**
  30111. * Gets or sets first associated color
  30112. */
  30113. color1: Color4;
  30114. /**
  30115. * Gets or sets second associated color
  30116. */
  30117. color2?: Color4;
  30118. /**
  30119. * Will get a color picked randomly between color1 and color2.
  30120. * If color2 is undefined then color1 will be used
  30121. * @param result defines the target Color4 to store the result in
  30122. */
  30123. getColorToRef(result: Color4): void;
  30124. }
  30125. /** Class used to store color 3 gradient */
  30126. export class Color3Gradient implements IValueGradient {
  30127. /**
  30128. * Gets or sets the gradient value (between 0 and 1)
  30129. */
  30130. gradient: number;
  30131. /**
  30132. * Gets or sets the associated color
  30133. */
  30134. color: Color3;
  30135. }
  30136. /** Class used to store factor gradient */
  30137. export class FactorGradient implements IValueGradient {
  30138. /**
  30139. * Gets or sets the gradient value (between 0 and 1)
  30140. */
  30141. gradient: number;
  30142. /**
  30143. * Gets or sets first associated factor
  30144. */
  30145. factor1: number;
  30146. /**
  30147. * Gets or sets second associated factor
  30148. */
  30149. factor2?: number;
  30150. /**
  30151. * Will get a number picked randomly between factor1 and factor2.
  30152. * If factor2 is undefined then factor1 will be used
  30153. * @returns the picked number
  30154. */
  30155. getFactor(): number;
  30156. }
  30157. /**
  30158. * @ignore
  30159. * Application error to support additional information when loading a file
  30160. */
  30161. export class LoadFileError extends Error {
  30162. /** defines the optional web request */
  30163. request?: WebRequest | undefined;
  30164. private static _setPrototypeOf;
  30165. /**
  30166. * Creates a new LoadFileError
  30167. * @param message defines the message of the error
  30168. * @param request defines the optional web request
  30169. */
  30170. constructor(message: string,
  30171. /** defines the optional web request */
  30172. request?: WebRequest | undefined);
  30173. }
  30174. /**
  30175. * Class used to define a retry strategy when error happens while loading assets
  30176. */
  30177. export class RetryStrategy {
  30178. /**
  30179. * Function used to defines an exponential back off strategy
  30180. * @param maxRetries defines the maximum number of retries (3 by default)
  30181. * @param baseInterval defines the interval between retries
  30182. * @returns the strategy function to use
  30183. */
  30184. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30185. }
  30186. /**
  30187. * File request interface
  30188. */
  30189. export interface IFileRequest {
  30190. /**
  30191. * Raised when the request is complete (success or error).
  30192. */
  30193. onCompleteObservable: Observable<IFileRequest>;
  30194. /**
  30195. * Aborts the request for a file.
  30196. */
  30197. abort: () => void;
  30198. }
  30199. /**
  30200. * Class containing a set of static utilities functions
  30201. */
  30202. export class Tools {
  30203. /**
  30204. * Gets or sets the base URL to use to load assets
  30205. */
  30206. static BaseUrl: string;
  30207. /**
  30208. * Enable/Disable Custom HTTP Request Headers globally.
  30209. * default = false
  30210. * @see CustomRequestHeaders
  30211. */
  30212. static UseCustomRequestHeaders: boolean;
  30213. /**
  30214. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30215. * i.e. when loading files, where the server/service expects an Authorization header
  30216. */
  30217. static CustomRequestHeaders: {
  30218. [key: string]: string;
  30219. };
  30220. /**
  30221. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30222. */
  30223. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30224. /**
  30225. * Default behaviour for cors in the application.
  30226. * It can be a string if the expected behavior is identical in the entire app.
  30227. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30228. */
  30229. static CorsBehavior: string | ((url: string | string[]) => string);
  30230. /**
  30231. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30232. * @ignorenaming
  30233. */
  30234. static UseFallbackTexture: boolean;
  30235. /**
  30236. * Use this object to register external classes like custom textures or material
  30237. * to allow the laoders to instantiate them
  30238. */
  30239. static RegisteredExternalClasses: {
  30240. [key: string]: Object;
  30241. };
  30242. /**
  30243. * Texture content used if a texture cannot loaded
  30244. * @ignorenaming
  30245. */
  30246. static fallbackTexture: string;
  30247. /**
  30248. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30249. * @param u defines the coordinate on X axis
  30250. * @param v defines the coordinate on Y axis
  30251. * @param width defines the width of the source data
  30252. * @param height defines the height of the source data
  30253. * @param pixels defines the source byte array
  30254. * @param color defines the output color
  30255. */
  30256. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30257. /**
  30258. * Interpolates between a and b via alpha
  30259. * @param a The lower value (returned when alpha = 0)
  30260. * @param b The upper value (returned when alpha = 1)
  30261. * @param alpha The interpolation-factor
  30262. * @return The mixed value
  30263. */
  30264. static Mix(a: number, b: number, alpha: number): number;
  30265. /**
  30266. * Tries to instantiate a new object from a given class name
  30267. * @param className defines the class name to instantiate
  30268. * @returns the new object or null if the system was not able to do the instantiation
  30269. */
  30270. static Instantiate(className: string): any;
  30271. /**
  30272. * Provides a slice function that will work even on IE
  30273. * @param data defines the array to slice
  30274. * @param start defines the start of the data (optional)
  30275. * @param end defines the end of the data (optional)
  30276. * @returns the new sliced array
  30277. */
  30278. static Slice<T>(data: T, start?: number, end?: number): T;
  30279. /**
  30280. * Polyfill for setImmediate
  30281. * @param action defines the action to execute after the current execution block
  30282. */
  30283. static SetImmediate(action: () => void): void;
  30284. /**
  30285. * Function indicating if a number is an exponent of 2
  30286. * @param value defines the value to test
  30287. * @returns true if the value is an exponent of 2
  30288. */
  30289. static IsExponentOfTwo(value: number): boolean;
  30290. private static _tmpFloatArray;
  30291. /**
  30292. * Returns the nearest 32-bit single precision float representation of a Number
  30293. * @param value A Number. If the parameter is of a different type, it will get converted
  30294. * to a number or to NaN if it cannot be converted
  30295. * @returns number
  30296. */
  30297. static FloatRound(value: number): number;
  30298. /**
  30299. * Find the next highest power of two.
  30300. * @param x Number to start search from.
  30301. * @return Next highest power of two.
  30302. */
  30303. static CeilingPOT(x: number): number;
  30304. /**
  30305. * Find the next lowest power of two.
  30306. * @param x Number to start search from.
  30307. * @return Next lowest power of two.
  30308. */
  30309. static FloorPOT(x: number): number;
  30310. /**
  30311. * Find the nearest power of two.
  30312. * @param x Number to start search from.
  30313. * @return Next nearest power of two.
  30314. */
  30315. static NearestPOT(x: number): number;
  30316. /**
  30317. * Get the closest exponent of two
  30318. * @param value defines the value to approximate
  30319. * @param max defines the maximum value to return
  30320. * @param mode defines how to define the closest value
  30321. * @returns closest exponent of two of the given value
  30322. */
  30323. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30324. /**
  30325. * Extracts the filename from a path
  30326. * @param path defines the path to use
  30327. * @returns the filename
  30328. */
  30329. static GetFilename(path: string): string;
  30330. /**
  30331. * Extracts the "folder" part of a path (everything before the filename).
  30332. * @param uri The URI to extract the info from
  30333. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30334. * @returns The "folder" part of the path
  30335. */
  30336. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30337. /**
  30338. * Extracts text content from a DOM element hierarchy
  30339. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30340. */
  30341. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30342. /**
  30343. * Convert an angle in radians to degrees
  30344. * @param angle defines the angle to convert
  30345. * @returns the angle in degrees
  30346. */
  30347. static ToDegrees(angle: number): number;
  30348. /**
  30349. * Convert an angle in degrees to radians
  30350. * @param angle defines the angle to convert
  30351. * @returns the angle in radians
  30352. */
  30353. static ToRadians(angle: number): number;
  30354. /**
  30355. * Encode a buffer to a base64 string
  30356. * @param buffer defines the buffer to encode
  30357. * @returns the encoded string
  30358. */
  30359. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30360. /**
  30361. * Extracts minimum and maximum values from a list of indexed positions
  30362. * @param positions defines the positions to use
  30363. * @param indices defines the indices to the positions
  30364. * @param indexStart defines the start index
  30365. * @param indexCount defines the end index
  30366. * @param bias defines bias value to add to the result
  30367. * @return minimum and maximum values
  30368. */
  30369. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30370. minimum: Vector3;
  30371. maximum: Vector3;
  30372. };
  30373. /**
  30374. * Extracts minimum and maximum values from a list of positions
  30375. * @param positions defines the positions to use
  30376. * @param start defines the start index in the positions array
  30377. * @param count defines the number of positions to handle
  30378. * @param bias defines bias value to add to the result
  30379. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30380. * @return minimum and maximum values
  30381. */
  30382. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30383. minimum: Vector3;
  30384. maximum: Vector3;
  30385. };
  30386. /**
  30387. * Returns an array if obj is not an array
  30388. * @param obj defines the object to evaluate as an array
  30389. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30390. * @returns either obj directly if obj is an array or a new array containing obj
  30391. */
  30392. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30393. /**
  30394. * Gets the pointer prefix to use
  30395. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30396. */
  30397. static GetPointerPrefix(): string;
  30398. /**
  30399. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30400. * @param func - the function to be called
  30401. * @param requester - the object that will request the next frame. Falls back to window.
  30402. * @returns frame number
  30403. */
  30404. static QueueNewFrame(func: () => void, requester?: any): number;
  30405. /**
  30406. * Ask the browser to promote the current element to fullscreen rendering mode
  30407. * @param element defines the DOM element to promote
  30408. */
  30409. static RequestFullscreen(element: HTMLElement): void;
  30410. /**
  30411. * Asks the browser to exit fullscreen mode
  30412. */
  30413. static ExitFullscreen(): void;
  30414. /**
  30415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30416. * @param url define the url we are trying
  30417. * @param element define the dom element where to configure the cors policy
  30418. */
  30419. static SetCorsBehavior(url: string | string[], element: {
  30420. crossOrigin: string | null;
  30421. }): void;
  30422. /**
  30423. * Removes unwanted characters from an url
  30424. * @param url defines the url to clean
  30425. * @returns the cleaned url
  30426. */
  30427. static CleanUrl(url: string): string;
  30428. /**
  30429. * Gets or sets a function used to pre-process url before using them to load assets
  30430. */
  30431. static PreprocessUrl: (url: string) => string;
  30432. /**
  30433. * Loads an image as an HTMLImageElement.
  30434. * @param input url string, ArrayBuffer, or Blob to load
  30435. * @param onLoad callback called when the image successfully loads
  30436. * @param onError callback called when the image fails to load
  30437. * @param offlineProvider offline provider for caching
  30438. * @returns the HTMLImageElement of the loaded image
  30439. */
  30440. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30441. /**
  30442. * Loads a file
  30443. * @param url url string, ArrayBuffer, or Blob to load
  30444. * @param onSuccess callback called when the file successfully loads
  30445. * @param onProgress callback called while file is loading (if the server supports this mode)
  30446. * @param offlineProvider defines the offline provider for caching
  30447. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30448. * @param onError callback called when the file fails to load
  30449. * @returns a file request object
  30450. */
  30451. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30452. /**
  30453. * Load a script (identified by an url). When the url returns, the
  30454. * content of this file is added into a new script element, attached to the DOM (body element)
  30455. * @param scriptUrl defines the url of the script to laod
  30456. * @param onSuccess defines the callback called when the script is loaded
  30457. * @param onError defines the callback to call if an error occurs
  30458. * @param scriptId defines the id of the script element
  30459. */
  30460. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30461. /**
  30462. * Load an asynchronous script (identified by an url). When the url returns, the
  30463. * content of this file is added into a new script element, attached to the DOM (body element)
  30464. * @param scriptUrl defines the url of the script to laod
  30465. * @param scriptId defines the id of the script element
  30466. * @returns a promise request object
  30467. */
  30468. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30469. /**
  30470. * Loads a file from a blob
  30471. * @param fileToLoad defines the blob to use
  30472. * @param callback defines the callback to call when data is loaded
  30473. * @param progressCallback defines the callback to call during loading process
  30474. * @returns a file request object
  30475. */
  30476. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30477. /**
  30478. * Loads a file
  30479. * @param fileToLoad defines the file to load
  30480. * @param callback defines the callback to call when data is loaded
  30481. * @param progressCallBack defines the callback to call during loading process
  30482. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30483. * @returns a file request object
  30484. */
  30485. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30486. /**
  30487. * Creates a data url from a given string content
  30488. * @param content defines the content to convert
  30489. * @returns the new data url link
  30490. */
  30491. static FileAsURL(content: string): string;
  30492. /**
  30493. * Format the given number to a specific decimal format
  30494. * @param value defines the number to format
  30495. * @param decimals defines the number of decimals to use
  30496. * @returns the formatted string
  30497. */
  30498. static Format(value: number, decimals?: number): string;
  30499. /**
  30500. * Checks if a given vector is inside a specific range
  30501. * @param v defines the vector to test
  30502. * @param min defines the minimum range
  30503. * @param max defines the maximum range
  30504. */
  30505. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30506. /**
  30507. * Tries to copy an object by duplicating every property
  30508. * @param source defines the source object
  30509. * @param destination defines the target object
  30510. * @param doNotCopyList defines a list of properties to avoid
  30511. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30512. */
  30513. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30514. /**
  30515. * Gets a boolean indicating if the given object has no own property
  30516. * @param obj defines the object to test
  30517. * @returns true if object has no own property
  30518. */
  30519. static IsEmpty(obj: any): boolean;
  30520. /**
  30521. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30522. * @param str Source string
  30523. * @param suffix Suffix to search for in the source string
  30524. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30525. */
  30526. static EndsWith(str: string, suffix: string): boolean;
  30527. /**
  30528. * Function used to register events at window level
  30529. * @param events defines the events to register
  30530. */
  30531. static RegisterTopRootEvents(events: {
  30532. name: string;
  30533. handler: Nullable<(e: FocusEvent) => any>;
  30534. }[]): void;
  30535. /**
  30536. * Function used to unregister events from window level
  30537. * @param events defines the events to unregister
  30538. */
  30539. static UnregisterTopRootEvents(events: {
  30540. name: string;
  30541. handler: Nullable<(e: FocusEvent) => any>;
  30542. }[]): void;
  30543. /**
  30544. * @ignore
  30545. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30546. /**
  30547. * Dumps the current bound framebuffer
  30548. * @param width defines the rendering width
  30549. * @param height defines the rendering height
  30550. * @param engine defines the hosting engine
  30551. * @param successCallback defines the callback triggered once the data are available
  30552. * @param mimeType defines the mime type of the result
  30553. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30554. */
  30555. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30556. /**
  30557. * Converts the canvas data to blob.
  30558. * This acts as a polyfill for browsers not supporting the to blob function.
  30559. * @param canvas Defines the canvas to extract the data from
  30560. * @param successCallback Defines the callback triggered once the data are available
  30561. * @param mimeType Defines the mime type of the result
  30562. */
  30563. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30564. /**
  30565. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30566. * @param successCallback defines the callback triggered once the data are available
  30567. * @param mimeType defines the mime type of the result
  30568. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30569. */
  30570. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30571. /**
  30572. * Downloads a blob in the browser
  30573. * @param blob defines the blob to download
  30574. * @param fileName defines the name of the downloaded file
  30575. */
  30576. static Download(blob: Blob, fileName: string): void;
  30577. /**
  30578. * Captures a screenshot of the current rendering
  30579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30580. * @param engine defines the rendering engine
  30581. * @param camera defines the source camera
  30582. * @param size This parameter can be set to a single number or to an object with the
  30583. * following (optional) properties: precision, width, height. If a single number is passed,
  30584. * it will be used for both width and height. If an object is passed, the screenshot size
  30585. * will be derived from the parameters. The precision property is a multiplier allowing
  30586. * rendering at a higher or lower resolution
  30587. * @param successCallback defines the callback receives a single parameter which contains the
  30588. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30589. * src parameter of an <img> to display it
  30590. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30591. * Check your browser for supported MIME types
  30592. */
  30593. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30594. /**
  30595. * Generates an image screenshot from the specified camera.
  30596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30597. * @param engine The engine to use for rendering
  30598. * @param camera The camera to use for rendering
  30599. * @param size This parameter can be set to a single number or to an object with the
  30600. * following (optional) properties: precision, width, height. If a single number is passed,
  30601. * it will be used for both width and height. If an object is passed, the screenshot size
  30602. * will be derived from the parameters. The precision property is a multiplier allowing
  30603. * rendering at a higher or lower resolution
  30604. * @param successCallback The callback receives a single parameter which contains the
  30605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30606. * src parameter of an <img> to display it
  30607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30608. * Check your browser for supported MIME types
  30609. * @param samples Texture samples (default: 1)
  30610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30611. * @param fileName A name for for the downloaded file.
  30612. */
  30613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30614. /**
  30615. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30616. * Be aware Math.random() could cause collisions, but:
  30617. * "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"
  30618. * @returns a pseudo random id
  30619. */
  30620. static RandomId(): string;
  30621. /**
  30622. * Test if the given uri is a base64 string
  30623. * @param uri The uri to test
  30624. * @return True if the uri is a base64 string or false otherwise
  30625. */
  30626. static IsBase64(uri: string): boolean;
  30627. /**
  30628. * Decode the given base64 uri.
  30629. * @param uri The uri to decode
  30630. * @return The decoded base64 data.
  30631. */
  30632. static DecodeBase64(uri: string): ArrayBuffer;
  30633. /**
  30634. * Gets the absolute url.
  30635. * @param url the input url
  30636. * @return the absolute url
  30637. */
  30638. static GetAbsoluteUrl(url: string): string;
  30639. /**
  30640. * No log
  30641. */
  30642. static readonly NoneLogLevel: number;
  30643. /**
  30644. * Only message logs
  30645. */
  30646. static readonly MessageLogLevel: number;
  30647. /**
  30648. * Only warning logs
  30649. */
  30650. static readonly WarningLogLevel: number;
  30651. /**
  30652. * Only error logs
  30653. */
  30654. static readonly ErrorLogLevel: number;
  30655. /**
  30656. * All logs
  30657. */
  30658. static readonly AllLogLevel: number;
  30659. /**
  30660. * Gets a value indicating the number of loading errors
  30661. * @ignorenaming
  30662. */
  30663. static readonly errorsCount: number;
  30664. /**
  30665. * Callback called when a new log is added
  30666. */
  30667. static OnNewCacheEntry: (entry: string) => void;
  30668. /**
  30669. * Log a message to the console
  30670. * @param message defines the message to log
  30671. */
  30672. static Log(message: string): void;
  30673. /**
  30674. * Write a warning message to the console
  30675. * @param message defines the message to log
  30676. */
  30677. static Warn(message: string): void;
  30678. /**
  30679. * Write an error message to the console
  30680. * @param message defines the message to log
  30681. */
  30682. static Error(message: string): void;
  30683. /**
  30684. * Gets current log cache (list of logs)
  30685. */
  30686. static readonly LogCache: string;
  30687. /**
  30688. * Clears the log cache
  30689. */
  30690. static ClearLogCache(): void;
  30691. /**
  30692. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30693. */
  30694. static LogLevels: number;
  30695. /**
  30696. * Checks if the loaded document was accessed via `file:`-Protocol.
  30697. * @returns boolean
  30698. */
  30699. static IsFileURL(): boolean;
  30700. /**
  30701. * Checks if the window object exists
  30702. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30703. */
  30704. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30705. /**
  30706. * No performance log
  30707. */
  30708. static readonly PerformanceNoneLogLevel: number;
  30709. /**
  30710. * Use user marks to log performance
  30711. */
  30712. static readonly PerformanceUserMarkLogLevel: number;
  30713. /**
  30714. * Log performance to the console
  30715. */
  30716. static readonly PerformanceConsoleLogLevel: number;
  30717. private static _performance;
  30718. /**
  30719. * Sets the current performance log level
  30720. */
  30721. static PerformanceLogLevel: number;
  30722. private static _StartPerformanceCounterDisabled;
  30723. private static _EndPerformanceCounterDisabled;
  30724. private static _StartUserMark;
  30725. private static _EndUserMark;
  30726. private static _StartPerformanceConsole;
  30727. private static _EndPerformanceConsole;
  30728. /**
  30729. * Starts a performance counter
  30730. */
  30731. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30732. /**
  30733. * Ends a specific performance coutner
  30734. */
  30735. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30736. /**
  30737. * Gets either window.performance.now() if supported or Date.now() else
  30738. */
  30739. static readonly Now: number;
  30740. /**
  30741. * This method will return the name of the class used to create the instance of the given object.
  30742. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30743. * @param object the object to get the class name from
  30744. * @param isType defines if the object is actually a type
  30745. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30746. */
  30747. static GetClassName(object: any, isType?: boolean): string;
  30748. /**
  30749. * Gets the first element of an array satisfying a given predicate
  30750. * @param array defines the array to browse
  30751. * @param predicate defines the predicate to use
  30752. * @returns null if not found or the element
  30753. */
  30754. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30755. /**
  30756. * This method will return the name of the full name of the class, including its owning module (if any).
  30757. * 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).
  30758. * @param object the object to get the class name from
  30759. * @param isType defines if the object is actually a type
  30760. * @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.
  30761. * @ignorenaming
  30762. */
  30763. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30764. /**
  30765. * Returns a promise that resolves after the given amount of time.
  30766. * @param delay Number of milliseconds to delay
  30767. * @returns Promise that resolves after the given amount of time
  30768. */
  30769. static DelayAsync(delay: number): Promise<void>;
  30770. /**
  30771. * Gets the current gradient from an array of IValueGradient
  30772. * @param ratio defines the current ratio to get
  30773. * @param gradients defines the array of IValueGradient
  30774. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30775. */
  30776. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30777. }
  30778. /**
  30779. * This class is used to track a performance counter which is number based.
  30780. * The user has access to many properties which give statistics of different nature.
  30781. *
  30782. * The implementer can track two kinds of Performance Counter: time and count.
  30783. * 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.
  30784. * 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.
  30785. */
  30786. export class PerfCounter {
  30787. /**
  30788. * Gets or sets a global boolean to turn on and off all the counters
  30789. */
  30790. static Enabled: boolean;
  30791. /**
  30792. * Returns the smallest value ever
  30793. */
  30794. readonly min: number;
  30795. /**
  30796. * Returns the biggest value ever
  30797. */
  30798. readonly max: number;
  30799. /**
  30800. * Returns the average value since the performance counter is running
  30801. */
  30802. readonly average: number;
  30803. /**
  30804. * Returns the average value of the last second the counter was monitored
  30805. */
  30806. readonly lastSecAverage: number;
  30807. /**
  30808. * Returns the current value
  30809. */
  30810. readonly current: number;
  30811. /**
  30812. * Gets the accumulated total
  30813. */
  30814. readonly total: number;
  30815. /**
  30816. * Gets the total value count
  30817. */
  30818. readonly count: number;
  30819. /**
  30820. * Creates a new counter
  30821. */
  30822. constructor();
  30823. /**
  30824. * Call this method to start monitoring a new frame.
  30825. * 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.
  30826. */
  30827. fetchNewFrame(): void;
  30828. /**
  30829. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30830. * @param newCount the count value to add to the monitored count
  30831. * @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.
  30832. */
  30833. addCount(newCount: number, fetchResult: boolean): void;
  30834. /**
  30835. * Start monitoring this performance counter
  30836. */
  30837. beginMonitoring(): void;
  30838. /**
  30839. * Compute the time lapsed since the previous beginMonitoring() call.
  30840. * @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
  30841. */
  30842. endMonitoring(newFrame?: boolean): void;
  30843. private _fetchResult;
  30844. private _startMonitoringTime;
  30845. private _min;
  30846. private _max;
  30847. private _average;
  30848. private _current;
  30849. private _totalValueCount;
  30850. private _totalAccumulated;
  30851. private _lastSecAverage;
  30852. private _lastSecAccumulated;
  30853. private _lastSecTime;
  30854. private _lastSecValueCount;
  30855. }
  30856. /**
  30857. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30858. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30859. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30860. * @param name The name of the class, case should be preserved
  30861. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30862. */
  30863. export function className(name: string, module?: string): (target: Object) => void;
  30864. /**
  30865. * An implementation of a loop for asynchronous functions.
  30866. */
  30867. export class AsyncLoop {
  30868. /**
  30869. * Defines the number of iterations for the loop
  30870. */
  30871. iterations: number;
  30872. /**
  30873. * Defines the current index of the loop.
  30874. */
  30875. index: number;
  30876. private _done;
  30877. private _fn;
  30878. private _successCallback;
  30879. /**
  30880. * Constructor.
  30881. * @param iterations the number of iterations.
  30882. * @param func the function to run each iteration
  30883. * @param successCallback the callback that will be called upon succesful execution
  30884. * @param offset starting offset.
  30885. */
  30886. constructor(
  30887. /**
  30888. * Defines the number of iterations for the loop
  30889. */
  30890. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30891. /**
  30892. * Execute the next iteration. Must be called after the last iteration was finished.
  30893. */
  30894. executeNext(): void;
  30895. /**
  30896. * Break the loop and run the success callback.
  30897. */
  30898. breakLoop(): void;
  30899. /**
  30900. * Create and run an async loop.
  30901. * @param iterations the number of iterations.
  30902. * @param fn the function to run each iteration
  30903. * @param successCallback the callback that will be called upon succesful execution
  30904. * @param offset starting offset.
  30905. * @returns the created async loop object
  30906. */
  30907. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30908. /**
  30909. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30910. * @param iterations total number of iterations
  30911. * @param syncedIterations number of synchronous iterations in each async iteration.
  30912. * @param fn the function to call each iteration.
  30913. * @param callback a success call back that will be called when iterating stops.
  30914. * @param breakFunction a break condition (optional)
  30915. * @param timeout timeout settings for the setTimeout function. default - 0.
  30916. * @returns the created async loop object
  30917. */
  30918. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30919. }
  30920. }
  30921. declare module BABYLON {
  30922. /** @hidden */
  30923. export interface ICollisionCoordinator {
  30924. createCollider(): Collider;
  30925. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30926. init(scene: Scene): void;
  30927. }
  30928. /** @hidden */
  30929. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30930. private _scene;
  30931. private _scaledPosition;
  30932. private _scaledVelocity;
  30933. private _finalPosition;
  30934. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30935. createCollider(): Collider;
  30936. init(scene: Scene): void;
  30937. private _collideWithWorld;
  30938. }
  30939. }
  30940. declare module BABYLON {
  30941. /**
  30942. * Class used to manage all inputs for the scene.
  30943. */
  30944. export class InputManager {
  30945. /** The distance in pixel that you have to move to prevent some events */
  30946. static DragMovementThreshold: number;
  30947. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30948. static LongPressDelay: number;
  30949. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30950. static DoubleClickDelay: number;
  30951. /** If you need to check double click without raising a single click at first click, enable this flag */
  30952. static ExclusiveDoubleClickMode: boolean;
  30953. private _wheelEventName;
  30954. private _onPointerMove;
  30955. private _onPointerDown;
  30956. private _onPointerUp;
  30957. private _initClickEvent;
  30958. private _initActionManager;
  30959. private _delayedSimpleClick;
  30960. private _delayedSimpleClickTimeout;
  30961. private _previousDelayedSimpleClickTimeout;
  30962. private _meshPickProceed;
  30963. private _previousButtonPressed;
  30964. private _currentPickResult;
  30965. private _previousPickResult;
  30966. private _totalPointersPressed;
  30967. private _doubleClickOccured;
  30968. private _pointerOverMesh;
  30969. private _pickedDownMesh;
  30970. private _pickedUpMesh;
  30971. private _pointerX;
  30972. private _pointerY;
  30973. private _unTranslatedPointerX;
  30974. private _unTranslatedPointerY;
  30975. private _startingPointerPosition;
  30976. private _previousStartingPointerPosition;
  30977. private _startingPointerTime;
  30978. private _previousStartingPointerTime;
  30979. private _pointerCaptures;
  30980. private _onKeyDown;
  30981. private _onKeyUp;
  30982. private _onCanvasFocusObserver;
  30983. private _onCanvasBlurObserver;
  30984. private _scene;
  30985. /**
  30986. * Creates a new InputManager
  30987. * @param scene defines the hosting scene
  30988. */
  30989. constructor(scene: Scene);
  30990. /**
  30991. * Gets the mesh that is currently under the pointer
  30992. */
  30993. readonly meshUnderPointer: Nullable<AbstractMesh>;
  30994. /**
  30995. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  30996. */
  30997. readonly unTranslatedPointer: Vector2;
  30998. /**
  30999. * Gets or sets the current on-screen X position of the pointer
  31000. */
  31001. pointerX: number;
  31002. /**
  31003. * Gets or sets the current on-screen Y position of the pointer
  31004. */
  31005. pointerY: number;
  31006. private _updatePointerPosition;
  31007. private _processPointerMove;
  31008. private _setRayOnPointerInfo;
  31009. private _checkPrePointerObservable;
  31010. /**
  31011. * Use this method to simulate a pointer move on a mesh
  31012. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31013. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31014. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31015. */
  31016. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31017. /**
  31018. * Use this method to simulate a pointer down on a mesh
  31019. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31020. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31021. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31022. */
  31023. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31024. private _processPointerDown;
  31025. /** @hidden */ isPointerSwiping(): boolean;
  31026. /**
  31027. * Use this method to simulate a pointer up on a mesh
  31028. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31029. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31030. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31031. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31032. */
  31033. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31034. private _processPointerUp;
  31035. /**
  31036. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31037. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31038. * @returns true if the pointer was captured
  31039. */
  31040. isPointerCaptured(pointerId?: number): boolean;
  31041. /**
  31042. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31043. * @param attachUp defines if you want to attach events to pointerup
  31044. * @param attachDown defines if you want to attach events to pointerdown
  31045. * @param attachMove defines if you want to attach events to pointermove
  31046. */
  31047. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31048. /**
  31049. * Detaches all event handlers
  31050. */
  31051. detachControl(): void;
  31052. /**
  31053. * Force the value of meshUnderPointer
  31054. * @param mesh defines the mesh to use
  31055. */
  31056. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31057. /**
  31058. * Gets the mesh under the pointer
  31059. * @returns a Mesh or null if no mesh is under the pointer
  31060. */
  31061. getPointerOverMesh(): Nullable<AbstractMesh>;
  31062. }
  31063. }
  31064. declare module BABYLON {
  31065. /**
  31066. * This class defines the direct association between an animation and a target
  31067. */
  31068. export class TargetedAnimation {
  31069. /**
  31070. * Animation to perform
  31071. */
  31072. animation: Animation;
  31073. /**
  31074. * Target to animate
  31075. */
  31076. target: any;
  31077. }
  31078. /**
  31079. * Use this class to create coordinated animations on multiple targets
  31080. */
  31081. export class AnimationGroup implements IDisposable {
  31082. /** The name of the animation group */
  31083. name: string;
  31084. private _scene;
  31085. private _targetedAnimations;
  31086. private _animatables;
  31087. private _from;
  31088. private _to;
  31089. private _isStarted;
  31090. private _isPaused;
  31091. private _speedRatio;
  31092. /**
  31093. * Gets or sets the unique id of the node
  31094. */
  31095. uniqueId: number;
  31096. /**
  31097. * This observable will notify when one animation have ended
  31098. */
  31099. onAnimationEndObservable: Observable<TargetedAnimation>;
  31100. /**
  31101. * Observer raised when one animation loops
  31102. */
  31103. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31104. /**
  31105. * This observable will notify when all animations have ended.
  31106. */
  31107. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31108. /**
  31109. * This observable will notify when all animations have paused.
  31110. */
  31111. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31112. /**
  31113. * This observable will notify when all animations are playing.
  31114. */
  31115. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31116. /**
  31117. * Gets the first frame
  31118. */
  31119. readonly from: number;
  31120. /**
  31121. * Gets the last frame
  31122. */
  31123. readonly to: number;
  31124. /**
  31125. * Define if the animations are started
  31126. */
  31127. readonly isStarted: boolean;
  31128. /**
  31129. * Gets a value indicating that the current group is playing
  31130. */
  31131. readonly isPlaying: boolean;
  31132. /**
  31133. * Gets or sets the speed ratio to use for all animations
  31134. */
  31135. /**
  31136. * Gets or sets the speed ratio to use for all animations
  31137. */
  31138. speedRatio: number;
  31139. /**
  31140. * Gets the targeted animations for this animation group
  31141. */
  31142. readonly targetedAnimations: Array<TargetedAnimation>;
  31143. /**
  31144. * returning the list of animatables controlled by this animation group.
  31145. */
  31146. readonly animatables: Array<Animatable>;
  31147. /**
  31148. * Instantiates a new Animation Group.
  31149. * This helps managing several animations at once.
  31150. * @see http://doc.babylonjs.com/how_to/group
  31151. * @param name Defines the name of the group
  31152. * @param scene Defines the scene the group belongs to
  31153. */
  31154. constructor(
  31155. /** The name of the animation group */
  31156. name: string, scene?: Nullable<Scene>);
  31157. /**
  31158. * Add an animation (with its target) in the group
  31159. * @param animation defines the animation we want to add
  31160. * @param target defines the target of the animation
  31161. * @returns the TargetedAnimation object
  31162. */
  31163. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31164. /**
  31165. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31166. * It can add constant keys at begin or end
  31167. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31168. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31169. * @returns the animation group
  31170. */
  31171. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31172. /**
  31173. * Start all animations on given targets
  31174. * @param loop defines if animations must loop
  31175. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31176. * @param from defines the from key (optional)
  31177. * @param to defines the to key (optional)
  31178. * @returns the current animation group
  31179. */
  31180. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31181. /**
  31182. * Pause all animations
  31183. * @returns the animation group
  31184. */
  31185. pause(): AnimationGroup;
  31186. /**
  31187. * Play all animations to initial state
  31188. * This function will start() the animations if they were not started or will restart() them if they were paused
  31189. * @param loop defines if animations must loop
  31190. * @returns the animation group
  31191. */
  31192. play(loop?: boolean): AnimationGroup;
  31193. /**
  31194. * Reset all animations to initial state
  31195. * @returns the animation group
  31196. */
  31197. reset(): AnimationGroup;
  31198. /**
  31199. * Restart animations from key 0
  31200. * @returns the animation group
  31201. */
  31202. restart(): AnimationGroup;
  31203. /**
  31204. * Stop all animations
  31205. * @returns the animation group
  31206. */
  31207. stop(): AnimationGroup;
  31208. /**
  31209. * Set animation weight for all animatables
  31210. * @param weight defines the weight to use
  31211. * @return the animationGroup
  31212. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31213. */
  31214. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31215. /**
  31216. * Synchronize and normalize all animatables with a source animatable
  31217. * @param root defines the root animatable to synchronize with
  31218. * @return the animationGroup
  31219. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31220. */
  31221. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31222. /**
  31223. * Goes to a specific frame in this animation group
  31224. * @param frame the frame number to go to
  31225. * @return the animationGroup
  31226. */
  31227. goToFrame(frame: number): AnimationGroup;
  31228. /**
  31229. * Dispose all associated resources
  31230. */
  31231. dispose(): void;
  31232. private _checkAnimationGroupEnded;
  31233. /**
  31234. * Clone the current animation group and returns a copy
  31235. * @param newName defines the name of the new group
  31236. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31237. * @returns the new aniamtion group
  31238. */
  31239. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31240. /**
  31241. * Returns a new AnimationGroup object parsed from the source provided.
  31242. * @param parsedAnimationGroup defines the source
  31243. * @param scene defines the scene that will receive the animationGroup
  31244. * @returns a new AnimationGroup
  31245. */
  31246. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31247. /**
  31248. * Returns the string "AnimationGroup"
  31249. * @returns "AnimationGroup"
  31250. */
  31251. getClassName(): string;
  31252. /**
  31253. * Creates a detailled string about the object
  31254. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31255. * @returns a string representing the object
  31256. */
  31257. toString(fullDetails?: boolean): string;
  31258. }
  31259. }
  31260. declare module BABYLON {
  31261. /**
  31262. * Define an interface for all classes that will hold resources
  31263. */
  31264. export interface IDisposable {
  31265. /**
  31266. * Releases all held resources
  31267. */
  31268. dispose(): void;
  31269. }
  31270. /** Interface defining initialization parameters for Scene class */
  31271. export interface SceneOptions {
  31272. /**
  31273. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31274. * It will improve performance when the number of geometries becomes important.
  31275. */
  31276. useGeometryUniqueIdsMap?: boolean;
  31277. /**
  31278. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31279. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31280. */
  31281. useMaterialMeshMap?: boolean;
  31282. /**
  31283. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31284. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31285. */
  31286. useClonedMeshhMap?: boolean;
  31287. }
  31288. /**
  31289. * Represents a scene to be rendered by the engine.
  31290. * @see http://doc.babylonjs.com/features/scene
  31291. */
  31292. export class Scene extends AbstractScene implements IAnimatable {
  31293. private static _uniqueIdCounter;
  31294. /** The fog is deactivated */
  31295. static readonly FOGMODE_NONE: number;
  31296. /** The fog density is following an exponential function */
  31297. static readonly FOGMODE_EXP: number;
  31298. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31299. static readonly FOGMODE_EXP2: number;
  31300. /** The fog density is following a linear function. */
  31301. static readonly FOGMODE_LINEAR: number;
  31302. /**
  31303. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31305. */
  31306. static MinDeltaTime: number;
  31307. /**
  31308. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31310. */
  31311. static MaxDeltaTime: number;
  31312. /**
  31313. * Factory used to create the default material.
  31314. * @param name The name of the material to create
  31315. * @param scene The scene to create the material for
  31316. * @returns The default material
  31317. */
  31318. static DefaultMaterialFactory(scene: Scene): Material;
  31319. /**
  31320. * Factory used to create the a collision coordinator.
  31321. * @returns The collision coordinator
  31322. */
  31323. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31324. /** @hidden */ inputManager: InputManager;
  31325. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31326. cameraToUseForPointers: Nullable<Camera>;
  31327. /** @hidden */ protected readonly _isScene: boolean;
  31328. /**
  31329. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31330. */
  31331. autoClear: boolean;
  31332. /**
  31333. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31334. */
  31335. autoClearDepthAndStencil: boolean;
  31336. /**
  31337. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31338. */
  31339. clearColor: Color4;
  31340. /**
  31341. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31342. */
  31343. ambientColor: Color3;
  31344. /**
  31345. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31346. * It should only be one of the following (if not the default embedded one):
  31347. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31348. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31349. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31350. * The material properties need to be setup according to the type of texture in use.
  31351. */
  31352. environmentBRDFTexture: BaseTexture;
  31353. /** @hidden */
  31354. protected _environmentTexture: Nullable<BaseTexture>;
  31355. /**
  31356. * Texture used in all pbr material as the reflection texture.
  31357. * As in the majority of the scene they are the same (exception for multi room and so on),
  31358. * this is easier to reference from here than from all the materials.
  31359. */
  31360. /**
  31361. * Texture used in all pbr material as the reflection texture.
  31362. * As in the majority of the scene they are the same (exception for multi room and so on),
  31363. * this is easier to set here than in all the materials.
  31364. */
  31365. environmentTexture: Nullable<BaseTexture>;
  31366. /** @hidden */
  31367. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31368. /**
  31369. * Default image processing configuration used either in the rendering
  31370. * Forward main pass or through the imageProcessingPostProcess if present.
  31371. * As in the majority of the scene they are the same (exception for multi camera),
  31372. * this is easier to reference from here than from all the materials and post process.
  31373. *
  31374. * No setter as we it is a shared configuration, you can set the values instead.
  31375. */
  31376. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31377. private _forceWireframe;
  31378. /**
  31379. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31380. */
  31381. forceWireframe: boolean;
  31382. private _forcePointsCloud;
  31383. /**
  31384. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31385. */
  31386. forcePointsCloud: boolean;
  31387. /**
  31388. * Gets or sets the active clipplane 1
  31389. */
  31390. clipPlane: Nullable<Plane>;
  31391. /**
  31392. * Gets or sets the active clipplane 2
  31393. */
  31394. clipPlane2: Nullable<Plane>;
  31395. /**
  31396. * Gets or sets the active clipplane 3
  31397. */
  31398. clipPlane3: Nullable<Plane>;
  31399. /**
  31400. * Gets or sets the active clipplane 4
  31401. */
  31402. clipPlane4: Nullable<Plane>;
  31403. /**
  31404. * Gets or sets a boolean indicating if animations are enabled
  31405. */
  31406. animationsEnabled: boolean;
  31407. private _animationPropertiesOverride;
  31408. /**
  31409. * Gets or sets the animation properties override
  31410. */
  31411. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31412. /**
  31413. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31414. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31415. */
  31416. useConstantAnimationDeltaTime: boolean;
  31417. /**
  31418. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31419. * Please note that it requires to run a ray cast through the scene on every frame
  31420. */
  31421. constantlyUpdateMeshUnderPointer: boolean;
  31422. /**
  31423. * Defines the HTML cursor to use when hovering over interactive elements
  31424. */
  31425. hoverCursor: string;
  31426. /**
  31427. * Defines the HTML default cursor to use (empty by default)
  31428. */
  31429. defaultCursor: string;
  31430. /**
  31431. * This is used to call preventDefault() on pointer down
  31432. * in order to block unwanted artifacts like system double clicks
  31433. */
  31434. preventDefaultOnPointerDown: boolean;
  31435. /**
  31436. * This is used to call preventDefault() on pointer up
  31437. * in order to block unwanted artifacts like system double clicks
  31438. */
  31439. preventDefaultOnPointerUp: boolean;
  31440. /**
  31441. * Gets or sets user defined metadata
  31442. */
  31443. metadata: any;
  31444. /**
  31445. * For internal use only. Please do not use.
  31446. */
  31447. reservedDataStore: any;
  31448. /**
  31449. * Gets the name of the plugin used to load this scene (null by default)
  31450. */
  31451. loadingPluginName: string;
  31452. /**
  31453. * Use this array to add regular expressions used to disable offline support for specific urls
  31454. */
  31455. disableOfflineSupportExceptionRules: RegExp[];
  31456. /**
  31457. * An event triggered when the scene is disposed.
  31458. */
  31459. onDisposeObservable: Observable<Scene>;
  31460. private _onDisposeObserver;
  31461. /** Sets a function to be executed when this scene is disposed. */
  31462. onDispose: () => void;
  31463. /**
  31464. * An event triggered before rendering the scene (right after animations and physics)
  31465. */
  31466. onBeforeRenderObservable: Observable<Scene>;
  31467. private _onBeforeRenderObserver;
  31468. /** Sets a function to be executed before rendering this scene */
  31469. beforeRender: Nullable<() => void>;
  31470. /**
  31471. * An event triggered after rendering the scene
  31472. */
  31473. onAfterRenderObservable: Observable<Scene>;
  31474. private _onAfterRenderObserver;
  31475. /** Sets a function to be executed after rendering this scene */
  31476. afterRender: Nullable<() => void>;
  31477. /**
  31478. * An event triggered before animating the scene
  31479. */
  31480. onBeforeAnimationsObservable: Observable<Scene>;
  31481. /**
  31482. * An event triggered after animations processing
  31483. */
  31484. onAfterAnimationsObservable: Observable<Scene>;
  31485. /**
  31486. * An event triggered before draw calls are ready to be sent
  31487. */
  31488. onBeforeDrawPhaseObservable: Observable<Scene>;
  31489. /**
  31490. * An event triggered after draw calls have been sent
  31491. */
  31492. onAfterDrawPhaseObservable: Observable<Scene>;
  31493. /**
  31494. * An event triggered when the scene is ready
  31495. */
  31496. onReadyObservable: Observable<Scene>;
  31497. /**
  31498. * An event triggered before rendering a camera
  31499. */
  31500. onBeforeCameraRenderObservable: Observable<Camera>;
  31501. private _onBeforeCameraRenderObserver;
  31502. /** Sets a function to be executed before rendering a camera*/
  31503. beforeCameraRender: () => void;
  31504. /**
  31505. * An event triggered after rendering a camera
  31506. */
  31507. onAfterCameraRenderObservable: Observable<Camera>;
  31508. private _onAfterCameraRenderObserver;
  31509. /** Sets a function to be executed after rendering a camera*/
  31510. afterCameraRender: () => void;
  31511. /**
  31512. * An event triggered when active meshes evaluation is about to start
  31513. */
  31514. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31515. /**
  31516. * An event triggered when active meshes evaluation is done
  31517. */
  31518. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31519. /**
  31520. * An event triggered when particles rendering is about to start
  31521. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31522. */
  31523. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31524. /**
  31525. * An event triggered when particles rendering is done
  31526. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31527. */
  31528. onAfterParticlesRenderingObservable: Observable<Scene>;
  31529. /**
  31530. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31531. */
  31532. onDataLoadedObservable: Observable<Scene>;
  31533. /**
  31534. * An event triggered when a camera is created
  31535. */
  31536. onNewCameraAddedObservable: Observable<Camera>;
  31537. /**
  31538. * An event triggered when a camera is removed
  31539. */
  31540. onCameraRemovedObservable: Observable<Camera>;
  31541. /**
  31542. * An event triggered when a light is created
  31543. */
  31544. onNewLightAddedObservable: Observable<Light>;
  31545. /**
  31546. * An event triggered when a light is removed
  31547. */
  31548. onLightRemovedObservable: Observable<Light>;
  31549. /**
  31550. * An event triggered when a geometry is created
  31551. */
  31552. onNewGeometryAddedObservable: Observable<Geometry>;
  31553. /**
  31554. * An event triggered when a geometry is removed
  31555. */
  31556. onGeometryRemovedObservable: Observable<Geometry>;
  31557. /**
  31558. * An event triggered when a transform node is created
  31559. */
  31560. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31561. /**
  31562. * An event triggered when a transform node is removed
  31563. */
  31564. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31565. /**
  31566. * An event triggered when a mesh is created
  31567. */
  31568. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31569. /**
  31570. * An event triggered when a mesh is removed
  31571. */
  31572. onMeshRemovedObservable: Observable<AbstractMesh>;
  31573. /**
  31574. * An event triggered when a skeleton is created
  31575. */
  31576. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31577. /**
  31578. * An event triggered when a skeleton is removed
  31579. */
  31580. onSkeletonRemovedObservable: Observable<Skeleton>;
  31581. /**
  31582. * An event triggered when a material is created
  31583. */
  31584. onNewMaterialAddedObservable: Observable<Material>;
  31585. /**
  31586. * An event triggered when a material is removed
  31587. */
  31588. onMaterialRemovedObservable: Observable<Material>;
  31589. /**
  31590. * An event triggered when a texture is created
  31591. */
  31592. onNewTextureAddedObservable: Observable<BaseTexture>;
  31593. /**
  31594. * An event triggered when a texture is removed
  31595. */
  31596. onTextureRemovedObservable: Observable<BaseTexture>;
  31597. /**
  31598. * An event triggered when render targets are about to be rendered
  31599. * Can happen multiple times per frame.
  31600. */
  31601. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31602. /**
  31603. * An event triggered when render targets were rendered.
  31604. * Can happen multiple times per frame.
  31605. */
  31606. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31607. /**
  31608. * An event triggered before calculating deterministic simulation step
  31609. */
  31610. onBeforeStepObservable: Observable<Scene>;
  31611. /**
  31612. * An event triggered after calculating deterministic simulation step
  31613. */
  31614. onAfterStepObservable: Observable<Scene>;
  31615. /**
  31616. * An event triggered when the activeCamera property is updated
  31617. */
  31618. onActiveCameraChanged: Observable<Scene>;
  31619. /**
  31620. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31621. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31622. * 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)
  31623. */
  31624. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31625. /**
  31626. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31627. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31628. * 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)
  31629. */
  31630. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31631. /**
  31632. * This Observable will when a mesh has been imported into the scene.
  31633. */
  31634. onMeshImportedObservable: Observable<AbstractMesh>;
  31635. /**
  31636. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31637. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31638. */
  31639. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31640. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31641. /**
  31642. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31643. */
  31644. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31645. /**
  31646. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31647. */
  31648. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31649. /**
  31650. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31651. */
  31652. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31653. /** Callback called when a pointer move is detected */
  31654. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31655. /** Callback called when a pointer down is detected */
  31656. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31657. /** Callback called when a pointer up is detected */
  31658. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31659. /** Callback called when a pointer pick is detected */
  31660. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31661. /**
  31662. * 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).
  31663. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31664. */
  31665. onPrePointerObservable: Observable<PointerInfoPre>;
  31666. /**
  31667. * Observable event triggered each time an input event is received from the rendering canvas
  31668. */
  31669. onPointerObservable: Observable<PointerInfo>;
  31670. /**
  31671. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31672. */
  31673. readonly unTranslatedPointer: Vector2;
  31674. /**
  31675. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31676. */
  31677. static DragMovementThreshold: number;
  31678. /**
  31679. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31680. */
  31681. static LongPressDelay: number;
  31682. /**
  31683. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31684. */
  31685. static DoubleClickDelay: number;
  31686. /** If you need to check double click without raising a single click at first click, enable this flag */
  31687. static ExclusiveDoubleClickMode: boolean;
  31688. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31689. /**
  31690. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31691. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31692. */
  31693. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31694. /**
  31695. * Observable event triggered each time an keyboard event is received from the hosting window
  31696. */
  31697. onKeyboardObservable: Observable<KeyboardInfo>;
  31698. private _useRightHandedSystem;
  31699. /**
  31700. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31701. */
  31702. useRightHandedSystem: boolean;
  31703. private _timeAccumulator;
  31704. private _currentStepId;
  31705. private _currentInternalStep;
  31706. /**
  31707. * Sets the step Id used by deterministic lock step
  31708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31709. * @param newStepId defines the step Id
  31710. */
  31711. setStepId(newStepId: number): void;
  31712. /**
  31713. * Gets the step Id used by deterministic lock step
  31714. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31715. * @returns the step Id
  31716. */
  31717. getStepId(): number;
  31718. /**
  31719. * Gets the internal step used by deterministic lock step
  31720. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31721. * @returns the internal step
  31722. */
  31723. getInternalStep(): number;
  31724. private _fogEnabled;
  31725. /**
  31726. * Gets or sets a boolean indicating if fog is enabled on this scene
  31727. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31728. * (Default is true)
  31729. */
  31730. fogEnabled: boolean;
  31731. private _fogMode;
  31732. /**
  31733. * Gets or sets the fog mode to use
  31734. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31735. * | mode | value |
  31736. * | --- | --- |
  31737. * | FOGMODE_NONE | 0 |
  31738. * | FOGMODE_EXP | 1 |
  31739. * | FOGMODE_EXP2 | 2 |
  31740. * | FOGMODE_LINEAR | 3 |
  31741. */
  31742. fogMode: number;
  31743. /**
  31744. * Gets or sets the fog color to use
  31745. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31746. * (Default is Color3(0.2, 0.2, 0.3))
  31747. */
  31748. fogColor: Color3;
  31749. /**
  31750. * Gets or sets the fog density to use
  31751. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31752. * (Default is 0.1)
  31753. */
  31754. fogDensity: number;
  31755. /**
  31756. * Gets or sets the fog start distance to use
  31757. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31758. * (Default is 0)
  31759. */
  31760. fogStart: number;
  31761. /**
  31762. * Gets or sets the fog end distance to use
  31763. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31764. * (Default is 1000)
  31765. */
  31766. fogEnd: number;
  31767. private _shadowsEnabled;
  31768. /**
  31769. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31770. */
  31771. shadowsEnabled: boolean;
  31772. private _lightsEnabled;
  31773. /**
  31774. * Gets or sets a boolean indicating if lights are enabled on this scene
  31775. */
  31776. lightsEnabled: boolean;
  31777. /** All of the active cameras added to this scene. */
  31778. activeCameras: Camera[];
  31779. /** @hidden */ activeCamera: Nullable<Camera>;
  31780. /** Gets or sets the current active camera */
  31781. activeCamera: Nullable<Camera>;
  31782. private _defaultMaterial;
  31783. /** The default material used on meshes when no material is affected */
  31784. /** The default material used on meshes when no material is affected */
  31785. defaultMaterial: Material;
  31786. private _texturesEnabled;
  31787. /**
  31788. * Gets or sets a boolean indicating if textures are enabled on this scene
  31789. */
  31790. texturesEnabled: boolean;
  31791. /**
  31792. * Gets or sets a boolean indicating if particles are enabled on this scene
  31793. */
  31794. particlesEnabled: boolean;
  31795. /**
  31796. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31797. */
  31798. spritesEnabled: boolean;
  31799. private _skeletonsEnabled;
  31800. /**
  31801. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31802. */
  31803. skeletonsEnabled: boolean;
  31804. /**
  31805. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31806. */
  31807. lensFlaresEnabled: boolean;
  31808. /**
  31809. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31811. */
  31812. collisionsEnabled: boolean;
  31813. private _collisionCoordinator;
  31814. /** @hidden */
  31815. readonly collisionCoordinator: ICollisionCoordinator;
  31816. /**
  31817. * Defines the gravity applied to this scene (used only for collisions)
  31818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31819. */
  31820. gravity: Vector3;
  31821. /**
  31822. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31823. */
  31824. postProcessesEnabled: boolean;
  31825. /**
  31826. * The list of postprocesses added to the scene
  31827. */
  31828. postProcesses: PostProcess[];
  31829. /**
  31830. * Gets the current postprocess manager
  31831. */
  31832. postProcessManager: PostProcessManager;
  31833. /**
  31834. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31835. */
  31836. renderTargetsEnabled: boolean;
  31837. /**
  31838. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31839. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31840. */
  31841. dumpNextRenderTargets: boolean;
  31842. /**
  31843. * The list of user defined render targets added to the scene
  31844. */
  31845. customRenderTargets: RenderTargetTexture[];
  31846. /**
  31847. * Defines if texture loading must be delayed
  31848. * If true, textures will only be loaded when they need to be rendered
  31849. */
  31850. useDelayedTextureLoading: boolean;
  31851. /**
  31852. * Gets the list of meshes imported to the scene through SceneLoader
  31853. */
  31854. importedMeshesFiles: String[];
  31855. /**
  31856. * Gets or sets a boolean indicating if probes are enabled on this scene
  31857. */
  31858. probesEnabled: boolean;
  31859. /**
  31860. * Gets or sets the current offline provider to use to store scene data
  31861. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31862. */
  31863. offlineProvider: IOfflineProvider;
  31864. /**
  31865. * Gets or sets the action manager associated with the scene
  31866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31867. */
  31868. actionManager: AbstractActionManager;
  31869. private _meshesForIntersections;
  31870. /**
  31871. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31872. */
  31873. proceduralTexturesEnabled: boolean;
  31874. private _engine;
  31875. private _totalVertices;
  31876. /** @hidden */ activeIndices: PerfCounter;
  31877. /** @hidden */ activeParticles: PerfCounter;
  31878. /** @hidden */ activeBones: PerfCounter;
  31879. private _animationRatio;
  31880. /** @hidden */ animationTimeLast: number;
  31881. /** @hidden */ animationTime: number;
  31882. /**
  31883. * Gets or sets a general scale for animation speed
  31884. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31885. */
  31886. animationTimeScale: number;
  31887. /** @hidden */ cachedMaterial: Nullable<Material>;
  31888. /** @hidden */ cachedEffect: Nullable<Effect>;
  31889. /** @hidden */ cachedVisibility: Nullable<number>;
  31890. private _renderId;
  31891. private _frameId;
  31892. private _executeWhenReadyTimeoutId;
  31893. private _intermediateRendering;
  31894. private _viewUpdateFlag;
  31895. private _projectionUpdateFlag;
  31896. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31897. private _activeRequests;
  31898. /** @hidden */ pendingData: any[];
  31899. private _isDisposed;
  31900. /**
  31901. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31902. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31903. */
  31904. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31905. private _activeMeshes;
  31906. private _processedMaterials;
  31907. private _renderTargets;
  31908. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31909. private _activeSkeletons;
  31910. private _softwareSkinnedMeshes;
  31911. private _renderingManager;
  31912. /** @hidden */ activeAnimatables: Animatable[];
  31913. private _transformMatrix;
  31914. private _sceneUbo;
  31915. /** @hidden */ viewMatrix: Matrix;
  31916. private _projectionMatrix;
  31917. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31918. /** @hidden */ frustumPlanes: Plane[];
  31919. /**
  31920. * Gets the list of frustum planes (built from the active camera)
  31921. */
  31922. readonly frustumPlanes: Plane[];
  31923. /**
  31924. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31925. * This is useful if there are more lights that the maximum simulteanous authorized
  31926. */
  31927. requireLightSorting: boolean;
  31928. /** @hidden */
  31929. readonly useMaterialMeshMap: boolean;
  31930. /** @hidden */
  31931. readonly useClonedMeshhMap: boolean;
  31932. private _externalData;
  31933. private _uid;
  31934. /**
  31935. * @hidden
  31936. * Backing store of defined scene components.
  31937. */ components: ISceneComponent[];
  31938. /**
  31939. * @hidden
  31940. * Backing store of defined scene components.
  31941. */ serializableComponents: ISceneSerializableComponent[];
  31942. /**
  31943. * List of components to register on the next registration step.
  31944. */
  31945. private _transientComponents;
  31946. /**
  31947. * Registers the transient components if needed.
  31948. */
  31949. private _registerTransientComponents;
  31950. /**
  31951. * @hidden
  31952. * Add a component to the scene.
  31953. * Note that the ccomponent could be registered on th next frame if this is called after
  31954. * the register component stage.
  31955. * @param component Defines the component to add to the scene
  31956. */ addComponent(component: ISceneComponent): void;
  31957. /**
  31958. * @hidden
  31959. * Gets a component from the scene.
  31960. * @param name defines the name of the component to retrieve
  31961. * @returns the component or null if not present
  31962. */ getComponent(name: string): Nullable<ISceneComponent>;
  31963. /**
  31964. * @hidden
  31965. * Defines the actions happening before camera updates.
  31966. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31967. /**
  31968. * @hidden
  31969. * Defines the actions happening before clear the canvas.
  31970. */ beforeClearStage: Stage<SimpleStageAction>;
  31971. /**
  31972. * @hidden
  31973. * Defines the actions when collecting render targets for the frame.
  31974. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31975. /**
  31976. * @hidden
  31977. * Defines the actions happening for one camera in the frame.
  31978. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31979. /**
  31980. * @hidden
  31981. * Defines the actions happening during the per mesh ready checks.
  31982. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31983. /**
  31984. * @hidden
  31985. * Defines the actions happening before evaluate active mesh checks.
  31986. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31987. /**
  31988. * @hidden
  31989. * Defines the actions happening during the evaluate sub mesh checks.
  31990. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31991. /**
  31992. * @hidden
  31993. * Defines the actions happening during the active mesh stage.
  31994. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31995. /**
  31996. * @hidden
  31997. * Defines the actions happening during the per camera render target step.
  31998. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  31999. /**
  32000. * @hidden
  32001. * Defines the actions happening just before the active camera is drawing.
  32002. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  32003. /**
  32004. * @hidden
  32005. * Defines the actions happening just before a render target is drawing.
  32006. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32007. /**
  32008. * @hidden
  32009. * Defines the actions happening just before a rendering group is drawing.
  32010. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32011. /**
  32012. * @hidden
  32013. * Defines the actions happening just before a mesh is drawing.
  32014. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32015. /**
  32016. * @hidden
  32017. * Defines the actions happening just after a mesh has been drawn.
  32018. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32019. /**
  32020. * @hidden
  32021. * Defines the actions happening just after a rendering group has been drawn.
  32022. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32023. /**
  32024. * @hidden
  32025. * Defines the actions happening just after the active camera has been drawn.
  32026. */ afterCameraDrawStage: Stage<CameraStageAction>;
  32027. /**
  32028. * @hidden
  32029. * Defines the actions happening just after a render target has been drawn.
  32030. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32031. /**
  32032. * @hidden
  32033. * Defines the actions happening just after rendering all cameras and computing intersections.
  32034. */ afterRenderStage: Stage<SimpleStageAction>;
  32035. /**
  32036. * @hidden
  32037. * Defines the actions happening when a pointer move event happens.
  32038. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  32039. /**
  32040. * @hidden
  32041. * Defines the actions happening when a pointer down event happens.
  32042. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  32043. /**
  32044. * @hidden
  32045. * Defines the actions happening when a pointer up event happens.
  32046. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  32047. /**
  32048. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32049. */
  32050. private geometriesByUniqueId;
  32051. /**
  32052. * Creates a new Scene
  32053. * @param engine defines the engine to use to render this scene
  32054. * @param options defines the scene options
  32055. */
  32056. constructor(engine: Engine, options?: SceneOptions);
  32057. /**
  32058. * Gets a string idenfifying the name of the class
  32059. * @returns "Scene" string
  32060. */
  32061. getClassName(): string;
  32062. private _defaultMeshCandidates;
  32063. /**
  32064. * @hidden
  32065. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32066. private _defaultSubMeshCandidates;
  32067. /**
  32068. * @hidden
  32069. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32070. /**
  32071. * Sets the default candidate providers for the scene.
  32072. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32073. * and getCollidingSubMeshCandidates to their default function
  32074. */
  32075. setDefaultCandidateProviders(): void;
  32076. /**
  32077. * Gets the mesh that is currently under the pointer
  32078. */
  32079. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32080. /**
  32081. * Gets or sets the current on-screen X position of the pointer
  32082. */
  32083. pointerX: number;
  32084. /**
  32085. * Gets or sets the current on-screen Y position of the pointer
  32086. */
  32087. pointerY: number;
  32088. /**
  32089. * Gets the cached material (ie. the latest rendered one)
  32090. * @returns the cached material
  32091. */
  32092. getCachedMaterial(): Nullable<Material>;
  32093. /**
  32094. * Gets the cached effect (ie. the latest rendered one)
  32095. * @returns the cached effect
  32096. */
  32097. getCachedEffect(): Nullable<Effect>;
  32098. /**
  32099. * Gets the cached visibility state (ie. the latest rendered one)
  32100. * @returns the cached visibility state
  32101. */
  32102. getCachedVisibility(): Nullable<number>;
  32103. /**
  32104. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32105. * @param material defines the current material
  32106. * @param effect defines the current effect
  32107. * @param visibility defines the current visibility state
  32108. * @returns true if one parameter is not cached
  32109. */
  32110. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32111. /**
  32112. * Gets the engine associated with the scene
  32113. * @returns an Engine
  32114. */
  32115. getEngine(): Engine;
  32116. /**
  32117. * Gets the total number of vertices rendered per frame
  32118. * @returns the total number of vertices rendered per frame
  32119. */
  32120. getTotalVertices(): number;
  32121. /**
  32122. * Gets the performance counter for total vertices
  32123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32124. */
  32125. readonly totalVerticesPerfCounter: PerfCounter;
  32126. /**
  32127. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32128. * @returns the total number of active indices rendered per frame
  32129. */
  32130. getActiveIndices(): number;
  32131. /**
  32132. * Gets the performance counter for active indices
  32133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32134. */
  32135. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32136. /**
  32137. * Gets the total number of active particles rendered per frame
  32138. * @returns the total number of active particles rendered per frame
  32139. */
  32140. getActiveParticles(): number;
  32141. /**
  32142. * Gets the performance counter for active particles
  32143. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32144. */
  32145. readonly activeParticlesPerfCounter: PerfCounter;
  32146. /**
  32147. * Gets the total number of active bones rendered per frame
  32148. * @returns the total number of active bones rendered per frame
  32149. */
  32150. getActiveBones(): number;
  32151. /**
  32152. * Gets the performance counter for active bones
  32153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32154. */
  32155. readonly activeBonesPerfCounter: PerfCounter;
  32156. /**
  32157. * Gets the array of active meshes
  32158. * @returns an array of AbstractMesh
  32159. */
  32160. getActiveMeshes(): SmartArray<AbstractMesh>;
  32161. /**
  32162. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32163. * @returns a number
  32164. */
  32165. getAnimationRatio(): number;
  32166. /**
  32167. * Gets an unique Id for the current render phase
  32168. * @returns a number
  32169. */
  32170. getRenderId(): number;
  32171. /**
  32172. * Gets an unique Id for the current frame
  32173. * @returns a number
  32174. */
  32175. getFrameId(): number;
  32176. /** Call this function if you want to manually increment the render Id*/
  32177. incrementRenderId(): void;
  32178. private _createUbo;
  32179. /**
  32180. * Use this method to simulate a pointer move on a mesh
  32181. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32182. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32183. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32184. * @returns the current scene
  32185. */
  32186. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32187. /**
  32188. * Use this method to simulate a pointer down on a mesh
  32189. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32190. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32191. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32192. * @returns the current scene
  32193. */
  32194. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32195. /**
  32196. * Use this method to simulate a pointer up on a mesh
  32197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32200. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32201. * @returns the current scene
  32202. */
  32203. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32204. /**
  32205. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32206. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32207. * @returns true if the pointer was captured
  32208. */
  32209. isPointerCaptured(pointerId?: number): boolean;
  32210. /**
  32211. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32212. * @param attachUp defines if you want to attach events to pointerup
  32213. * @param attachDown defines if you want to attach events to pointerdown
  32214. * @param attachMove defines if you want to attach events to pointermove
  32215. */
  32216. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32217. /** Detaches all event handlers*/
  32218. detachControl(): void;
  32219. /**
  32220. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32221. * Delay loaded resources are not taking in account
  32222. * @return true if all required resources are ready
  32223. */
  32224. isReady(): boolean;
  32225. /** Resets all cached information relative to material (including effect and visibility) */
  32226. resetCachedMaterial(): void;
  32227. /**
  32228. * Registers a function to be called before every frame render
  32229. * @param func defines the function to register
  32230. */
  32231. registerBeforeRender(func: () => void): void;
  32232. /**
  32233. * Unregisters a function called before every frame render
  32234. * @param func defines the function to unregister
  32235. */
  32236. unregisterBeforeRender(func: () => void): void;
  32237. /**
  32238. * Registers a function to be called after every frame render
  32239. * @param func defines the function to register
  32240. */
  32241. registerAfterRender(func: () => void): void;
  32242. /**
  32243. * Unregisters a function called after every frame render
  32244. * @param func defines the function to unregister
  32245. */
  32246. unregisterAfterRender(func: () => void): void;
  32247. private _executeOnceBeforeRender;
  32248. /**
  32249. * The provided function will run before render once and will be disposed afterwards.
  32250. * A timeout delay can be provided so that the function will be executed in N ms.
  32251. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32252. * @param func The function to be executed.
  32253. * @param timeout optional delay in ms
  32254. */
  32255. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32256. /** @hidden */ addPendingData(data: any): void;
  32257. /** @hidden */ removePendingData(data: any): void;
  32258. /**
  32259. * Returns the number of items waiting to be loaded
  32260. * @returns the number of items waiting to be loaded
  32261. */
  32262. getWaitingItemsCount(): number;
  32263. /**
  32264. * Returns a boolean indicating if the scene is still loading data
  32265. */
  32266. readonly isLoading: boolean;
  32267. /**
  32268. * Registers a function to be executed when the scene is ready
  32269. * @param {Function} func - the function to be executed
  32270. */
  32271. executeWhenReady(func: () => void): void;
  32272. /**
  32273. * Returns a promise that resolves when the scene is ready
  32274. * @returns A promise that resolves when the scene is ready
  32275. */
  32276. whenReadyAsync(): Promise<void>;
  32277. /** @hidden */ checkIsReady(): void;
  32278. /**
  32279. * Gets all animatable attached to the scene
  32280. */
  32281. readonly animatables: Animatable[];
  32282. /**
  32283. * Resets the last animation time frame.
  32284. * Useful to override when animations start running when loading a scene for the first time.
  32285. */
  32286. resetLastAnimationTimeFrame(): void;
  32287. /**
  32288. * Gets the current view matrix
  32289. * @returns a Matrix
  32290. */
  32291. getViewMatrix(): Matrix;
  32292. /**
  32293. * Gets the current projection matrix
  32294. * @returns a Matrix
  32295. */
  32296. getProjectionMatrix(): Matrix;
  32297. /**
  32298. * Gets the current transform matrix
  32299. * @returns a Matrix made of View * Projection
  32300. */
  32301. getTransformMatrix(): Matrix;
  32302. /**
  32303. * Sets the current transform matrix
  32304. * @param viewL defines the View matrix to use
  32305. * @param projectionL defines the Projection matrix to use
  32306. * @param viewR defines the right View matrix to use (if provided)
  32307. * @param projectionR defines the right Projection matrix to use (if provided)
  32308. */
  32309. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32310. /**
  32311. * Gets the uniform buffer used to store scene data
  32312. * @returns a UniformBuffer
  32313. */
  32314. getSceneUniformBuffer(): UniformBuffer;
  32315. /**
  32316. * Gets an unique (relatively to the current scene) Id
  32317. * @returns an unique number for the scene
  32318. */
  32319. getUniqueId(): number;
  32320. /**
  32321. * Add a mesh to the list of scene's meshes
  32322. * @param newMesh defines the mesh to add
  32323. * @param recursive if all child meshes should also be added to the scene
  32324. */
  32325. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32326. /**
  32327. * Remove a mesh for the list of scene's meshes
  32328. * @param toRemove defines the mesh to remove
  32329. * @param recursive if all child meshes should also be removed from the scene
  32330. * @returns the index where the mesh was in the mesh list
  32331. */
  32332. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32333. /**
  32334. * Add a transform node to the list of scene's transform nodes
  32335. * @param newTransformNode defines the transform node to add
  32336. */
  32337. addTransformNode(newTransformNode: TransformNode): void;
  32338. /**
  32339. * Remove a transform node for the list of scene's transform nodes
  32340. * @param toRemove defines the transform node to remove
  32341. * @returns the index where the transform node was in the transform node list
  32342. */
  32343. removeTransformNode(toRemove: TransformNode): number;
  32344. /**
  32345. * Remove a skeleton for the list of scene's skeletons
  32346. * @param toRemove defines the skeleton to remove
  32347. * @returns the index where the skeleton was in the skeleton list
  32348. */
  32349. removeSkeleton(toRemove: Skeleton): number;
  32350. /**
  32351. * Remove a morph target for the list of scene's morph targets
  32352. * @param toRemove defines the morph target to remove
  32353. * @returns the index where the morph target was in the morph target list
  32354. */
  32355. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32356. /**
  32357. * Remove a light for the list of scene's lights
  32358. * @param toRemove defines the light to remove
  32359. * @returns the index where the light was in the light list
  32360. */
  32361. removeLight(toRemove: Light): number;
  32362. /**
  32363. * Remove a camera for the list of scene's cameras
  32364. * @param toRemove defines the camera to remove
  32365. * @returns the index where the camera was in the camera list
  32366. */
  32367. removeCamera(toRemove: Camera): number;
  32368. /**
  32369. * Remove a particle system for the list of scene's particle systems
  32370. * @param toRemove defines the particle system to remove
  32371. * @returns the index where the particle system was in the particle system list
  32372. */
  32373. removeParticleSystem(toRemove: IParticleSystem): number;
  32374. /**
  32375. * Remove a animation for the list of scene's animations
  32376. * @param toRemove defines the animation to remove
  32377. * @returns the index where the animation was in the animation list
  32378. */
  32379. removeAnimation(toRemove: Animation): number;
  32380. /**
  32381. * Removes the given animation group from this scene.
  32382. * @param toRemove The animation group to remove
  32383. * @returns The index of the removed animation group
  32384. */
  32385. removeAnimationGroup(toRemove: AnimationGroup): number;
  32386. /**
  32387. * Removes the given multi-material from this scene.
  32388. * @param toRemove The multi-material to remove
  32389. * @returns The index of the removed multi-material
  32390. */
  32391. removeMultiMaterial(toRemove: MultiMaterial): number;
  32392. /**
  32393. * Removes the given material from this scene.
  32394. * @param toRemove The material to remove
  32395. * @returns The index of the removed material
  32396. */
  32397. removeMaterial(toRemove: Material): number;
  32398. /**
  32399. * Removes the given action manager from this scene.
  32400. * @param toRemove The action manager to remove
  32401. * @returns The index of the removed action manager
  32402. */
  32403. removeActionManager(toRemove: AbstractActionManager): number;
  32404. /**
  32405. * Removes the given texture from this scene.
  32406. * @param toRemove The texture to remove
  32407. * @returns The index of the removed texture
  32408. */
  32409. removeTexture(toRemove: BaseTexture): number;
  32410. /**
  32411. * Adds the given light to this scene
  32412. * @param newLight The light to add
  32413. */
  32414. addLight(newLight: Light): void;
  32415. /**
  32416. * Sorts the list list based on light priorities
  32417. */
  32418. sortLightsByPriority(): void;
  32419. /**
  32420. * Adds the given camera to this scene
  32421. * @param newCamera The camera to add
  32422. */
  32423. addCamera(newCamera: Camera): void;
  32424. /**
  32425. * Adds the given skeleton to this scene
  32426. * @param newSkeleton The skeleton to add
  32427. */
  32428. addSkeleton(newSkeleton: Skeleton): void;
  32429. /**
  32430. * Adds the given particle system to this scene
  32431. * @param newParticleSystem The particle system to add
  32432. */
  32433. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32434. /**
  32435. * Adds the given animation to this scene
  32436. * @param newAnimation The animation to add
  32437. */
  32438. addAnimation(newAnimation: Animation): void;
  32439. /**
  32440. * Adds the given animation group to this scene.
  32441. * @param newAnimationGroup The animation group to add
  32442. */
  32443. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32444. /**
  32445. * Adds the given multi-material to this scene
  32446. * @param newMultiMaterial The multi-material to add
  32447. */
  32448. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32449. /**
  32450. * Adds the given material to this scene
  32451. * @param newMaterial The material to add
  32452. */
  32453. addMaterial(newMaterial: Material): void;
  32454. /**
  32455. * Adds the given morph target to this scene
  32456. * @param newMorphTargetManager The morph target to add
  32457. */
  32458. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32459. /**
  32460. * Adds the given geometry to this scene
  32461. * @param newGeometry The geometry to add
  32462. */
  32463. addGeometry(newGeometry: Geometry): void;
  32464. /**
  32465. * Adds the given action manager to this scene
  32466. * @param newActionManager The action manager to add
  32467. */
  32468. addActionManager(newActionManager: AbstractActionManager): void;
  32469. /**
  32470. * Adds the given texture to this scene.
  32471. * @param newTexture The texture to add
  32472. */
  32473. addTexture(newTexture: BaseTexture): void;
  32474. /**
  32475. * Switch active camera
  32476. * @param newCamera defines the new active camera
  32477. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32478. */
  32479. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32480. /**
  32481. * sets the active camera of the scene using its ID
  32482. * @param id defines the camera's ID
  32483. * @return the new active camera or null if none found.
  32484. */
  32485. setActiveCameraByID(id: string): Nullable<Camera>;
  32486. /**
  32487. * sets the active camera of the scene using its name
  32488. * @param name defines the camera's name
  32489. * @returns the new active camera or null if none found.
  32490. */
  32491. setActiveCameraByName(name: string): Nullable<Camera>;
  32492. /**
  32493. * get an animation group using its name
  32494. * @param name defines the material's name
  32495. * @return the animation group or null if none found.
  32496. */
  32497. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32498. /**
  32499. * Get a material using its unique id
  32500. * @param uniqueId defines the material's unique id
  32501. * @return the material or null if none found.
  32502. */
  32503. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32504. /**
  32505. * get a material using its id
  32506. * @param id defines the material's ID
  32507. * @return the material or null if none found.
  32508. */
  32509. getMaterialByID(id: string): Nullable<Material>;
  32510. /**
  32511. * Gets a material using its name
  32512. * @param name defines the material's name
  32513. * @return the material or null if none found.
  32514. */
  32515. getMaterialByName(name: string): Nullable<Material>;
  32516. /**
  32517. * Gets a camera using its id
  32518. * @param id defines the id to look for
  32519. * @returns the camera or null if not found
  32520. */
  32521. getCameraByID(id: string): Nullable<Camera>;
  32522. /**
  32523. * Gets a camera using its unique id
  32524. * @param uniqueId defines the unique id to look for
  32525. * @returns the camera or null if not found
  32526. */
  32527. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32528. /**
  32529. * Gets a camera using its name
  32530. * @param name defines the camera's name
  32531. * @return the camera or null if none found.
  32532. */
  32533. getCameraByName(name: string): Nullable<Camera>;
  32534. /**
  32535. * Gets a bone using its id
  32536. * @param id defines the bone's id
  32537. * @return the bone or null if not found
  32538. */
  32539. getBoneByID(id: string): Nullable<Bone>;
  32540. /**
  32541. * Gets a bone using its id
  32542. * @param name defines the bone's name
  32543. * @return the bone or null if not found
  32544. */
  32545. getBoneByName(name: string): Nullable<Bone>;
  32546. /**
  32547. * Gets a light node using its name
  32548. * @param name defines the the light's name
  32549. * @return the light or null if none found.
  32550. */
  32551. getLightByName(name: string): Nullable<Light>;
  32552. /**
  32553. * Gets a light node using its id
  32554. * @param id defines the light's id
  32555. * @return the light or null if none found.
  32556. */
  32557. getLightByID(id: string): Nullable<Light>;
  32558. /**
  32559. * Gets a light node using its scene-generated unique ID
  32560. * @param uniqueId defines the light's unique id
  32561. * @return the light or null if none found.
  32562. */
  32563. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32564. /**
  32565. * Gets a particle system by id
  32566. * @param id defines the particle system id
  32567. * @return the corresponding system or null if none found
  32568. */
  32569. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32570. /**
  32571. * Gets a geometry using its ID
  32572. * @param id defines the geometry's id
  32573. * @return the geometry or null if none found.
  32574. */
  32575. getGeometryByID(id: string): Nullable<Geometry>;
  32576. private _getGeometryByUniqueID;
  32577. /**
  32578. * Add a new geometry to this scene
  32579. * @param geometry defines the geometry to be added to the scene.
  32580. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32581. * @return a boolean defining if the geometry was added or not
  32582. */
  32583. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32584. /**
  32585. * Removes an existing geometry
  32586. * @param geometry defines the geometry to be removed from the scene
  32587. * @return a boolean defining if the geometry was removed or not
  32588. */
  32589. removeGeometry(geometry: Geometry): boolean;
  32590. /**
  32591. * Gets the list of geometries attached to the scene
  32592. * @returns an array of Geometry
  32593. */
  32594. getGeometries(): Geometry[];
  32595. /**
  32596. * Gets the first added mesh found of a given ID
  32597. * @param id defines the id to search for
  32598. * @return the mesh found or null if not found at all
  32599. */
  32600. getMeshByID(id: string): Nullable<AbstractMesh>;
  32601. /**
  32602. * Gets a list of meshes using their id
  32603. * @param id defines the id to search for
  32604. * @returns a list of meshes
  32605. */
  32606. getMeshesByID(id: string): Array<AbstractMesh>;
  32607. /**
  32608. * Gets the first added transform node found of a given ID
  32609. * @param id defines the id to search for
  32610. * @return the found transform node or null if not found at all.
  32611. */
  32612. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32613. /**
  32614. * Gets a transform node with its auto-generated unique id
  32615. * @param uniqueId efines the unique id to search for
  32616. * @return the found transform node or null if not found at all.
  32617. */
  32618. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32619. /**
  32620. * Gets a list of transform nodes using their id
  32621. * @param id defines the id to search for
  32622. * @returns a list of transform nodes
  32623. */
  32624. getTransformNodesByID(id: string): Array<TransformNode>;
  32625. /**
  32626. * Gets a mesh with its auto-generated unique id
  32627. * @param uniqueId defines the unique id to search for
  32628. * @return the found mesh or null if not found at all.
  32629. */
  32630. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32631. /**
  32632. * Gets a the last added mesh using a given id
  32633. * @param id defines the id to search for
  32634. * @return the found mesh or null if not found at all.
  32635. */
  32636. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32637. /**
  32638. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32639. * @param id defines the id to search for
  32640. * @return the found node or null if not found at all
  32641. */
  32642. getLastEntryByID(id: string): Nullable<Node>;
  32643. /**
  32644. * Gets a node (Mesh, Camera, Light) using a given id
  32645. * @param id defines the id to search for
  32646. * @return the found node or null if not found at all
  32647. */
  32648. getNodeByID(id: string): Nullable<Node>;
  32649. /**
  32650. * Gets a node (Mesh, Camera, Light) using a given name
  32651. * @param name defines the name to search for
  32652. * @return the found node or null if not found at all.
  32653. */
  32654. getNodeByName(name: string): Nullable<Node>;
  32655. /**
  32656. * Gets a mesh using a given name
  32657. * @param name defines the name to search for
  32658. * @return the found mesh or null if not found at all.
  32659. */
  32660. getMeshByName(name: string): Nullable<AbstractMesh>;
  32661. /**
  32662. * Gets a transform node using a given name
  32663. * @param name defines the name to search for
  32664. * @return the found transform node or null if not found at all.
  32665. */
  32666. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32667. /**
  32668. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32669. * @param id defines the id to search for
  32670. * @return the found skeleton or null if not found at all.
  32671. */
  32672. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32673. /**
  32674. * Gets a skeleton using a given auto generated unique id
  32675. * @param uniqueId defines the unique id to search for
  32676. * @return the found skeleton or null if not found at all.
  32677. */
  32678. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32679. /**
  32680. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32681. * @param id defines the id to search for
  32682. * @return the found skeleton or null if not found at all.
  32683. */
  32684. getSkeletonById(id: string): Nullable<Skeleton>;
  32685. /**
  32686. * Gets a skeleton using a given name
  32687. * @param name defines the name to search for
  32688. * @return the found skeleton or null if not found at all.
  32689. */
  32690. getSkeletonByName(name: string): Nullable<Skeleton>;
  32691. /**
  32692. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32693. * @param id defines the id to search for
  32694. * @return the found morph target manager or null if not found at all.
  32695. */
  32696. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32697. /**
  32698. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32699. * @param id defines the id to search for
  32700. * @return the found morph target or null if not found at all.
  32701. */
  32702. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32703. /**
  32704. * Gets a boolean indicating if the given mesh is active
  32705. * @param mesh defines the mesh to look for
  32706. * @returns true if the mesh is in the active list
  32707. */
  32708. isActiveMesh(mesh: AbstractMesh): boolean;
  32709. /**
  32710. * Return a unique id as a string which can serve as an identifier for the scene
  32711. */
  32712. readonly uid: string;
  32713. /**
  32714. * Add an externaly attached data from its key.
  32715. * This method call will fail and return false, if such key already exists.
  32716. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32717. * @param key the unique key that identifies the data
  32718. * @param data the data object to associate to the key for this Engine instance
  32719. * @return true if no such key were already present and the data was added successfully, false otherwise
  32720. */
  32721. addExternalData<T>(key: string, data: T): boolean;
  32722. /**
  32723. * Get an externaly attached data from its key
  32724. * @param key the unique key that identifies the data
  32725. * @return the associated data, if present (can be null), or undefined if not present
  32726. */
  32727. getExternalData<T>(key: string): Nullable<T>;
  32728. /**
  32729. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32730. * @param key the unique key that identifies the data
  32731. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32732. * @return the associated data, can be null if the factory returned null.
  32733. */
  32734. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32735. /**
  32736. * Remove an externaly attached data from the Engine instance
  32737. * @param key the unique key that identifies the data
  32738. * @return true if the data was successfully removed, false if it doesn't exist
  32739. */
  32740. removeExternalData(key: string): boolean;
  32741. private _evaluateSubMesh;
  32742. /**
  32743. * Clear the processed materials smart array preventing retention point in material dispose.
  32744. */
  32745. freeProcessedMaterials(): void;
  32746. private _preventFreeActiveMeshesAndRenderingGroups;
  32747. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32748. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32749. * when disposing several meshes in a row or a hierarchy of meshes.
  32750. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32751. */
  32752. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32753. /**
  32754. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32755. */
  32756. freeActiveMeshes(): void;
  32757. /**
  32758. * Clear the info related to rendering groups preventing retention points during dispose.
  32759. */
  32760. freeRenderingGroups(): void;
  32761. /** @hidden */ isInIntermediateRendering(): boolean;
  32762. /**
  32763. * Lambda returning the list of potentially active meshes.
  32764. */
  32765. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32766. /**
  32767. * Lambda returning the list of potentially active sub meshes.
  32768. */
  32769. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32770. /**
  32771. * Lambda returning the list of potentially intersecting sub meshes.
  32772. */
  32773. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32774. /**
  32775. * Lambda returning the list of potentially colliding sub meshes.
  32776. */
  32777. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32778. private _activeMeshesFrozen;
  32779. /**
  32780. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32781. * @returns the current scene
  32782. */
  32783. freezeActiveMeshes(): Scene;
  32784. /**
  32785. * Use this function to restart evaluating active meshes on every frame
  32786. * @returns the current scene
  32787. */
  32788. unfreezeActiveMeshes(): Scene;
  32789. private _evaluateActiveMeshes;
  32790. private _activeMesh;
  32791. /**
  32792. * Update the transform matrix to update from the current active camera
  32793. * @param force defines a boolean used to force the update even if cache is up to date
  32794. */
  32795. updateTransformMatrix(force?: boolean): void;
  32796. private _bindFrameBuffer;
  32797. /** @hidden */ allowPostProcessClearColor: boolean;
  32798. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32799. private _processSubCameras;
  32800. private _checkIntersections;
  32801. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32802. /**
  32803. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32804. */
  32805. getDeterministicFrameTime: () => number;
  32806. /** @hidden */ animate(): void;
  32807. /** Execute all animations (for a frame) */
  32808. animate(): void;
  32809. /**
  32810. * Render the scene
  32811. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32812. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32813. */
  32814. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32815. /**
  32816. * Freeze all materials
  32817. * A frozen material will not be updatable but should be faster to render
  32818. */
  32819. freezeMaterials(): void;
  32820. /**
  32821. * Unfreeze all materials
  32822. * A frozen material will not be updatable but should be faster to render
  32823. */
  32824. unfreezeMaterials(): void;
  32825. /**
  32826. * Releases all held ressources
  32827. */
  32828. dispose(): void;
  32829. /**
  32830. * Gets if the scene is already disposed
  32831. */
  32832. readonly isDisposed: boolean;
  32833. /**
  32834. * Call this function to reduce memory footprint of the scene.
  32835. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32836. */
  32837. clearCachedVertexData(): void;
  32838. /**
  32839. * This function will remove the local cached buffer data from texture.
  32840. * It will save memory but will prevent the texture from being rebuilt
  32841. */
  32842. cleanCachedTextureBuffer(): void;
  32843. /**
  32844. * Get the world extend vectors with an optional filter
  32845. *
  32846. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32847. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32848. */
  32849. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32850. min: Vector3;
  32851. max: Vector3;
  32852. };
  32853. /**
  32854. * Creates a ray that can be used to pick in the scene
  32855. * @param x defines the x coordinate of the origin (on-screen)
  32856. * @param y defines the y coordinate of the origin (on-screen)
  32857. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32858. * @param camera defines the camera to use for the picking
  32859. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32860. * @returns a Ray
  32861. */
  32862. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32863. /**
  32864. * Creates a ray that can be used to pick in the scene
  32865. * @param x defines the x coordinate of the origin (on-screen)
  32866. * @param y defines the y coordinate of the origin (on-screen)
  32867. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32868. * @param result defines the ray where to store the picking ray
  32869. * @param camera defines the camera to use for the picking
  32870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32871. * @returns the current scene
  32872. */
  32873. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32874. /**
  32875. * Creates a ray that can be used to pick in the scene
  32876. * @param x defines the x coordinate of the origin (on-screen)
  32877. * @param y defines the y coordinate of the origin (on-screen)
  32878. * @param camera defines the camera to use for the picking
  32879. * @returns a Ray
  32880. */
  32881. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32882. /**
  32883. * Creates a ray that can be used to pick in the scene
  32884. * @param x defines the x coordinate of the origin (on-screen)
  32885. * @param y defines the y coordinate of the origin (on-screen)
  32886. * @param result defines the ray where to store the picking ray
  32887. * @param camera defines the camera to use for the picking
  32888. * @returns the current scene
  32889. */
  32890. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32891. /** Launch a ray to try to pick a mesh in the scene
  32892. * @param x position on screen
  32893. * @param y position on screen
  32894. * @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
  32895. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32896. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32898. * @returns a PickingInfo
  32899. */
  32900. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32901. /** Use the given ray to pick a mesh in the scene
  32902. * @param ray The ray to use to pick meshes
  32903. * @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
  32904. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32905. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32906. * @returns a PickingInfo
  32907. */
  32908. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32909. /**
  32910. * Launch a ray to try to pick a mesh in the scene
  32911. * @param x X position on screen
  32912. * @param y Y position on screen
  32913. * @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
  32914. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32915. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32916. * @returns an array of PickingInfo
  32917. */
  32918. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32919. /**
  32920. * Launch a ray to try to pick a mesh in the scene
  32921. * @param ray Ray to use
  32922. * @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
  32923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32924. * @returns an array of PickingInfo
  32925. */
  32926. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32927. /**
  32928. * Force the value of meshUnderPointer
  32929. * @param mesh defines the mesh to use
  32930. */
  32931. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32932. /**
  32933. * Gets the mesh under the pointer
  32934. * @returns a Mesh or null if no mesh is under the pointer
  32935. */
  32936. getPointerOverMesh(): Nullable<AbstractMesh>;
  32937. /** @hidden */ rebuildGeometries(): void;
  32938. /** @hidden */ rebuildTextures(): void;
  32939. private _getByTags;
  32940. /**
  32941. * Get a list of meshes by tags
  32942. * @param tagsQuery defines the tags query to use
  32943. * @param forEach defines a predicate used to filter results
  32944. * @returns an array of Mesh
  32945. */
  32946. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32947. /**
  32948. * Get a list of cameras by tags
  32949. * @param tagsQuery defines the tags query to use
  32950. * @param forEach defines a predicate used to filter results
  32951. * @returns an array of Camera
  32952. */
  32953. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32954. /**
  32955. * Get a list of lights by tags
  32956. * @param tagsQuery defines the tags query to use
  32957. * @param forEach defines a predicate used to filter results
  32958. * @returns an array of Light
  32959. */
  32960. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32961. /**
  32962. * Get a list of materials by tags
  32963. * @param tagsQuery defines the tags query to use
  32964. * @param forEach defines a predicate used to filter results
  32965. * @returns an array of Material
  32966. */
  32967. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32968. /**
  32969. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32970. * This allowed control for front to back rendering or reversly depending of the special needs.
  32971. *
  32972. * @param renderingGroupId The rendering group id corresponding to its index
  32973. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32974. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32975. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32976. */
  32977. 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;
  32978. /**
  32979. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32980. *
  32981. * @param renderingGroupId The rendering group id corresponding to its index
  32982. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32983. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32984. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32985. */
  32986. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32987. /**
  32988. * Gets the current auto clear configuration for one rendering group of the rendering
  32989. * manager.
  32990. * @param index the rendering group index to get the information for
  32991. * @returns The auto clear setup for the requested rendering group
  32992. */
  32993. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32994. private _blockMaterialDirtyMechanism;
  32995. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32996. blockMaterialDirtyMechanism: boolean;
  32997. /**
  32998. * Will flag all materials as dirty to trigger new shader compilation
  32999. * @param flag defines the flag used to specify which material part must be marked as dirty
  33000. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33001. */
  33002. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33003. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33004. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33005. }
  33006. }
  33007. declare module BABYLON {
  33008. /**
  33009. * Set of assets to keep when moving a scene into an asset container.
  33010. */
  33011. export class KeepAssets extends AbstractScene {
  33012. }
  33013. /**
  33014. * Container with a set of assets that can be added or removed from a scene.
  33015. */
  33016. export class AssetContainer extends AbstractScene {
  33017. /**
  33018. * The scene the AssetContainer belongs to.
  33019. */
  33020. scene: Scene;
  33021. /**
  33022. * Instantiates an AssetContainer.
  33023. * @param scene The scene the AssetContainer belongs to.
  33024. */
  33025. constructor(scene: Scene);
  33026. /**
  33027. * Adds all the assets from the container to the scene.
  33028. */
  33029. addAllToScene(): void;
  33030. /**
  33031. * Removes all the assets in the container from the scene
  33032. */
  33033. removeAllFromScene(): void;
  33034. /**
  33035. * Disposes all the assets in the container
  33036. */
  33037. dispose(): void;
  33038. private _moveAssets;
  33039. /**
  33040. * Removes all the assets contained in the scene and adds them to the container.
  33041. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33042. */
  33043. moveAllFromScene(keepAssets?: KeepAssets): void;
  33044. /**
  33045. * 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.
  33046. * @returns the root mesh
  33047. */
  33048. createRootMesh(): Mesh;
  33049. }
  33050. }
  33051. declare module BABYLON {
  33052. /**
  33053. * Defines how the parser contract is defined.
  33054. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33055. */
  33056. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33057. /**
  33058. * Defines how the individual parser contract is defined.
  33059. * These parser can parse an individual asset
  33060. */
  33061. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33062. /**
  33063. * Base class of the scene acting as a container for the different elements composing a scene.
  33064. * This class is dynamically extended by the different components of the scene increasing
  33065. * flexibility and reducing coupling
  33066. */
  33067. export abstract class AbstractScene {
  33068. /**
  33069. * Stores the list of available parsers in the application.
  33070. */
  33071. private static _BabylonFileParsers;
  33072. /**
  33073. * Stores the list of available individual parsers in the application.
  33074. */
  33075. private static _IndividualBabylonFileParsers;
  33076. /**
  33077. * Adds a parser in the list of available ones
  33078. * @param name Defines the name of the parser
  33079. * @param parser Defines the parser to add
  33080. */
  33081. static AddParser(name: string, parser: BabylonFileParser): void;
  33082. /**
  33083. * Gets a general parser from the list of avaialble ones
  33084. * @param name Defines the name of the parser
  33085. * @returns the requested parser or null
  33086. */
  33087. static GetParser(name: string): Nullable<BabylonFileParser>;
  33088. /**
  33089. * Adds n individual parser in the list of available ones
  33090. * @param name Defines the name of the parser
  33091. * @param parser Defines the parser to add
  33092. */
  33093. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33094. /**
  33095. * Gets an individual parser from the list of avaialble ones
  33096. * @param name Defines the name of the parser
  33097. * @returns the requested parser or null
  33098. */
  33099. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33100. /**
  33101. * Parser json data and populate both a scene and its associated container object
  33102. * @param jsonData Defines the data to parse
  33103. * @param scene Defines the scene to parse the data for
  33104. * @param container Defines the container attached to the parsing sequence
  33105. * @param rootUrl Defines the root url of the data
  33106. */
  33107. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33108. /**
  33109. * Gets the list of root nodes (ie. nodes with no parent)
  33110. */
  33111. rootNodes: Node[];
  33112. /** All of the cameras added to this scene
  33113. * @see http://doc.babylonjs.com/babylon101/cameras
  33114. */
  33115. cameras: Camera[];
  33116. /**
  33117. * All of the lights added to this scene
  33118. * @see http://doc.babylonjs.com/babylon101/lights
  33119. */
  33120. lights: Light[];
  33121. /**
  33122. * All of the (abstract) meshes added to this scene
  33123. */
  33124. meshes: AbstractMesh[];
  33125. /**
  33126. * The list of skeletons added to the scene
  33127. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33128. */
  33129. skeletons: Skeleton[];
  33130. /**
  33131. * All of the particle systems added to this scene
  33132. * @see http://doc.babylonjs.com/babylon101/particles
  33133. */
  33134. particleSystems: IParticleSystem[];
  33135. /**
  33136. * Gets a list of Animations associated with the scene
  33137. */
  33138. animations: Animation[];
  33139. /**
  33140. * All of the animation groups added to this scene
  33141. * @see http://doc.babylonjs.com/how_to/group
  33142. */
  33143. animationGroups: AnimationGroup[];
  33144. /**
  33145. * All of the multi-materials added to this scene
  33146. * @see http://doc.babylonjs.com/how_to/multi_materials
  33147. */
  33148. multiMaterials: MultiMaterial[];
  33149. /**
  33150. * All of the materials added to this scene
  33151. * In the context of a Scene, it is not supposed to be modified manually.
  33152. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33153. * Note also that the order of the Material wihin the array is not significant and might change.
  33154. * @see http://doc.babylonjs.com/babylon101/materials
  33155. */
  33156. materials: Material[];
  33157. /**
  33158. * The list of morph target managers added to the scene
  33159. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33160. */
  33161. morphTargetManagers: MorphTargetManager[];
  33162. /**
  33163. * The list of geometries used in the scene.
  33164. */
  33165. geometries: Geometry[];
  33166. /**
  33167. * All of the tranform nodes added to this scene
  33168. * In the context of a Scene, it is not supposed to be modified manually.
  33169. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33170. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33171. * @see http://doc.babylonjs.com/how_to/transformnode
  33172. */
  33173. transformNodes: TransformNode[];
  33174. /**
  33175. * ActionManagers available on the scene.
  33176. */
  33177. actionManagers: AbstractActionManager[];
  33178. /**
  33179. * Textures to keep.
  33180. */
  33181. textures: BaseTexture[];
  33182. /**
  33183. * Environment texture for the scene
  33184. */
  33185. environmentTexture: Nullable<BaseTexture>;
  33186. }
  33187. }
  33188. declare module BABYLON {
  33189. /**
  33190. * Defines a sound that can be played in the application.
  33191. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33193. */
  33194. export class Sound {
  33195. /**
  33196. * The name of the sound in the scene.
  33197. */
  33198. name: string;
  33199. /**
  33200. * Does the sound autoplay once loaded.
  33201. */
  33202. autoplay: boolean;
  33203. /**
  33204. * Does the sound loop after it finishes playing once.
  33205. */
  33206. loop: boolean;
  33207. /**
  33208. * Does the sound use a custom attenuation curve to simulate the falloff
  33209. * happening when the source gets further away from the camera.
  33210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33211. */
  33212. useCustomAttenuation: boolean;
  33213. /**
  33214. * The sound track id this sound belongs to.
  33215. */
  33216. soundTrackId: number;
  33217. /**
  33218. * Is this sound currently played.
  33219. */
  33220. isPlaying: boolean;
  33221. /**
  33222. * Is this sound currently paused.
  33223. */
  33224. isPaused: boolean;
  33225. /**
  33226. * Does this sound enables spatial sound.
  33227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33228. */
  33229. spatialSound: boolean;
  33230. /**
  33231. * Define the reference distance the sound should be heard perfectly.
  33232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33233. */
  33234. refDistance: number;
  33235. /**
  33236. * Define the roll off factor of spatial sounds.
  33237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33238. */
  33239. rolloffFactor: number;
  33240. /**
  33241. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33243. */
  33244. maxDistance: number;
  33245. /**
  33246. * Define the distance attenuation model the sound will follow.
  33247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33248. */
  33249. distanceModel: string;
  33250. /**
  33251. * @hidden
  33252. * Back Compat
  33253. **/
  33254. onended: () => any;
  33255. /**
  33256. * Observable event when the current playing sound finishes.
  33257. */
  33258. onEndedObservable: Observable<Sound>;
  33259. private _panningModel;
  33260. private _playbackRate;
  33261. private _streaming;
  33262. private _startTime;
  33263. private _startOffset;
  33264. private _position;
  33265. /** @hidden */ positionInEmitterSpace: boolean;
  33266. private _localDirection;
  33267. private _volume;
  33268. private _isReadyToPlay;
  33269. private _isDirectional;
  33270. private _readyToPlayCallback;
  33271. private _audioBuffer;
  33272. private _soundSource;
  33273. private _streamingSource;
  33274. private _soundPanner;
  33275. private _soundGain;
  33276. private _inputAudioNode;
  33277. private _outputAudioNode;
  33278. private _coneInnerAngle;
  33279. private _coneOuterAngle;
  33280. private _coneOuterGain;
  33281. private _scene;
  33282. private _connectedTransformNode;
  33283. private _customAttenuationFunction;
  33284. private _registerFunc;
  33285. private _isOutputConnected;
  33286. private _htmlAudioElement;
  33287. private _urlType;
  33288. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33289. /**
  33290. * Create a sound and attach it to a scene
  33291. * @param name Name of your sound
  33292. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33293. * @param scene defines the scene the sound belongs to
  33294. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33295. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33296. */
  33297. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33298. /**
  33299. * Release the sound and its associated resources
  33300. */
  33301. dispose(): void;
  33302. /**
  33303. * Gets if the sounds is ready to be played or not.
  33304. * @returns true if ready, otherwise false
  33305. */
  33306. isReady(): boolean;
  33307. private _soundLoaded;
  33308. /**
  33309. * Sets the data of the sound from an audiobuffer
  33310. * @param audioBuffer The audioBuffer containing the data
  33311. */
  33312. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33313. /**
  33314. * Updates the current sounds options such as maxdistance, loop...
  33315. * @param options A JSON object containing values named as the object properties
  33316. */
  33317. updateOptions(options: any): void;
  33318. private _createSpatialParameters;
  33319. private _updateSpatialParameters;
  33320. /**
  33321. * Switch the panning model to HRTF:
  33322. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33324. */
  33325. switchPanningModelToHRTF(): void;
  33326. /**
  33327. * Switch the panning model to Equal Power:
  33328. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33330. */
  33331. switchPanningModelToEqualPower(): void;
  33332. private _switchPanningModel;
  33333. /**
  33334. * Connect this sound to a sound track audio node like gain...
  33335. * @param soundTrackAudioNode the sound track audio node to connect to
  33336. */
  33337. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33338. /**
  33339. * Transform this sound into a directional source
  33340. * @param coneInnerAngle Size of the inner cone in degree
  33341. * @param coneOuterAngle Size of the outer cone in degree
  33342. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33343. */
  33344. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33345. /**
  33346. * Gets or sets the inner angle for the directional cone.
  33347. */
  33348. /**
  33349. * Gets or sets the inner angle for the directional cone.
  33350. */
  33351. directionalConeInnerAngle: number;
  33352. /**
  33353. * Gets or sets the outer angle for the directional cone.
  33354. */
  33355. /**
  33356. * Gets or sets the outer angle for the directional cone.
  33357. */
  33358. directionalConeOuterAngle: number;
  33359. /**
  33360. * Sets the position of the emitter if spatial sound is enabled
  33361. * @param newPosition Defines the new posisiton
  33362. */
  33363. setPosition(newPosition: Vector3): void;
  33364. /**
  33365. * Sets the local direction of the emitter if spatial sound is enabled
  33366. * @param newLocalDirection Defines the new local direction
  33367. */
  33368. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33369. private _updateDirection;
  33370. /** @hidden */
  33371. updateDistanceFromListener(): void;
  33372. /**
  33373. * Sets a new custom attenuation function for the sound.
  33374. * @param callback Defines the function used for the attenuation
  33375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33376. */
  33377. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33378. /**
  33379. * Play the sound
  33380. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33381. * @param offset (optional) Start the sound setting it at a specific time
  33382. */
  33383. play(time?: number, offset?: number): void;
  33384. private _onended;
  33385. /**
  33386. * Stop the sound
  33387. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33388. */
  33389. stop(time?: number): void;
  33390. /**
  33391. * Put the sound in pause
  33392. */
  33393. pause(): void;
  33394. /**
  33395. * Sets a dedicated volume for this sounds
  33396. * @param newVolume Define the new volume of the sound
  33397. * @param time Define in how long the sound should be at this value
  33398. */
  33399. setVolume(newVolume: number, time?: number): void;
  33400. /**
  33401. * Set the sound play back rate
  33402. * @param newPlaybackRate Define the playback rate the sound should be played at
  33403. */
  33404. setPlaybackRate(newPlaybackRate: number): void;
  33405. /**
  33406. * Gets the volume of the sound.
  33407. * @returns the volume of the sound
  33408. */
  33409. getVolume(): number;
  33410. /**
  33411. * Attach the sound to a dedicated mesh
  33412. * @param transformNode The transform node to connect the sound with
  33413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33414. */
  33415. attachToMesh(transformNode: TransformNode): void;
  33416. /**
  33417. * Detach the sound from the previously attached mesh
  33418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33419. */
  33420. detachFromMesh(): void;
  33421. private _onRegisterAfterWorldMatrixUpdate;
  33422. /**
  33423. * Clone the current sound in the scene.
  33424. * @returns the new sound clone
  33425. */
  33426. clone(): Nullable<Sound>;
  33427. /**
  33428. * Gets the current underlying audio buffer containing the data
  33429. * @returns the audio buffer
  33430. */
  33431. getAudioBuffer(): Nullable<AudioBuffer>;
  33432. /**
  33433. * Serializes the Sound in a JSON representation
  33434. * @returns the JSON representation of the sound
  33435. */
  33436. serialize(): any;
  33437. /**
  33438. * Parse a JSON representation of a sound to innstantiate in a given scene
  33439. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33440. * @param scene Define the scene the new parsed sound should be created in
  33441. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33442. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33443. * @returns the newly parsed sound
  33444. */
  33445. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33446. }
  33447. }
  33448. declare module BABYLON {
  33449. /**
  33450. * This defines an action helpful to play a defined sound on a triggered action.
  33451. */
  33452. export class PlaySoundAction extends Action {
  33453. private _sound;
  33454. /**
  33455. * Instantiate the action
  33456. * @param triggerOptions defines the trigger options
  33457. * @param sound defines the sound to play
  33458. * @param condition defines the trigger related conditions
  33459. */
  33460. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33461. /** @hidden */ prepare(): void;
  33462. /**
  33463. * Execute the action and play the sound.
  33464. */
  33465. execute(): void;
  33466. /**
  33467. * Serializes the actions and its related information.
  33468. * @param parent defines the object to serialize in
  33469. * @returns the serialized object
  33470. */
  33471. serialize(parent: any): any;
  33472. }
  33473. /**
  33474. * This defines an action helpful to stop a defined sound on a triggered action.
  33475. */
  33476. export class StopSoundAction extends Action {
  33477. private _sound;
  33478. /**
  33479. * Instantiate the action
  33480. * @param triggerOptions defines the trigger options
  33481. * @param sound defines the sound to stop
  33482. * @param condition defines the trigger related conditions
  33483. */
  33484. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33485. /** @hidden */ prepare(): void;
  33486. /**
  33487. * Execute the action and stop the sound.
  33488. */
  33489. execute(): void;
  33490. /**
  33491. * Serializes the actions and its related information.
  33492. * @param parent defines the object to serialize in
  33493. * @returns the serialized object
  33494. */
  33495. serialize(parent: any): any;
  33496. }
  33497. }
  33498. declare module BABYLON {
  33499. /**
  33500. * This defines an action responsible to change the value of a property
  33501. * by interpolating between its current value and the newly set one once triggered.
  33502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33503. */
  33504. export class InterpolateValueAction extends Action {
  33505. /**
  33506. * Defines the path of the property where the value should be interpolated
  33507. */
  33508. propertyPath: string;
  33509. /**
  33510. * Defines the target value at the end of the interpolation.
  33511. */
  33512. value: any;
  33513. /**
  33514. * Defines the time it will take for the property to interpolate to the value.
  33515. */
  33516. duration: number;
  33517. /**
  33518. * Defines if the other scene animations should be stopped when the action has been triggered
  33519. */
  33520. stopOtherAnimations?: boolean;
  33521. /**
  33522. * Defines a callback raised once the interpolation animation has been done.
  33523. */
  33524. onInterpolationDone?: () => void;
  33525. /**
  33526. * Observable triggered once the interpolation animation has been done.
  33527. */
  33528. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33529. private _target;
  33530. private _effectiveTarget;
  33531. private _property;
  33532. /**
  33533. * Instantiate the action
  33534. * @param triggerOptions defines the trigger options
  33535. * @param target defines the object containing the value to interpolate
  33536. * @param propertyPath defines the path to the property in the target object
  33537. * @param value defines the target value at the end of the interpolation
  33538. * @param duration deines the time it will take for the property to interpolate to the value.
  33539. * @param condition defines the trigger related conditions
  33540. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33541. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33542. */
  33543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33544. /** @hidden */ prepare(): void;
  33545. /**
  33546. * Execute the action starts the value interpolation.
  33547. */
  33548. execute(): void;
  33549. /**
  33550. * Serializes the actions and its related information.
  33551. * @param parent defines the object to serialize in
  33552. * @returns the serialized object
  33553. */
  33554. serialize(parent: any): any;
  33555. }
  33556. }
  33557. declare module BABYLON {
  33558. /**
  33559. * Options allowed during the creation of a sound track.
  33560. */
  33561. export interface ISoundTrackOptions {
  33562. /**
  33563. * The volume the sound track should take during creation
  33564. */
  33565. volume?: number;
  33566. /**
  33567. * Define if the sound track is the main sound track of the scene
  33568. */
  33569. mainTrack?: boolean;
  33570. }
  33571. /**
  33572. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33573. * It will be also used in a future release to apply effects on a specific track.
  33574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33575. */
  33576. export class SoundTrack {
  33577. /**
  33578. * The unique identifier of the sound track in the scene.
  33579. */
  33580. id: number;
  33581. /**
  33582. * The list of sounds included in the sound track.
  33583. */
  33584. soundCollection: Array<Sound>;
  33585. private _outputAudioNode;
  33586. private _scene;
  33587. private _isMainTrack;
  33588. private _connectedAnalyser;
  33589. private _options;
  33590. private _isInitialized;
  33591. /**
  33592. * Creates a new sound track.
  33593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33594. * @param scene Define the scene the sound track belongs to
  33595. * @param options
  33596. */
  33597. constructor(scene: Scene, options?: ISoundTrackOptions);
  33598. private _initializeSoundTrackAudioGraph;
  33599. /**
  33600. * Release the sound track and its associated resources
  33601. */
  33602. dispose(): void;
  33603. /**
  33604. * Adds a sound to this sound track
  33605. * @param sound define the cound to add
  33606. * @ignoreNaming
  33607. */
  33608. AddSound(sound: Sound): void;
  33609. /**
  33610. * Removes a sound to this sound track
  33611. * @param sound define the cound to remove
  33612. * @ignoreNaming
  33613. */
  33614. RemoveSound(sound: Sound): void;
  33615. /**
  33616. * Set a global volume for the full sound track.
  33617. * @param newVolume Define the new volume of the sound track
  33618. */
  33619. setVolume(newVolume: number): void;
  33620. /**
  33621. * Switch the panning model to HRTF:
  33622. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33624. */
  33625. switchPanningModelToHRTF(): void;
  33626. /**
  33627. * Switch the panning model to Equal Power:
  33628. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33630. */
  33631. switchPanningModelToEqualPower(): void;
  33632. /**
  33633. * Connect the sound track to an audio analyser allowing some amazing
  33634. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33636. * @param analyser The analyser to connect to the engine
  33637. */
  33638. connectToAnalyser(analyser: Analyser): void;
  33639. }
  33640. }
  33641. declare module BABYLON {
  33642. interface AbstractScene {
  33643. /**
  33644. * The list of sounds used in the scene.
  33645. */
  33646. sounds: Nullable<Array<Sound>>;
  33647. }
  33648. interface Scene {
  33649. /**
  33650. * @hidden
  33651. * Backing field
  33652. */ mainSoundTrack: SoundTrack;
  33653. /**
  33654. * The main sound track played by the scene.
  33655. * It cotains your primary collection of sounds.
  33656. */
  33657. mainSoundTrack: SoundTrack;
  33658. /**
  33659. * The list of sound tracks added to the scene
  33660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33661. */
  33662. soundTracks: Nullable<Array<SoundTrack>>;
  33663. /**
  33664. * Gets a sound using a given name
  33665. * @param name defines the name to search for
  33666. * @return the found sound or null if not found at all.
  33667. */
  33668. getSoundByName(name: string): Nullable<Sound>;
  33669. /**
  33670. * Gets or sets if audio support is enabled
  33671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33672. */
  33673. audioEnabled: boolean;
  33674. /**
  33675. * Gets or sets if audio will be output to headphones
  33676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33677. */
  33678. headphone: boolean;
  33679. }
  33680. /**
  33681. * Defines the sound scene component responsible to manage any sounds
  33682. * in a given scene.
  33683. */
  33684. export class AudioSceneComponent implements ISceneSerializableComponent {
  33685. /**
  33686. * The component name helpfull to identify the component in the list of scene components.
  33687. */
  33688. readonly name: string;
  33689. /**
  33690. * The scene the component belongs to.
  33691. */
  33692. scene: Scene;
  33693. private _audioEnabled;
  33694. /**
  33695. * Gets whether audio is enabled or not.
  33696. * Please use related enable/disable method to switch state.
  33697. */
  33698. readonly audioEnabled: boolean;
  33699. private _headphone;
  33700. /**
  33701. * Gets whether audio is outputing to headphone or not.
  33702. * Please use the according Switch methods to change output.
  33703. */
  33704. readonly headphone: boolean;
  33705. /**
  33706. * Creates a new instance of the component for the given scene
  33707. * @param scene Defines the scene to register the component in
  33708. */
  33709. constructor(scene: Scene);
  33710. /**
  33711. * Registers the component in a given scene
  33712. */
  33713. register(): void;
  33714. /**
  33715. * Rebuilds the elements related to this component in case of
  33716. * context lost for instance.
  33717. */
  33718. rebuild(): void;
  33719. /**
  33720. * Serializes the component data to the specified json object
  33721. * @param serializationObject The object to serialize to
  33722. */
  33723. serialize(serializationObject: any): void;
  33724. /**
  33725. * Adds all the element from the container to the scene
  33726. * @param container the container holding the elements
  33727. */
  33728. addFromContainer(container: AbstractScene): void;
  33729. /**
  33730. * Removes all the elements in the container from the scene
  33731. * @param container contains the elements to remove
  33732. * @param dispose if the removed element should be disposed (default: false)
  33733. */
  33734. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33735. /**
  33736. * Disposes the component and the associated ressources.
  33737. */
  33738. dispose(): void;
  33739. /**
  33740. * Disables audio in the associated scene.
  33741. */
  33742. disableAudio(): void;
  33743. /**
  33744. * Enables audio in the associated scene.
  33745. */
  33746. enableAudio(): void;
  33747. /**
  33748. * Switch audio to headphone output.
  33749. */
  33750. switchAudioModeForHeadphones(): void;
  33751. /**
  33752. * Switch audio to normal speakers.
  33753. */
  33754. switchAudioModeForNormalSpeakers(): void;
  33755. private _afterRender;
  33756. }
  33757. }
  33758. declare module BABYLON {
  33759. /**
  33760. * Wraps one or more Sound objects and selects one with random weight for playback.
  33761. */
  33762. export class WeightedSound {
  33763. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33764. loop: boolean;
  33765. private _coneInnerAngle;
  33766. private _coneOuterAngle;
  33767. private _volume;
  33768. /** A Sound is currently playing. */
  33769. isPlaying: boolean;
  33770. /** A Sound is currently paused. */
  33771. isPaused: boolean;
  33772. private _sounds;
  33773. private _weights;
  33774. private _currentIndex?;
  33775. /**
  33776. * Creates a new WeightedSound from the list of sounds given.
  33777. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33778. * @param sounds Array of Sounds that will be selected from.
  33779. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33780. */
  33781. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33782. /**
  33783. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33784. */
  33785. /**
  33786. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33787. */
  33788. directionalConeInnerAngle: number;
  33789. /**
  33790. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33791. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33792. */
  33793. /**
  33794. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33795. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33796. */
  33797. directionalConeOuterAngle: number;
  33798. /**
  33799. * Playback volume.
  33800. */
  33801. /**
  33802. * Playback volume.
  33803. */
  33804. volume: number;
  33805. private _onended;
  33806. /**
  33807. * Suspend playback
  33808. */
  33809. pause(): void;
  33810. /**
  33811. * Stop playback
  33812. */
  33813. stop(): void;
  33814. /**
  33815. * Start playback.
  33816. * @param startOffset Position the clip head at a specific time in seconds.
  33817. */
  33818. play(startOffset?: number): void;
  33819. }
  33820. }
  33821. declare module BABYLON {
  33822. /**
  33823. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33824. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33825. */
  33826. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33827. /**
  33828. * Gets the name of the behavior.
  33829. */
  33830. readonly name: string;
  33831. /**
  33832. * The easing function used by animations
  33833. */
  33834. static EasingFunction: BackEase;
  33835. /**
  33836. * The easing mode used by animations
  33837. */
  33838. static EasingMode: number;
  33839. /**
  33840. * The duration of the animation, in milliseconds
  33841. */
  33842. transitionDuration: number;
  33843. /**
  33844. * Length of the distance animated by the transition when lower radius is reached
  33845. */
  33846. lowerRadiusTransitionRange: number;
  33847. /**
  33848. * Length of the distance animated by the transition when upper radius is reached
  33849. */
  33850. upperRadiusTransitionRange: number;
  33851. private _autoTransitionRange;
  33852. /**
  33853. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33854. */
  33855. /**
  33856. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33857. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33858. */
  33859. autoTransitionRange: boolean;
  33860. private _attachedCamera;
  33861. private _onAfterCheckInputsObserver;
  33862. private _onMeshTargetChangedObserver;
  33863. /**
  33864. * Initializes the behavior.
  33865. */
  33866. init(): void;
  33867. /**
  33868. * Attaches the behavior to its arc rotate camera.
  33869. * @param camera Defines the camera to attach the behavior to
  33870. */
  33871. attach(camera: ArcRotateCamera): void;
  33872. /**
  33873. * Detaches the behavior from its current arc rotate camera.
  33874. */
  33875. detach(): void;
  33876. private _radiusIsAnimating;
  33877. private _radiusBounceTransition;
  33878. private _animatables;
  33879. private _cachedWheelPrecision;
  33880. /**
  33881. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33882. * @param radiusLimit The limit to check against.
  33883. * @return Bool to indicate if at limit.
  33884. */
  33885. private _isRadiusAtLimit;
  33886. /**
  33887. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33888. * @param radiusDelta The delta by which to animate to. Can be negative.
  33889. */
  33890. private _applyBoundRadiusAnimation;
  33891. /**
  33892. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33893. */
  33894. protected _clearAnimationLocks(): void;
  33895. /**
  33896. * Stops and removes all animations that have been applied to the camera
  33897. */
  33898. stopAllAnimations(): void;
  33899. }
  33900. }
  33901. declare module BABYLON {
  33902. /**
  33903. * 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.
  33904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33905. */
  33906. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33907. /**
  33908. * Gets the name of the behavior.
  33909. */
  33910. readonly name: string;
  33911. private _mode;
  33912. private _radiusScale;
  33913. private _positionScale;
  33914. private _defaultElevation;
  33915. private _elevationReturnTime;
  33916. private _elevationReturnWaitTime;
  33917. private _zoomStopsAnimation;
  33918. private _framingTime;
  33919. /**
  33920. * The easing function used by animations
  33921. */
  33922. static EasingFunction: ExponentialEase;
  33923. /**
  33924. * The easing mode used by animations
  33925. */
  33926. static EasingMode: number;
  33927. /**
  33928. * Sets the current mode used by the behavior
  33929. */
  33930. /**
  33931. * Gets current mode used by the behavior.
  33932. */
  33933. mode: number;
  33934. /**
  33935. * Sets the scale applied to the radius (1 by default)
  33936. */
  33937. /**
  33938. * Gets the scale applied to the radius
  33939. */
  33940. radiusScale: number;
  33941. /**
  33942. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33943. */
  33944. /**
  33945. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33946. */
  33947. positionScale: number;
  33948. /**
  33949. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33950. * behaviour is triggered, in radians.
  33951. */
  33952. /**
  33953. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33954. * behaviour is triggered, in radians.
  33955. */
  33956. defaultElevation: number;
  33957. /**
  33958. * Sets the time (in milliseconds) taken to return to the default beta position.
  33959. * Negative value indicates camera should not return to default.
  33960. */
  33961. /**
  33962. * Gets the time (in milliseconds) taken to return to the default beta position.
  33963. * Negative value indicates camera should not return to default.
  33964. */
  33965. elevationReturnTime: number;
  33966. /**
  33967. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33968. */
  33969. /**
  33970. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33971. */
  33972. elevationReturnWaitTime: number;
  33973. /**
  33974. * Sets the flag that indicates if user zooming should stop animation.
  33975. */
  33976. /**
  33977. * Gets the flag that indicates if user zooming should stop animation.
  33978. */
  33979. zoomStopsAnimation: boolean;
  33980. /**
  33981. * Sets the transition time when framing the mesh, in milliseconds
  33982. */
  33983. /**
  33984. * Gets the transition time when framing the mesh, in milliseconds
  33985. */
  33986. framingTime: number;
  33987. /**
  33988. * Define if the behavior should automatically change the configured
  33989. * camera limits and sensibilities.
  33990. */
  33991. autoCorrectCameraLimitsAndSensibility: boolean;
  33992. private _onPrePointerObservableObserver;
  33993. private _onAfterCheckInputsObserver;
  33994. private _onMeshTargetChangedObserver;
  33995. private _attachedCamera;
  33996. private _isPointerDown;
  33997. private _lastInteractionTime;
  33998. /**
  33999. * Initializes the behavior.
  34000. */
  34001. init(): void;
  34002. /**
  34003. * Attaches the behavior to its arc rotate camera.
  34004. * @param camera Defines the camera to attach the behavior to
  34005. */
  34006. attach(camera: ArcRotateCamera): void;
  34007. /**
  34008. * Detaches the behavior from its current arc rotate camera.
  34009. */
  34010. detach(): void;
  34011. private _animatables;
  34012. private _betaIsAnimating;
  34013. private _betaTransition;
  34014. private _radiusTransition;
  34015. private _vectorTransition;
  34016. /**
  34017. * Targets the given mesh and updates zoom level accordingly.
  34018. * @param mesh The mesh to target.
  34019. * @param radius Optional. If a cached radius position already exists, overrides default.
  34020. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34021. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34022. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34023. */
  34024. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34025. /**
  34026. * Targets the given mesh with its children and updates zoom level accordingly.
  34027. * @param mesh The mesh to target.
  34028. * @param radius Optional. If a cached radius position already exists, overrides default.
  34029. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34030. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34031. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34032. */
  34033. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34034. /**
  34035. * Targets the given meshes with their children and updates zoom level accordingly.
  34036. * @param meshes The mesh to target.
  34037. * @param radius Optional. If a cached radius position already exists, overrides default.
  34038. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34039. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34040. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34041. */
  34042. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34043. /**
  34044. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34045. * @param minimumWorld Determines the smaller position of the bounding box extend
  34046. * @param maximumWorld Determines the bigger position of the bounding box extend
  34047. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34048. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34049. */
  34050. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34051. /**
  34052. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34053. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34054. * frustum width.
  34055. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34056. * to fully enclose the mesh in the viewing frustum.
  34057. */
  34058. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34059. /**
  34060. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34061. * is automatically returned to its default position (expected to be above ground plane).
  34062. */
  34063. private _maintainCameraAboveGround;
  34064. /**
  34065. * Returns the frustum slope based on the canvas ratio and camera FOV
  34066. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34067. */
  34068. private _getFrustumSlope;
  34069. /**
  34070. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34071. */
  34072. private _clearAnimationLocks;
  34073. /**
  34074. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34075. */
  34076. private _applyUserInteraction;
  34077. /**
  34078. * Stops and removes all animations that have been applied to the camera
  34079. */
  34080. stopAllAnimations(): void;
  34081. /**
  34082. * Gets a value indicating if the user is moving the camera
  34083. */
  34084. readonly isUserIsMoving: boolean;
  34085. /**
  34086. * The camera can move all the way towards the mesh.
  34087. */
  34088. static IgnoreBoundsSizeMode: number;
  34089. /**
  34090. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34091. */
  34092. static FitFrustumSidesMode: number;
  34093. }
  34094. }
  34095. declare module BABYLON {
  34096. /**
  34097. * Base class for Camera Pointer Inputs.
  34098. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34099. * for example usage.
  34100. */
  34101. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34102. /**
  34103. * Defines the camera the input is attached to.
  34104. */
  34105. abstract camera: Camera;
  34106. /**
  34107. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34108. */
  34109. protected _altKey: boolean;
  34110. protected _ctrlKey: boolean;
  34111. protected _metaKey: boolean;
  34112. protected _shiftKey: boolean;
  34113. /**
  34114. * Which mouse buttons were pressed at time of last mouse event.
  34115. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34116. */
  34117. protected _buttonsPressed: number;
  34118. /**
  34119. * Defines the buttons associated with the input to handle camera move.
  34120. */
  34121. buttons: number[];
  34122. /**
  34123. * Attach the input controls to a specific dom element to get the input from.
  34124. * @param element Defines the element the controls should be listened from
  34125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34126. */
  34127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34128. /**
  34129. * Detach the current controls from the specified dom element.
  34130. * @param element Defines the element to stop listening the inputs from
  34131. */
  34132. detachControl(element: Nullable<HTMLElement>): void;
  34133. /**
  34134. * Gets the class name of the current input.
  34135. * @returns the class name
  34136. */
  34137. getClassName(): string;
  34138. /**
  34139. * Get the friendly name associated with the input class.
  34140. * @returns the input friendly name
  34141. */
  34142. getSimpleName(): string;
  34143. /**
  34144. * Called on pointer POINTERDOUBLETAP event.
  34145. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34146. */
  34147. protected onDoubleTap(type: string): void;
  34148. /**
  34149. * Called on pointer POINTERMOVE event if only a single touch is active.
  34150. * Override this method to provide functionality.
  34151. */
  34152. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34153. /**
  34154. * Called on pointer POINTERMOVE event if multiple touches are active.
  34155. * Override this method to provide functionality.
  34156. */
  34157. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34158. /**
  34159. * Called on JS contextmenu event.
  34160. * Override this method to provide functionality.
  34161. */
  34162. protected onContextMenu(evt: PointerEvent): void;
  34163. /**
  34164. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34165. * press.
  34166. * Override this method to provide functionality.
  34167. */
  34168. protected onButtonDown(evt: PointerEvent): void;
  34169. /**
  34170. * Called each time a new POINTERUP event occurs. Ie, for each button
  34171. * release.
  34172. * Override this method to provide functionality.
  34173. */
  34174. protected onButtonUp(evt: PointerEvent): void;
  34175. /**
  34176. * Called when window becomes inactive.
  34177. * Override this method to provide functionality.
  34178. */
  34179. protected onLostFocus(): void;
  34180. private _pointerInput;
  34181. private _observer;
  34182. private _onLostFocus;
  34183. private pointA;
  34184. private pointB;
  34185. }
  34186. }
  34187. declare module BABYLON {
  34188. /**
  34189. * Manage the pointers inputs to control an arc rotate camera.
  34190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34191. */
  34192. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34193. /**
  34194. * Defines the camera the input is attached to.
  34195. */
  34196. camera: ArcRotateCamera;
  34197. /**
  34198. * Gets the class name of the current input.
  34199. * @returns the class name
  34200. */
  34201. getClassName(): string;
  34202. /**
  34203. * Defines the buttons associated with the input to handle camera move.
  34204. */
  34205. buttons: number[];
  34206. /**
  34207. * Defines the pointer angular sensibility along the X axis or how fast is
  34208. * the camera rotating.
  34209. */
  34210. angularSensibilityX: number;
  34211. /**
  34212. * Defines the pointer angular sensibility along the Y axis or how fast is
  34213. * the camera rotating.
  34214. */
  34215. angularSensibilityY: number;
  34216. /**
  34217. * Defines the pointer pinch precision or how fast is the camera zooming.
  34218. */
  34219. pinchPrecision: number;
  34220. /**
  34221. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34222. * from 0.
  34223. * It defines the percentage of current camera.radius to use as delta when
  34224. * pinch zoom is used.
  34225. */
  34226. pinchDeltaPercentage: number;
  34227. /**
  34228. * Defines the pointer panning sensibility or how fast is the camera moving.
  34229. */
  34230. panningSensibility: number;
  34231. /**
  34232. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34233. */
  34234. multiTouchPanning: boolean;
  34235. /**
  34236. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34237. * zoom (pinch) through multitouch.
  34238. */
  34239. multiTouchPanAndZoom: boolean;
  34240. /**
  34241. * Revers pinch action direction.
  34242. */
  34243. pinchInwards: boolean;
  34244. private _isPanClick;
  34245. private _twoFingerActivityCount;
  34246. private _isPinching;
  34247. /**
  34248. * Called on pointer POINTERMOVE event if only a single touch is active.
  34249. */
  34250. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34251. /**
  34252. * Called on pointer POINTERDOUBLETAP event.
  34253. */
  34254. protected onDoubleTap(type: string): void;
  34255. /**
  34256. * Called on pointer POINTERMOVE event if multiple touches are active.
  34257. */
  34258. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34259. /**
  34260. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34261. * press.
  34262. */
  34263. protected onButtonDown(evt: PointerEvent): void;
  34264. /**
  34265. * Called each time a new POINTERUP event occurs. Ie, for each button
  34266. * release.
  34267. */
  34268. protected onButtonUp(evt: PointerEvent): void;
  34269. /**
  34270. * Called when window becomes inactive.
  34271. */
  34272. protected onLostFocus(): void;
  34273. }
  34274. }
  34275. declare module BABYLON {
  34276. /**
  34277. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34279. */
  34280. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34281. /**
  34282. * Defines the camera the input is attached to.
  34283. */
  34284. camera: ArcRotateCamera;
  34285. /**
  34286. * Defines the list of key codes associated with the up action (increase alpha)
  34287. */
  34288. keysUp: number[];
  34289. /**
  34290. * Defines the list of key codes associated with the down action (decrease alpha)
  34291. */
  34292. keysDown: number[];
  34293. /**
  34294. * Defines the list of key codes associated with the left action (increase beta)
  34295. */
  34296. keysLeft: number[];
  34297. /**
  34298. * Defines the list of key codes associated with the right action (decrease beta)
  34299. */
  34300. keysRight: number[];
  34301. /**
  34302. * Defines the list of key codes associated with the reset action.
  34303. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34304. */
  34305. keysReset: number[];
  34306. /**
  34307. * Defines the panning sensibility of the inputs.
  34308. * (How fast is the camera paning)
  34309. */
  34310. panningSensibility: number;
  34311. /**
  34312. * Defines the zooming sensibility of the inputs.
  34313. * (How fast is the camera zooming)
  34314. */
  34315. zoomingSensibility: number;
  34316. /**
  34317. * Defines wether maintaining the alt key down switch the movement mode from
  34318. * orientation to zoom.
  34319. */
  34320. useAltToZoom: boolean;
  34321. /**
  34322. * Rotation speed of the camera
  34323. */
  34324. angularSpeed: number;
  34325. private _keys;
  34326. private _ctrlPressed;
  34327. private _altPressed;
  34328. private _onCanvasBlurObserver;
  34329. private _onKeyboardObserver;
  34330. private _engine;
  34331. private _scene;
  34332. /**
  34333. * Attach the input controls to a specific dom element to get the input from.
  34334. * @param element Defines the element the controls should be listened from
  34335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34336. */
  34337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34338. /**
  34339. * Detach the current controls from the specified dom element.
  34340. * @param element Defines the element to stop listening the inputs from
  34341. */
  34342. detachControl(element: Nullable<HTMLElement>): void;
  34343. /**
  34344. * Update the current camera state depending on the inputs that have been used this frame.
  34345. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34346. */
  34347. checkInputs(): void;
  34348. /**
  34349. * Gets the class name of the current intput.
  34350. * @returns the class name
  34351. */
  34352. getClassName(): string;
  34353. /**
  34354. * Get the friendly name associated with the input class.
  34355. * @returns the input friendly name
  34356. */
  34357. getSimpleName(): string;
  34358. }
  34359. }
  34360. declare module BABYLON {
  34361. /**
  34362. * Manage the mouse wheel inputs to control an arc rotate camera.
  34363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34364. */
  34365. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34366. /**
  34367. * Defines the camera the input is attached to.
  34368. */
  34369. camera: ArcRotateCamera;
  34370. /**
  34371. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34372. */
  34373. wheelPrecision: number;
  34374. /**
  34375. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34376. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34377. */
  34378. wheelDeltaPercentage: number;
  34379. private _wheel;
  34380. private _observer;
  34381. /**
  34382. * Attach the input controls to a specific dom element to get the input from.
  34383. * @param element Defines the element the controls should be listened from
  34384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34385. */
  34386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34387. /**
  34388. * Detach the current controls from the specified dom element.
  34389. * @param element Defines the element to stop listening the inputs from
  34390. */
  34391. detachControl(element: Nullable<HTMLElement>): void;
  34392. /**
  34393. * Gets the class name of the current intput.
  34394. * @returns the class name
  34395. */
  34396. getClassName(): string;
  34397. /**
  34398. * Get the friendly name associated with the input class.
  34399. * @returns the input friendly name
  34400. */
  34401. getSimpleName(): string;
  34402. }
  34403. }
  34404. declare module BABYLON {
  34405. /**
  34406. * Default Inputs manager for the ArcRotateCamera.
  34407. * It groups all the default supported inputs for ease of use.
  34408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34409. */
  34410. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34411. /**
  34412. * Instantiates a new ArcRotateCameraInputsManager.
  34413. * @param camera Defines the camera the inputs belong to
  34414. */
  34415. constructor(camera: ArcRotateCamera);
  34416. /**
  34417. * Add mouse wheel input support to the input manager.
  34418. * @returns the current input manager
  34419. */
  34420. addMouseWheel(): ArcRotateCameraInputsManager;
  34421. /**
  34422. * Add pointers input support to the input manager.
  34423. * @returns the current input manager
  34424. */
  34425. addPointers(): ArcRotateCameraInputsManager;
  34426. /**
  34427. * Add keyboard input support to the input manager.
  34428. * @returns the current input manager
  34429. */
  34430. addKeyboard(): ArcRotateCameraInputsManager;
  34431. }
  34432. }
  34433. declare module BABYLON {
  34434. /**
  34435. * This represents an orbital type of camera.
  34436. *
  34437. * 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.
  34438. * 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.
  34439. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34440. */
  34441. export class ArcRotateCamera extends TargetCamera {
  34442. /**
  34443. * Defines the rotation angle of the camera along the longitudinal axis.
  34444. */
  34445. alpha: number;
  34446. /**
  34447. * Defines the rotation angle of the camera along the latitudinal axis.
  34448. */
  34449. beta: number;
  34450. /**
  34451. * Defines the radius of the camera from it s target point.
  34452. */
  34453. radius: number;
  34454. protected _target: Vector3;
  34455. protected _targetHost: Nullable<AbstractMesh>;
  34456. /**
  34457. * Defines the target point of the camera.
  34458. * The camera looks towards it form the radius distance.
  34459. */
  34460. target: Vector3;
  34461. /**
  34462. * Define the current local position of the camera in the scene
  34463. */
  34464. position: Vector3;
  34465. protected _upVector: Vector3;
  34466. protected _upToYMatrix: Matrix;
  34467. protected _YToUpMatrix: Matrix;
  34468. /**
  34469. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34470. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34471. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34472. */
  34473. upVector: Vector3;
  34474. /**
  34475. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34476. */
  34477. setMatUp(): void;
  34478. /**
  34479. * Current inertia value on the longitudinal axis.
  34480. * The bigger this number the longer it will take for the camera to stop.
  34481. */
  34482. inertialAlphaOffset: number;
  34483. /**
  34484. * Current inertia value on the latitudinal axis.
  34485. * The bigger this number the longer it will take for the camera to stop.
  34486. */
  34487. inertialBetaOffset: number;
  34488. /**
  34489. * Current inertia value on the radius axis.
  34490. * The bigger this number the longer it will take for the camera to stop.
  34491. */
  34492. inertialRadiusOffset: number;
  34493. /**
  34494. * Minimum allowed angle on the longitudinal axis.
  34495. * This can help limiting how the Camera is able to move in the scene.
  34496. */
  34497. lowerAlphaLimit: Nullable<number>;
  34498. /**
  34499. * Maximum allowed angle on the longitudinal axis.
  34500. * This can help limiting how the Camera is able to move in the scene.
  34501. */
  34502. upperAlphaLimit: Nullable<number>;
  34503. /**
  34504. * Minimum allowed angle on the latitudinal axis.
  34505. * This can help limiting how the Camera is able to move in the scene.
  34506. */
  34507. lowerBetaLimit: number;
  34508. /**
  34509. * Maximum allowed angle on the latitudinal axis.
  34510. * This can help limiting how the Camera is able to move in the scene.
  34511. */
  34512. upperBetaLimit: number;
  34513. /**
  34514. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34515. * This can help limiting how the Camera is able to move in the scene.
  34516. */
  34517. lowerRadiusLimit: Nullable<number>;
  34518. /**
  34519. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34520. * This can help limiting how the Camera is able to move in the scene.
  34521. */
  34522. upperRadiusLimit: Nullable<number>;
  34523. /**
  34524. * Defines the current inertia value used during panning of the camera along the X axis.
  34525. */
  34526. inertialPanningX: number;
  34527. /**
  34528. * Defines the current inertia value used during panning of the camera along the Y axis.
  34529. */
  34530. inertialPanningY: number;
  34531. /**
  34532. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34533. * Basically if your fingers moves away from more than this distance you will be considered
  34534. * in pinch mode.
  34535. */
  34536. pinchToPanMaxDistance: number;
  34537. /**
  34538. * Defines the maximum distance the camera can pan.
  34539. * This could help keeping the cammera always in your scene.
  34540. */
  34541. panningDistanceLimit: Nullable<number>;
  34542. /**
  34543. * Defines the target of the camera before paning.
  34544. */
  34545. panningOriginTarget: Vector3;
  34546. /**
  34547. * Defines the value of the inertia used during panning.
  34548. * 0 would mean stop inertia and one would mean no decelleration at all.
  34549. */
  34550. panningInertia: number;
  34551. /**
  34552. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34553. */
  34554. angularSensibilityX: number;
  34555. /**
  34556. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34557. */
  34558. angularSensibilityY: number;
  34559. /**
  34560. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34561. */
  34562. pinchPrecision: number;
  34563. /**
  34564. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34565. * It will be used instead of pinchDeltaPrecision if different from 0.
  34566. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34567. */
  34568. pinchDeltaPercentage: number;
  34569. /**
  34570. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34571. */
  34572. panningSensibility: number;
  34573. /**
  34574. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34575. */
  34576. keysUp: number[];
  34577. /**
  34578. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34579. */
  34580. keysDown: number[];
  34581. /**
  34582. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34583. */
  34584. keysLeft: number[];
  34585. /**
  34586. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34587. */
  34588. keysRight: number[];
  34589. /**
  34590. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34591. */
  34592. wheelPrecision: number;
  34593. /**
  34594. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34595. * It will be used instead of pinchDeltaPrecision if different from 0.
  34596. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34597. */
  34598. wheelDeltaPercentage: number;
  34599. /**
  34600. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34601. */
  34602. zoomOnFactor: number;
  34603. /**
  34604. * Defines a screen offset for the camera position.
  34605. */
  34606. targetScreenOffset: Vector2;
  34607. /**
  34608. * Allows the camera to be completely reversed.
  34609. * If false the camera can not arrive upside down.
  34610. */
  34611. allowUpsideDown: boolean;
  34612. /**
  34613. * Define if double tap/click is used to restore the previously saved state of the camera.
  34614. */
  34615. useInputToRestoreState: boolean;
  34616. /** @hidden */ viewMatrix: Matrix;
  34617. /** @hidden */ useCtrlForPanning: boolean;
  34618. /** @hidden */ panningMouseButton: number;
  34619. /**
  34620. * Defines the input associated to the camera.
  34621. */
  34622. inputs: ArcRotateCameraInputsManager;
  34623. /** @hidden */ reset: () => void;
  34624. /**
  34625. * Defines the allowed panning axis.
  34626. */
  34627. panningAxis: Vector3;
  34628. protected _localDirection: Vector3;
  34629. protected _transformedDirection: Vector3;
  34630. private _bouncingBehavior;
  34631. /**
  34632. * Gets the bouncing behavior of the camera if it has been enabled.
  34633. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34634. */
  34635. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34636. /**
  34637. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34638. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34639. */
  34640. useBouncingBehavior: boolean;
  34641. private _framingBehavior;
  34642. /**
  34643. * Gets the framing behavior of the camera if it has been enabled.
  34644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34645. */
  34646. readonly framingBehavior: Nullable<FramingBehavior>;
  34647. /**
  34648. * Defines if the framing behavior of the camera is enabled on the camera.
  34649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34650. */
  34651. useFramingBehavior: boolean;
  34652. private _autoRotationBehavior;
  34653. /**
  34654. * Gets the auto rotation behavior of the camera if it has been enabled.
  34655. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34656. */
  34657. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34658. /**
  34659. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34661. */
  34662. useAutoRotationBehavior: boolean;
  34663. /**
  34664. * Observable triggered when the mesh target has been changed on the camera.
  34665. */
  34666. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34667. /**
  34668. * Event raised when the camera is colliding with a mesh.
  34669. */
  34670. onCollide: (collidedMesh: AbstractMesh) => void;
  34671. /**
  34672. * Defines whether the camera should check collision with the objects oh the scene.
  34673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34674. */
  34675. checkCollisions: boolean;
  34676. /**
  34677. * Defines the collision radius of the camera.
  34678. * This simulates a sphere around the camera.
  34679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34680. */
  34681. collisionRadius: Vector3;
  34682. protected _collider: Collider;
  34683. protected _previousPosition: Vector3;
  34684. protected _collisionVelocity: Vector3;
  34685. protected _newPosition: Vector3;
  34686. protected _previousAlpha: number;
  34687. protected _previousBeta: number;
  34688. protected _previousRadius: number;
  34689. protected _collisionTriggered: boolean;
  34690. protected _targetBoundingCenter: Nullable<Vector3>;
  34691. private _computationVector;
  34692. /**
  34693. * Instantiates a new ArcRotateCamera in a given scene
  34694. * @param name Defines the name of the camera
  34695. * @param alpha Defines the camera rotation along the logitudinal axis
  34696. * @param beta Defines the camera rotation along the latitudinal axis
  34697. * @param radius Defines the camera distance from its target
  34698. * @param target Defines the camera target
  34699. * @param scene Defines the scene the camera belongs to
  34700. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34701. */
  34702. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34703. /** @hidden */ initCache(): void;
  34704. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34705. protected _getTargetPosition(): Vector3;
  34706. private _storedAlpha;
  34707. private _storedBeta;
  34708. private _storedRadius;
  34709. private _storedTarget;
  34710. /**
  34711. * Stores the current state of the camera (alpha, beta, radius and target)
  34712. * @returns the camera itself
  34713. */
  34714. storeState(): Camera;
  34715. /**
  34716. * @hidden
  34717. * Restored camera state. You must call storeState() first
  34718. */ restoreStateValues(): boolean;
  34719. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34720. /**
  34721. * Attached controls to the current camera.
  34722. * @param element Defines the element the controls should be listened from
  34723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34724. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34725. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34726. */
  34727. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34728. /**
  34729. * Detach the current controls from the camera.
  34730. * The camera will stop reacting to inputs.
  34731. * @param element Defines the element to stop listening the inputs from
  34732. */
  34733. detachControl(element: HTMLElement): void;
  34734. /** @hidden */ checkInputs(): void;
  34735. protected _checkLimits(): void;
  34736. /**
  34737. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34738. */
  34739. rebuildAnglesAndRadius(): void;
  34740. /**
  34741. * Use a position to define the current camera related information like aplha, beta and radius
  34742. * @param position Defines the position to set the camera at
  34743. */
  34744. setPosition(position: Vector3): void;
  34745. /**
  34746. * Defines the target the camera should look at.
  34747. * This will automatically adapt alpha beta and radius to fit within the new target.
  34748. * @param target Defines the new target as a Vector or a mesh
  34749. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34750. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34751. */
  34752. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34753. /** @hidden */ getViewMatrix(): Matrix;
  34754. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34755. /**
  34756. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34757. * @param meshes Defines the mesh to zoom on
  34758. * @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)
  34759. */
  34760. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34761. /**
  34762. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34763. * The target will be changed but the radius
  34764. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34765. * @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)
  34766. */
  34767. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34768. min: Vector3;
  34769. max: Vector3;
  34770. distance: number;
  34771. }, doNotUpdateMaxZ?: boolean): void;
  34772. /**
  34773. * @override
  34774. * Override Camera.createRigCamera
  34775. */
  34776. createRigCamera(name: string, cameraIndex: number): Camera;
  34777. /**
  34778. * @hidden
  34779. * @override
  34780. * Override Camera._updateRigCameras
  34781. */ updateRigCameras(): void;
  34782. /**
  34783. * Destroy the camera and release the current resources hold by it.
  34784. */
  34785. dispose(): void;
  34786. /**
  34787. * Gets the current object class name.
  34788. * @return the class name
  34789. */
  34790. getClassName(): string;
  34791. }
  34792. }
  34793. declare module BABYLON {
  34794. /**
  34795. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34797. */
  34798. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34799. /**
  34800. * Gets the name of the behavior.
  34801. */
  34802. readonly name: string;
  34803. private _zoomStopsAnimation;
  34804. private _idleRotationSpeed;
  34805. private _idleRotationWaitTime;
  34806. private _idleRotationSpinupTime;
  34807. /**
  34808. * Sets the flag that indicates if user zooming should stop animation.
  34809. */
  34810. /**
  34811. * Gets the flag that indicates if user zooming should stop animation.
  34812. */
  34813. zoomStopsAnimation: boolean;
  34814. /**
  34815. * Sets the default speed at which the camera rotates around the model.
  34816. */
  34817. /**
  34818. * Gets the default speed at which the camera rotates around the model.
  34819. */
  34820. idleRotationSpeed: number;
  34821. /**
  34822. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34823. */
  34824. /**
  34825. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34826. */
  34827. idleRotationWaitTime: number;
  34828. /**
  34829. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34830. */
  34831. /**
  34832. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34833. */
  34834. idleRotationSpinupTime: number;
  34835. /**
  34836. * Gets a value indicating if the camera is currently rotating because of this behavior
  34837. */
  34838. readonly rotationInProgress: boolean;
  34839. private _onPrePointerObservableObserver;
  34840. private _onAfterCheckInputsObserver;
  34841. private _attachedCamera;
  34842. private _isPointerDown;
  34843. private _lastFrameTime;
  34844. private _lastInteractionTime;
  34845. private _cameraRotationSpeed;
  34846. /**
  34847. * Initializes the behavior.
  34848. */
  34849. init(): void;
  34850. /**
  34851. * Attaches the behavior to its arc rotate camera.
  34852. * @param camera Defines the camera to attach the behavior to
  34853. */
  34854. attach(camera: ArcRotateCamera): void;
  34855. /**
  34856. * Detaches the behavior from its current arc rotate camera.
  34857. */
  34858. detach(): void;
  34859. /**
  34860. * Returns true if user is scrolling.
  34861. * @return true if user is scrolling.
  34862. */
  34863. private _userIsZooming;
  34864. private _lastFrameRadius;
  34865. private _shouldAnimationStopForInteraction;
  34866. /**
  34867. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34868. */
  34869. private _applyUserInteraction;
  34870. private _userIsMoving;
  34871. }
  34872. }
  34873. declare module BABYLON {
  34874. /**
  34875. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34876. */
  34877. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34878. private ui;
  34879. /**
  34880. * The name of the behavior
  34881. */
  34882. name: string;
  34883. /**
  34884. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34885. */
  34886. distanceAwayFromFace: number;
  34887. /**
  34888. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34889. */
  34890. distanceAwayFromBottomOfFace: number;
  34891. private _faceVectors;
  34892. private _target;
  34893. private _scene;
  34894. private _onRenderObserver;
  34895. private _tmpMatrix;
  34896. private _tmpVector;
  34897. /**
  34898. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34899. * @param ui The transform node that should be attched to the mesh
  34900. */
  34901. constructor(ui: TransformNode);
  34902. /**
  34903. * Initializes the behavior
  34904. */
  34905. init(): void;
  34906. private _closestFace;
  34907. private _zeroVector;
  34908. private _lookAtTmpMatrix;
  34909. private _lookAtToRef;
  34910. /**
  34911. * Attaches the AttachToBoxBehavior to the passed in mesh
  34912. * @param target The mesh that the specified node will be attached to
  34913. */
  34914. attach(target: Mesh): void;
  34915. /**
  34916. * Detaches the behavior from the mesh
  34917. */
  34918. detach(): void;
  34919. }
  34920. }
  34921. declare module BABYLON {
  34922. /**
  34923. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34924. */
  34925. export class FadeInOutBehavior implements Behavior<Mesh> {
  34926. /**
  34927. * Time in milliseconds to delay before fading in (Default: 0)
  34928. */
  34929. delay: number;
  34930. /**
  34931. * Time in milliseconds for the mesh to fade in (Default: 300)
  34932. */
  34933. fadeInTime: number;
  34934. private _millisecondsPerFrame;
  34935. private _hovered;
  34936. private _hoverValue;
  34937. private _ownerNode;
  34938. /**
  34939. * Instatiates the FadeInOutBehavior
  34940. */
  34941. constructor();
  34942. /**
  34943. * The name of the behavior
  34944. */
  34945. readonly name: string;
  34946. /**
  34947. * Initializes the behavior
  34948. */
  34949. init(): void;
  34950. /**
  34951. * Attaches the fade behavior on the passed in mesh
  34952. * @param ownerNode The mesh that will be faded in/out once attached
  34953. */
  34954. attach(ownerNode: Mesh): void;
  34955. /**
  34956. * Detaches the behavior from the mesh
  34957. */
  34958. detach(): void;
  34959. /**
  34960. * Triggers the mesh to begin fading in or out
  34961. * @param value if the object should fade in or out (true to fade in)
  34962. */
  34963. fadeIn(value: boolean): void;
  34964. private _update;
  34965. private _setAllVisibility;
  34966. }
  34967. }
  34968. declare module BABYLON {
  34969. /**
  34970. * Class containing a set of static utilities functions for managing Pivots
  34971. * @hidden
  34972. */
  34973. export class PivotTools {
  34974. private static _PivotCached;
  34975. private static _OldPivotPoint;
  34976. private static _PivotTranslation;
  34977. private static _PivotTmpVector;
  34978. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34979. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34980. }
  34981. }
  34982. declare module BABYLON {
  34983. /**
  34984. * Class containing static functions to help procedurally build meshes
  34985. */
  34986. export class PlaneBuilder {
  34987. /**
  34988. * Creates a plane mesh
  34989. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34990. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34991. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34993. * * 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
  34994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34995. * @param name defines the name of the mesh
  34996. * @param options defines the options used to create the mesh
  34997. * @param scene defines the hosting scene
  34998. * @returns the plane mesh
  34999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35000. */
  35001. static CreatePlane(name: string, options: {
  35002. size?: number;
  35003. width?: number;
  35004. height?: number;
  35005. sideOrientation?: number;
  35006. frontUVs?: Vector4;
  35007. backUVs?: Vector4;
  35008. updatable?: boolean;
  35009. sourcePlane?: Plane;
  35010. }, scene?: Nullable<Scene>): Mesh;
  35011. }
  35012. }
  35013. declare module BABYLON {
  35014. /**
  35015. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35016. */
  35017. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35018. private static _AnyMouseID;
  35019. private _attachedNode;
  35020. private _dragPlane;
  35021. private _scene;
  35022. private _pointerObserver;
  35023. private _beforeRenderObserver;
  35024. private static _planeScene;
  35025. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35026. /**
  35027. * 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)
  35028. */
  35029. maxDragAngle: number;
  35030. /**
  35031. * @hidden
  35032. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  35033. /**
  35034. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35035. */
  35036. currentDraggingPointerID: number;
  35037. /**
  35038. * The last position where the pointer hit the drag plane in world space
  35039. */
  35040. lastDragPosition: Vector3;
  35041. /**
  35042. * If the behavior is currently in a dragging state
  35043. */
  35044. dragging: boolean;
  35045. /**
  35046. * 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)
  35047. */
  35048. dragDeltaRatio: number;
  35049. /**
  35050. * If the drag plane orientation should be updated during the dragging (Default: true)
  35051. */
  35052. updateDragPlane: boolean;
  35053. private _debugMode;
  35054. private _moving;
  35055. /**
  35056. * Fires each time the attached mesh is dragged with the pointer
  35057. * * delta between last drag position and current drag position in world space
  35058. * * dragDistance along the drag axis
  35059. * * dragPlaneNormal normal of the current drag plane used during the drag
  35060. * * dragPlanePoint in world space where the drag intersects the drag plane
  35061. */
  35062. onDragObservable: Observable<{
  35063. delta: Vector3;
  35064. dragPlanePoint: Vector3;
  35065. dragPlaneNormal: Vector3;
  35066. dragDistance: number;
  35067. pointerId: number;
  35068. }>;
  35069. /**
  35070. * Fires each time a drag begins (eg. mouse down on mesh)
  35071. */
  35072. onDragStartObservable: Observable<{
  35073. dragPlanePoint: Vector3;
  35074. pointerId: number;
  35075. }>;
  35076. /**
  35077. * Fires each time a drag ends (eg. mouse release after drag)
  35078. */
  35079. onDragEndObservable: Observable<{
  35080. dragPlanePoint: Vector3;
  35081. pointerId: number;
  35082. }>;
  35083. /**
  35084. * If the attached mesh should be moved when dragged
  35085. */
  35086. moveAttached: boolean;
  35087. /**
  35088. * If the drag behavior will react to drag events (Default: true)
  35089. */
  35090. enabled: boolean;
  35091. /**
  35092. * If camera controls should be detached during the drag
  35093. */
  35094. detachCameraControls: boolean;
  35095. /**
  35096. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35097. */
  35098. useObjectOrienationForDragging: boolean;
  35099. private _options;
  35100. /**
  35101. * Creates a pointer drag behavior that can be attached to a mesh
  35102. * @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)
  35103. */
  35104. constructor(options?: {
  35105. dragAxis?: Vector3;
  35106. dragPlaneNormal?: Vector3;
  35107. });
  35108. /**
  35109. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35110. */
  35111. validateDrag: (targetPosition: Vector3) => boolean;
  35112. /**
  35113. * The name of the behavior
  35114. */
  35115. readonly name: string;
  35116. /**
  35117. * Initializes the behavior
  35118. */
  35119. init(): void;
  35120. private _tmpVector;
  35121. private _alternatePickedPoint;
  35122. private _worldDragAxis;
  35123. private _targetPosition;
  35124. private _attachedElement;
  35125. /**
  35126. * Attaches the drag behavior the passed in mesh
  35127. * @param ownerNode The mesh that will be dragged around once attached
  35128. */
  35129. attach(ownerNode: AbstractMesh): void;
  35130. /**
  35131. * Force relase the drag action by code.
  35132. */
  35133. releaseDrag(): void;
  35134. private _startDragRay;
  35135. private _lastPointerRay;
  35136. /**
  35137. * Simulates the start of a pointer drag event on the behavior
  35138. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35139. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35140. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35141. */
  35142. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35143. private _startDrag;
  35144. private _dragDelta;
  35145. private _moveDrag;
  35146. private _pickWithRayOnDragPlane;
  35147. private _pointA;
  35148. private _pointB;
  35149. private _pointC;
  35150. private _lineA;
  35151. private _lineB;
  35152. private _localAxis;
  35153. private _lookAt;
  35154. private _updateDragPlanePosition;
  35155. /**
  35156. * Detaches the behavior from the mesh
  35157. */
  35158. detach(): void;
  35159. }
  35160. }
  35161. declare module BABYLON {
  35162. /**
  35163. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35164. */
  35165. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35166. private _dragBehaviorA;
  35167. private _dragBehaviorB;
  35168. private _startDistance;
  35169. private _initialScale;
  35170. private _targetScale;
  35171. private _ownerNode;
  35172. private _sceneRenderObserver;
  35173. /**
  35174. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35175. */
  35176. constructor();
  35177. /**
  35178. * The name of the behavior
  35179. */
  35180. readonly name: string;
  35181. /**
  35182. * Initializes the behavior
  35183. */
  35184. init(): void;
  35185. private _getCurrentDistance;
  35186. /**
  35187. * Attaches the scale behavior the passed in mesh
  35188. * @param ownerNode The mesh that will be scaled around once attached
  35189. */
  35190. attach(ownerNode: Mesh): void;
  35191. /**
  35192. * Detaches the behavior from the mesh
  35193. */
  35194. detach(): void;
  35195. }
  35196. }
  35197. declare module BABYLON {
  35198. /**
  35199. * 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
  35200. */
  35201. export class SixDofDragBehavior implements Behavior<Mesh> {
  35202. private static _virtualScene;
  35203. private _ownerNode;
  35204. private _sceneRenderObserver;
  35205. private _scene;
  35206. private _targetPosition;
  35207. private _virtualOriginMesh;
  35208. private _virtualDragMesh;
  35209. private _pointerObserver;
  35210. private _moving;
  35211. private _startingOrientation;
  35212. /**
  35213. * 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)
  35214. */
  35215. private zDragFactor;
  35216. /**
  35217. * If the object should rotate to face the drag origin
  35218. */
  35219. rotateDraggedObject: boolean;
  35220. /**
  35221. * If the behavior is currently in a dragging state
  35222. */
  35223. dragging: boolean;
  35224. /**
  35225. * 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)
  35226. */
  35227. dragDeltaRatio: number;
  35228. /**
  35229. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35230. */
  35231. currentDraggingPointerID: number;
  35232. /**
  35233. * If camera controls should be detached during the drag
  35234. */
  35235. detachCameraControls: boolean;
  35236. /**
  35237. * Fires each time a drag starts
  35238. */
  35239. onDragStartObservable: Observable<{}>;
  35240. /**
  35241. * Fires each time a drag ends (eg. mouse release after drag)
  35242. */
  35243. onDragEndObservable: Observable<{}>;
  35244. /**
  35245. * 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
  35246. */
  35247. constructor();
  35248. /**
  35249. * The name of the behavior
  35250. */
  35251. readonly name: string;
  35252. /**
  35253. * Initializes the behavior
  35254. */
  35255. init(): void;
  35256. /**
  35257. * Attaches the scale behavior the passed in mesh
  35258. * @param ownerNode The mesh that will be scaled around once attached
  35259. */
  35260. attach(ownerNode: Mesh): void;
  35261. /**
  35262. * Detaches the behavior from the mesh
  35263. */
  35264. detach(): void;
  35265. }
  35266. }
  35267. declare module BABYLON {
  35268. /**
  35269. * Class used to apply inverse kinematics to bones
  35270. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35271. */
  35272. export class BoneIKController {
  35273. private static _tmpVecs;
  35274. private static _tmpQuat;
  35275. private static _tmpMats;
  35276. /**
  35277. * Gets or sets the target mesh
  35278. */
  35279. targetMesh: AbstractMesh;
  35280. /** Gets or sets the mesh used as pole */
  35281. poleTargetMesh: AbstractMesh;
  35282. /**
  35283. * Gets or sets the bone used as pole
  35284. */
  35285. poleTargetBone: Nullable<Bone>;
  35286. /**
  35287. * Gets or sets the target position
  35288. */
  35289. targetPosition: Vector3;
  35290. /**
  35291. * Gets or sets the pole target position
  35292. */
  35293. poleTargetPosition: Vector3;
  35294. /**
  35295. * Gets or sets the pole target local offset
  35296. */
  35297. poleTargetLocalOffset: Vector3;
  35298. /**
  35299. * Gets or sets the pole angle
  35300. */
  35301. poleAngle: number;
  35302. /**
  35303. * Gets or sets the mesh associated with the controller
  35304. */
  35305. mesh: AbstractMesh;
  35306. /**
  35307. * 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)
  35308. */
  35309. slerpAmount: number;
  35310. private _bone1Quat;
  35311. private _bone1Mat;
  35312. private _bone2Ang;
  35313. private _bone1;
  35314. private _bone2;
  35315. private _bone1Length;
  35316. private _bone2Length;
  35317. private _maxAngle;
  35318. private _maxReach;
  35319. private _rightHandedSystem;
  35320. private _bendAxis;
  35321. private _slerping;
  35322. private _adjustRoll;
  35323. /**
  35324. * Gets or sets maximum allowed angle
  35325. */
  35326. maxAngle: number;
  35327. /**
  35328. * Creates a new BoneIKController
  35329. * @param mesh defines the mesh to control
  35330. * @param bone defines the bone to control
  35331. * @param options defines options to set up the controller
  35332. */
  35333. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35334. targetMesh?: AbstractMesh;
  35335. poleTargetMesh?: AbstractMesh;
  35336. poleTargetBone?: Bone;
  35337. poleTargetLocalOffset?: Vector3;
  35338. poleAngle?: number;
  35339. bendAxis?: Vector3;
  35340. maxAngle?: number;
  35341. slerpAmount?: number;
  35342. });
  35343. private _setMaxAngle;
  35344. /**
  35345. * Force the controller to update the bones
  35346. */
  35347. update(): void;
  35348. }
  35349. }
  35350. declare module BABYLON {
  35351. /**
  35352. * Class used to make a bone look toward a point in space
  35353. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35354. */
  35355. export class BoneLookController {
  35356. private static _tmpVecs;
  35357. private static _tmpQuat;
  35358. private static _tmpMats;
  35359. /**
  35360. * The target Vector3 that the bone will look at
  35361. */
  35362. target: Vector3;
  35363. /**
  35364. * The mesh that the bone is attached to
  35365. */
  35366. mesh: AbstractMesh;
  35367. /**
  35368. * The bone that will be looking to the target
  35369. */
  35370. bone: Bone;
  35371. /**
  35372. * The up axis of the coordinate system that is used when the bone is rotated
  35373. */
  35374. upAxis: Vector3;
  35375. /**
  35376. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35377. */
  35378. upAxisSpace: Space;
  35379. /**
  35380. * Used to make an adjustment to the yaw of the bone
  35381. */
  35382. adjustYaw: number;
  35383. /**
  35384. * Used to make an adjustment to the pitch of the bone
  35385. */
  35386. adjustPitch: number;
  35387. /**
  35388. * Used to make an adjustment to the roll of the bone
  35389. */
  35390. adjustRoll: number;
  35391. /**
  35392. * 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)
  35393. */
  35394. slerpAmount: number;
  35395. private _minYaw;
  35396. private _maxYaw;
  35397. private _minPitch;
  35398. private _maxPitch;
  35399. private _minYawSin;
  35400. private _minYawCos;
  35401. private _maxYawSin;
  35402. private _maxYawCos;
  35403. private _midYawConstraint;
  35404. private _minPitchTan;
  35405. private _maxPitchTan;
  35406. private _boneQuat;
  35407. private _slerping;
  35408. private _transformYawPitch;
  35409. private _transformYawPitchInv;
  35410. private _firstFrameSkipped;
  35411. private _yawRange;
  35412. private _fowardAxis;
  35413. /**
  35414. * Gets or sets the minimum yaw angle that the bone can look to
  35415. */
  35416. minYaw: number;
  35417. /**
  35418. * Gets or sets the maximum yaw angle that the bone can look to
  35419. */
  35420. maxYaw: number;
  35421. /**
  35422. * Gets or sets the minimum pitch angle that the bone can look to
  35423. */
  35424. minPitch: number;
  35425. /**
  35426. * Gets or sets the maximum pitch angle that the bone can look to
  35427. */
  35428. maxPitch: number;
  35429. /**
  35430. * Create a BoneLookController
  35431. * @param mesh the mesh that the bone belongs to
  35432. * @param bone the bone that will be looking to the target
  35433. * @param target the target Vector3 to look at
  35434. * @param options optional settings:
  35435. * * maxYaw: the maximum angle the bone will yaw to
  35436. * * minYaw: the minimum angle the bone will yaw to
  35437. * * maxPitch: the maximum angle the bone will pitch to
  35438. * * minPitch: the minimum angle the bone will yaw to
  35439. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35440. * * upAxis: the up axis of the coordinate system
  35441. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35442. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35443. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35444. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35445. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35446. * * adjustRoll: used to make an adjustment to the roll of the bone
  35447. **/
  35448. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35449. maxYaw?: number;
  35450. minYaw?: number;
  35451. maxPitch?: number;
  35452. minPitch?: number;
  35453. slerpAmount?: number;
  35454. upAxis?: Vector3;
  35455. upAxisSpace?: Space;
  35456. yawAxis?: Vector3;
  35457. pitchAxis?: Vector3;
  35458. adjustYaw?: number;
  35459. adjustPitch?: number;
  35460. adjustRoll?: number;
  35461. });
  35462. /**
  35463. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35464. */
  35465. update(): void;
  35466. private _getAngleDiff;
  35467. private _getAngleBetween;
  35468. private _isAngleBetween;
  35469. }
  35470. }
  35471. declare module BABYLON {
  35472. /**
  35473. * Manage the gamepad inputs to control an arc rotate camera.
  35474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35475. */
  35476. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35477. /**
  35478. * Defines the camera the input is attached to.
  35479. */
  35480. camera: ArcRotateCamera;
  35481. /**
  35482. * Defines the gamepad the input is gathering event from.
  35483. */
  35484. gamepad: Nullable<Gamepad>;
  35485. /**
  35486. * Defines the gamepad rotation sensiblity.
  35487. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35488. */
  35489. gamepadRotationSensibility: number;
  35490. /**
  35491. * Defines the gamepad move sensiblity.
  35492. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35493. */
  35494. gamepadMoveSensibility: number;
  35495. private _onGamepadConnectedObserver;
  35496. private _onGamepadDisconnectedObserver;
  35497. /**
  35498. * Attach the input controls to a specific dom element to get the input from.
  35499. * @param element Defines the element the controls should be listened from
  35500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35501. */
  35502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35503. /**
  35504. * Detach the current controls from the specified dom element.
  35505. * @param element Defines the element to stop listening the inputs from
  35506. */
  35507. detachControl(element: Nullable<HTMLElement>): void;
  35508. /**
  35509. * Update the current camera state depending on the inputs that have been used this frame.
  35510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35511. */
  35512. checkInputs(): void;
  35513. /**
  35514. * Gets the class name of the current intput.
  35515. * @returns the class name
  35516. */
  35517. getClassName(): string;
  35518. /**
  35519. * Get the friendly name associated with the input class.
  35520. * @returns the input friendly name
  35521. */
  35522. getSimpleName(): string;
  35523. }
  35524. }
  35525. declare module BABYLON {
  35526. interface ArcRotateCameraInputsManager {
  35527. /**
  35528. * Add orientation input support to the input manager.
  35529. * @returns the current input manager
  35530. */
  35531. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35532. }
  35533. /**
  35534. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35536. */
  35537. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35538. /**
  35539. * Defines the camera the input is attached to.
  35540. */
  35541. camera: ArcRotateCamera;
  35542. /**
  35543. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35544. */
  35545. alphaCorrection: number;
  35546. /**
  35547. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35548. */
  35549. gammaCorrection: number;
  35550. private _alpha;
  35551. private _gamma;
  35552. private _dirty;
  35553. private _deviceOrientationHandler;
  35554. /**
  35555. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35556. */
  35557. constructor();
  35558. /**
  35559. * Attach the input controls to a specific dom element to get the input from.
  35560. * @param element Defines the element the controls should be listened from
  35561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35562. */
  35563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35564. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35565. /**
  35566. * Update the current camera state depending on the inputs that have been used this frame.
  35567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35568. */
  35569. checkInputs(): void;
  35570. /**
  35571. * Detach the current controls from the specified dom element.
  35572. * @param element Defines the element to stop listening the inputs from
  35573. */
  35574. detachControl(element: Nullable<HTMLElement>): void;
  35575. /**
  35576. * Gets the class name of the current intput.
  35577. * @returns the class name
  35578. */
  35579. getClassName(): string;
  35580. /**
  35581. * Get the friendly name associated with the input class.
  35582. * @returns the input friendly name
  35583. */
  35584. getSimpleName(): string;
  35585. }
  35586. }
  35587. declare module BABYLON {
  35588. /**
  35589. * Listen to mouse events to control the camera.
  35590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35591. */
  35592. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35593. /**
  35594. * Defines the camera the input is attached to.
  35595. */
  35596. camera: FlyCamera;
  35597. /**
  35598. * Defines if touch is enabled. (Default is true.)
  35599. */
  35600. touchEnabled: boolean;
  35601. /**
  35602. * Defines the buttons associated with the input to handle camera rotation.
  35603. */
  35604. buttons: number[];
  35605. /**
  35606. * Assign buttons for Yaw control.
  35607. */
  35608. buttonsYaw: number[];
  35609. /**
  35610. * Assign buttons for Pitch control.
  35611. */
  35612. buttonsPitch: number[];
  35613. /**
  35614. * Assign buttons for Roll control.
  35615. */
  35616. buttonsRoll: number[];
  35617. /**
  35618. * Detect if any button is being pressed while mouse is moved.
  35619. * -1 = Mouse locked.
  35620. * 0 = Left button.
  35621. * 1 = Middle Button.
  35622. * 2 = Right Button.
  35623. */
  35624. activeButton: number;
  35625. /**
  35626. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35627. * Higher values reduce its sensitivity.
  35628. */
  35629. angularSensibility: number;
  35630. private _mousemoveCallback;
  35631. private _observer;
  35632. private _rollObserver;
  35633. private previousPosition;
  35634. private noPreventDefault;
  35635. private element;
  35636. /**
  35637. * Listen to mouse events to control the camera.
  35638. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35640. */
  35641. constructor(touchEnabled?: boolean);
  35642. /**
  35643. * Attach the mouse control to the HTML DOM element.
  35644. * @param element Defines the element that listens to the input events.
  35645. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35646. */
  35647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35648. /**
  35649. * Detach the current controls from the specified dom element.
  35650. * @param element Defines the element to stop listening the inputs from
  35651. */
  35652. detachControl(element: Nullable<HTMLElement>): void;
  35653. /**
  35654. * Gets the class name of the current input.
  35655. * @returns the class name.
  35656. */
  35657. getClassName(): string;
  35658. /**
  35659. * Get the friendly name associated with the input class.
  35660. * @returns the input's friendly name.
  35661. */
  35662. getSimpleName(): string;
  35663. private _pointerInput;
  35664. private _onMouseMove;
  35665. /**
  35666. * Rotate camera by mouse offset.
  35667. */
  35668. private rotateCamera;
  35669. }
  35670. }
  35671. declare module BABYLON {
  35672. /**
  35673. * Default Inputs manager for the FlyCamera.
  35674. * It groups all the default supported inputs for ease of use.
  35675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35676. */
  35677. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35678. /**
  35679. * Instantiates a new FlyCameraInputsManager.
  35680. * @param camera Defines the camera the inputs belong to.
  35681. */
  35682. constructor(camera: FlyCamera);
  35683. /**
  35684. * Add keyboard input support to the input manager.
  35685. * @returns the new FlyCameraKeyboardMoveInput().
  35686. */
  35687. addKeyboard(): FlyCameraInputsManager;
  35688. /**
  35689. * Add mouse input support to the input manager.
  35690. * @param touchEnabled Enable touch screen support.
  35691. * @returns the new FlyCameraMouseInput().
  35692. */
  35693. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35694. }
  35695. }
  35696. declare module BABYLON {
  35697. /**
  35698. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35699. * such as in a 3D Space Shooter or a Flight Simulator.
  35700. */
  35701. export class FlyCamera extends TargetCamera {
  35702. /**
  35703. * Define the collision ellipsoid of the camera.
  35704. * This is helpful for simulating a camera body, like a player's body.
  35705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35706. */
  35707. ellipsoid: Vector3;
  35708. /**
  35709. * Define an offset for the position of the ellipsoid around the camera.
  35710. * This can be helpful if the camera is attached away from the player's body center,
  35711. * such as at its head.
  35712. */
  35713. ellipsoidOffset: Vector3;
  35714. /**
  35715. * Enable or disable collisions of the camera with the rest of the scene objects.
  35716. */
  35717. checkCollisions: boolean;
  35718. /**
  35719. * Enable or disable gravity on the camera.
  35720. */
  35721. applyGravity: boolean;
  35722. /**
  35723. * Define the current direction the camera is moving to.
  35724. */
  35725. cameraDirection: Vector3;
  35726. /**
  35727. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35728. * This overrides and empties cameraRotation.
  35729. */
  35730. rotationQuaternion: Quaternion;
  35731. /**
  35732. * Track Roll to maintain the wanted Rolling when looking around.
  35733. */ trackRoll: number;
  35734. /**
  35735. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35736. */
  35737. rollCorrect: number;
  35738. /**
  35739. * Mimic a banked turn, Rolling the camera when Yawing.
  35740. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35741. */
  35742. bankedTurn: boolean;
  35743. /**
  35744. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35745. */
  35746. bankedTurnLimit: number;
  35747. /**
  35748. * Value of 0 disables the banked Roll.
  35749. * Value of 1 is equal to the Yaw angle in radians.
  35750. */
  35751. bankedTurnMultiplier: number;
  35752. /**
  35753. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35754. */
  35755. inputs: FlyCameraInputsManager;
  35756. /**
  35757. * Gets the input sensibility for mouse input.
  35758. * Higher values reduce sensitivity.
  35759. */
  35760. /**
  35761. * Sets the input sensibility for a mouse input.
  35762. * Higher values reduce sensitivity.
  35763. */
  35764. angularSensibility: number;
  35765. /**
  35766. * Get the keys for camera movement forward.
  35767. */
  35768. /**
  35769. * Set the keys for camera movement forward.
  35770. */
  35771. keysForward: number[];
  35772. /**
  35773. * Get the keys for camera movement backward.
  35774. */
  35775. keysBackward: number[];
  35776. /**
  35777. * Get the keys for camera movement up.
  35778. */
  35779. /**
  35780. * Set the keys for camera movement up.
  35781. */
  35782. keysUp: number[];
  35783. /**
  35784. * Get the keys for camera movement down.
  35785. */
  35786. /**
  35787. * Set the keys for camera movement down.
  35788. */
  35789. keysDown: number[];
  35790. /**
  35791. * Get the keys for camera movement left.
  35792. */
  35793. /**
  35794. * Set the keys for camera movement left.
  35795. */
  35796. keysLeft: number[];
  35797. /**
  35798. * Set the keys for camera movement right.
  35799. */
  35800. /**
  35801. * Set the keys for camera movement right.
  35802. */
  35803. keysRight: number[];
  35804. /**
  35805. * Event raised when the camera collides with a mesh in the scene.
  35806. */
  35807. onCollide: (collidedMesh: AbstractMesh) => void;
  35808. private _collider;
  35809. private _needMoveForGravity;
  35810. private _oldPosition;
  35811. private _diffPosition;
  35812. private _newPosition;
  35813. /** @hidden */ localDirection: Vector3;
  35814. /** @hidden */ transformedDirection: Vector3;
  35815. /**
  35816. * Instantiates a FlyCamera.
  35817. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35818. * such as in a 3D Space Shooter or a Flight Simulator.
  35819. * @param name Define the name of the camera in the scene.
  35820. * @param position Define the starting position of the camera in the scene.
  35821. * @param scene Define the scene the camera belongs to.
  35822. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35823. */
  35824. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35825. /**
  35826. * Attach a control to the HTML DOM element.
  35827. * @param element Defines the element that listens to the input events.
  35828. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35829. */
  35830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35831. /**
  35832. * Detach a control from the HTML DOM element.
  35833. * The camera will stop reacting to that input.
  35834. * @param element Defines the element that listens to the input events.
  35835. */
  35836. detachControl(element: HTMLElement): void;
  35837. private _collisionMask;
  35838. /**
  35839. * Get the mask that the camera ignores in collision events.
  35840. */
  35841. /**
  35842. * Set the mask that the camera ignores in collision events.
  35843. */
  35844. collisionMask: number;
  35845. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35846. /** @hidden */
  35847. private _onCollisionPositionChange;
  35848. /** @hidden */ checkInputs(): void;
  35849. /** @hidden */ decideIfNeedsToMove(): boolean;
  35850. /** @hidden */ updatePosition(): void;
  35851. /**
  35852. * Restore the Roll to its target value at the rate specified.
  35853. * @param rate - Higher means slower restoring.
  35854. * @hidden
  35855. */
  35856. restoreRoll(rate: number): void;
  35857. /**
  35858. * Destroy the camera and release the current resources held by it.
  35859. */
  35860. dispose(): void;
  35861. /**
  35862. * Get the current object class name.
  35863. * @returns the class name.
  35864. */
  35865. getClassName(): string;
  35866. }
  35867. }
  35868. declare module BABYLON {
  35869. /**
  35870. * Listen to keyboard events to control the camera.
  35871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35872. */
  35873. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35874. /**
  35875. * Defines the camera the input is attached to.
  35876. */
  35877. camera: FlyCamera;
  35878. /**
  35879. * The list of keyboard keys used to control the forward move of the camera.
  35880. */
  35881. keysForward: number[];
  35882. /**
  35883. * The list of keyboard keys used to control the backward move of the camera.
  35884. */
  35885. keysBackward: number[];
  35886. /**
  35887. * The list of keyboard keys used to control the forward move of the camera.
  35888. */
  35889. keysUp: number[];
  35890. /**
  35891. * The list of keyboard keys used to control the backward move of the camera.
  35892. */
  35893. keysDown: number[];
  35894. /**
  35895. * The list of keyboard keys used to control the right strafe move of the camera.
  35896. */
  35897. keysRight: number[];
  35898. /**
  35899. * The list of keyboard keys used to control the left strafe move of the camera.
  35900. */
  35901. keysLeft: number[];
  35902. private _keys;
  35903. private _onCanvasBlurObserver;
  35904. private _onKeyboardObserver;
  35905. private _engine;
  35906. private _scene;
  35907. /**
  35908. * Attach the input controls to a specific dom element to get the input from.
  35909. * @param element Defines the element the controls should be listened from
  35910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35911. */
  35912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35913. /**
  35914. * Detach the current controls from the specified dom element.
  35915. * @param element Defines the element to stop listening the inputs from
  35916. */
  35917. detachControl(element: Nullable<HTMLElement>): void;
  35918. /**
  35919. * Gets the class name of the current intput.
  35920. * @returns the class name
  35921. */
  35922. getClassName(): string;
  35923. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35924. /**
  35925. * Get the friendly name associated with the input class.
  35926. * @returns the input friendly name
  35927. */
  35928. getSimpleName(): string;
  35929. /**
  35930. * Update the current camera state depending on the inputs that have been used this frame.
  35931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35932. */
  35933. checkInputs(): void;
  35934. }
  35935. }
  35936. declare module BABYLON {
  35937. /**
  35938. * Manage the mouse wheel inputs to control a follow camera.
  35939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35940. */
  35941. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35942. /**
  35943. * Defines the camera the input is attached to.
  35944. */
  35945. camera: FollowCamera;
  35946. /**
  35947. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35948. */
  35949. axisControlRadius: boolean;
  35950. /**
  35951. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35952. */
  35953. axisControlHeight: boolean;
  35954. /**
  35955. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35956. */
  35957. axisControlRotation: boolean;
  35958. /**
  35959. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35960. * relation to mouseWheel events.
  35961. */
  35962. wheelPrecision: number;
  35963. /**
  35964. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35965. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35966. */
  35967. wheelDeltaPercentage: number;
  35968. private _wheel;
  35969. private _observer;
  35970. /**
  35971. * Attach the input controls to a specific dom element to get the input from.
  35972. * @param element Defines the element the controls should be listened from
  35973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35974. */
  35975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35976. /**
  35977. * Detach the current controls from the specified dom element.
  35978. * @param element Defines the element to stop listening the inputs from
  35979. */
  35980. detachControl(element: Nullable<HTMLElement>): void;
  35981. /**
  35982. * Gets the class name of the current intput.
  35983. * @returns the class name
  35984. */
  35985. getClassName(): string;
  35986. /**
  35987. * Get the friendly name associated with the input class.
  35988. * @returns the input friendly name
  35989. */
  35990. getSimpleName(): string;
  35991. }
  35992. }
  35993. declare module BABYLON {
  35994. /**
  35995. * Manage the pointers inputs to control an follow camera.
  35996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35997. */
  35998. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35999. /**
  36000. * Defines the camera the input is attached to.
  36001. */
  36002. camera: FollowCamera;
  36003. /**
  36004. * Gets the class name of the current input.
  36005. * @returns the class name
  36006. */
  36007. getClassName(): string;
  36008. /**
  36009. * Defines the pointer angular sensibility along the X axis or how fast is
  36010. * the camera rotating.
  36011. * A negative number will reverse the axis direction.
  36012. */
  36013. angularSensibilityX: number;
  36014. /**
  36015. * Defines the pointer angular sensibility along the Y axis or how fast is
  36016. * the camera rotating.
  36017. * A negative number will reverse the axis direction.
  36018. */
  36019. angularSensibilityY: number;
  36020. /**
  36021. * Defines the pointer pinch precision or how fast is the camera zooming.
  36022. * A negative number will reverse the axis direction.
  36023. */
  36024. pinchPrecision: number;
  36025. /**
  36026. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36027. * from 0.
  36028. * It defines the percentage of current camera.radius to use as delta when
  36029. * pinch zoom is used.
  36030. */
  36031. pinchDeltaPercentage: number;
  36032. /**
  36033. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36034. */
  36035. axisXControlRadius: boolean;
  36036. /**
  36037. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36038. */
  36039. axisXControlHeight: boolean;
  36040. /**
  36041. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36042. */
  36043. axisXControlRotation: boolean;
  36044. /**
  36045. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36046. */
  36047. axisYControlRadius: boolean;
  36048. /**
  36049. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36050. */
  36051. axisYControlHeight: boolean;
  36052. /**
  36053. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36054. */
  36055. axisYControlRotation: boolean;
  36056. /**
  36057. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36058. */
  36059. axisPinchControlRadius: boolean;
  36060. /**
  36061. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36062. */
  36063. axisPinchControlHeight: boolean;
  36064. /**
  36065. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36066. */
  36067. axisPinchControlRotation: boolean;
  36068. /**
  36069. * Log error messages if basic misconfiguration has occurred.
  36070. */
  36071. warningEnable: boolean;
  36072. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36073. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36074. private _warningCounter;
  36075. private _warning;
  36076. }
  36077. }
  36078. declare module BABYLON {
  36079. /**
  36080. * Default Inputs manager for the FollowCamera.
  36081. * It groups all the default supported inputs for ease of use.
  36082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36083. */
  36084. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36085. /**
  36086. * Instantiates a new FollowCameraInputsManager.
  36087. * @param camera Defines the camera the inputs belong to
  36088. */
  36089. constructor(camera: FollowCamera);
  36090. /**
  36091. * Add keyboard input support to the input manager.
  36092. * @returns the current input manager
  36093. */
  36094. addKeyboard(): FollowCameraInputsManager;
  36095. /**
  36096. * Add mouse wheel input support to the input manager.
  36097. * @returns the current input manager
  36098. */
  36099. addMouseWheel(): FollowCameraInputsManager;
  36100. /**
  36101. * Add pointers input support to the input manager.
  36102. * @returns the current input manager
  36103. */
  36104. addPointers(): FollowCameraInputsManager;
  36105. /**
  36106. * Add orientation input support to the input manager.
  36107. * @returns the current input manager
  36108. */
  36109. addVRDeviceOrientation(): FollowCameraInputsManager;
  36110. }
  36111. }
  36112. declare module BABYLON {
  36113. /**
  36114. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36115. * an arc rotate version arcFollowCamera are available.
  36116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36117. */
  36118. export class FollowCamera extends TargetCamera {
  36119. /**
  36120. * Distance the follow camera should follow an object at
  36121. */
  36122. radius: number;
  36123. /**
  36124. * Minimum allowed distance of the camera to the axis of rotation
  36125. * (The camera can not get closer).
  36126. * This can help limiting how the Camera is able to move in the scene.
  36127. */
  36128. lowerRadiusLimit: Nullable<number>;
  36129. /**
  36130. * Maximum allowed distance of the camera to the axis of rotation
  36131. * (The camera can not get further).
  36132. * This can help limiting how the Camera is able to move in the scene.
  36133. */
  36134. upperRadiusLimit: Nullable<number>;
  36135. /**
  36136. * Define a rotation offset between the camera and the object it follows
  36137. */
  36138. rotationOffset: number;
  36139. /**
  36140. * Minimum allowed angle to camera position relative to target object.
  36141. * This can help limiting how the Camera is able to move in the scene.
  36142. */
  36143. lowerRotationOffsetLimit: Nullable<number>;
  36144. /**
  36145. * Maximum allowed angle to camera position relative to target object.
  36146. * This can help limiting how the Camera is able to move in the scene.
  36147. */
  36148. upperRotationOffsetLimit: Nullable<number>;
  36149. /**
  36150. * Define a height offset between the camera and the object it follows.
  36151. * It can help following an object from the top (like a car chaing a plane)
  36152. */
  36153. heightOffset: number;
  36154. /**
  36155. * Minimum allowed height of camera position relative to target object.
  36156. * This can help limiting how the Camera is able to move in the scene.
  36157. */
  36158. lowerHeightOffsetLimit: Nullable<number>;
  36159. /**
  36160. * Maximum allowed height of camera position relative to target object.
  36161. * This can help limiting how the Camera is able to move in the scene.
  36162. */
  36163. upperHeightOffsetLimit: Nullable<number>;
  36164. /**
  36165. * Define how fast the camera can accelerate to follow it s target.
  36166. */
  36167. cameraAcceleration: number;
  36168. /**
  36169. * Define the speed limit of the camera following an object.
  36170. */
  36171. maxCameraSpeed: number;
  36172. /**
  36173. * Define the target of the camera.
  36174. */
  36175. lockedTarget: Nullable<AbstractMesh>;
  36176. /**
  36177. * Defines the input associated with the camera.
  36178. */
  36179. inputs: FollowCameraInputsManager;
  36180. /**
  36181. * Instantiates the follow camera.
  36182. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36183. * @param name Define the name of the camera in the scene
  36184. * @param position Define the position of the camera
  36185. * @param scene Define the scene the camera belong to
  36186. * @param lockedTarget Define the target of the camera
  36187. */
  36188. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36189. private _follow;
  36190. /**
  36191. * Attached controls to the current camera.
  36192. * @param element Defines the element the controls should be listened from
  36193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36194. */
  36195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36196. /**
  36197. * Detach the current controls from the camera.
  36198. * The camera will stop reacting to inputs.
  36199. * @param element Defines the element to stop listening the inputs from
  36200. */
  36201. detachControl(element: HTMLElement): void;
  36202. /** @hidden */ checkInputs(): void;
  36203. private _checkLimits;
  36204. /**
  36205. * Gets the camera class name.
  36206. * @returns the class name
  36207. */
  36208. getClassName(): string;
  36209. }
  36210. /**
  36211. * Arc Rotate version of the follow camera.
  36212. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36213. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36214. */
  36215. export class ArcFollowCamera extends TargetCamera {
  36216. /** The longitudinal angle of the camera */
  36217. alpha: number;
  36218. /** The latitudinal angle of the camera */
  36219. beta: number;
  36220. /** The radius of the camera from its target */
  36221. radius: number;
  36222. /** Define the camera target (the messh it should follow) */
  36223. target: Nullable<AbstractMesh>;
  36224. private _cartesianCoordinates;
  36225. /**
  36226. * Instantiates a new ArcFollowCamera
  36227. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36228. * @param name Define the name of the camera
  36229. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36230. * @param beta Define the rotation angle of the camera around the elevation axis
  36231. * @param radius Define the radius of the camera from its target point
  36232. * @param target Define the target of the camera
  36233. * @param scene Define the scene the camera belongs to
  36234. */
  36235. constructor(name: string,
  36236. /** The longitudinal angle of the camera */
  36237. alpha: number,
  36238. /** The latitudinal angle of the camera */
  36239. beta: number,
  36240. /** The radius of the camera from its target */
  36241. radius: number,
  36242. /** Define the camera target (the messh it should follow) */
  36243. target: Nullable<AbstractMesh>, scene: Scene);
  36244. private _follow;
  36245. /** @hidden */ checkInputs(): void;
  36246. /**
  36247. * Returns the class name of the object.
  36248. * It is mostly used internally for serialization purposes.
  36249. */
  36250. getClassName(): string;
  36251. }
  36252. }
  36253. declare module BABYLON {
  36254. /**
  36255. * Manage the keyboard inputs to control the movement of a follow camera.
  36256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36257. */
  36258. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36259. /**
  36260. * Defines the camera the input is attached to.
  36261. */
  36262. camera: FollowCamera;
  36263. /**
  36264. * Defines the list of key codes associated with the up action (increase heightOffset)
  36265. */
  36266. keysHeightOffsetIncr: number[];
  36267. /**
  36268. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36269. */
  36270. keysHeightOffsetDecr: number[];
  36271. /**
  36272. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36273. */
  36274. keysHeightOffsetModifierAlt: boolean;
  36275. /**
  36276. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36277. */
  36278. keysHeightOffsetModifierCtrl: boolean;
  36279. /**
  36280. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36281. */
  36282. keysHeightOffsetModifierShift: boolean;
  36283. /**
  36284. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36285. */
  36286. keysRotationOffsetIncr: number[];
  36287. /**
  36288. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36289. */
  36290. keysRotationOffsetDecr: number[];
  36291. /**
  36292. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36293. */
  36294. keysRotationOffsetModifierAlt: boolean;
  36295. /**
  36296. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36297. */
  36298. keysRotationOffsetModifierCtrl: boolean;
  36299. /**
  36300. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36301. */
  36302. keysRotationOffsetModifierShift: boolean;
  36303. /**
  36304. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36305. */
  36306. keysRadiusIncr: number[];
  36307. /**
  36308. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36309. */
  36310. keysRadiusDecr: number[];
  36311. /**
  36312. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36313. */
  36314. keysRadiusModifierAlt: boolean;
  36315. /**
  36316. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36317. */
  36318. keysRadiusModifierCtrl: boolean;
  36319. /**
  36320. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36321. */
  36322. keysRadiusModifierShift: boolean;
  36323. /**
  36324. * Defines the rate of change of heightOffset.
  36325. */
  36326. heightSensibility: number;
  36327. /**
  36328. * Defines the rate of change of rotationOffset.
  36329. */
  36330. rotationSensibility: number;
  36331. /**
  36332. * Defines the rate of change of radius.
  36333. */
  36334. radiusSensibility: number;
  36335. private _keys;
  36336. private _ctrlPressed;
  36337. private _altPressed;
  36338. private _shiftPressed;
  36339. private _onCanvasBlurObserver;
  36340. private _onKeyboardObserver;
  36341. private _engine;
  36342. private _scene;
  36343. /**
  36344. * Attach the input controls to a specific dom element to get the input from.
  36345. * @param element Defines the element the controls should be listened from
  36346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36347. */
  36348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36349. /**
  36350. * Detach the current controls from the specified dom element.
  36351. * @param element Defines the element to stop listening the inputs from
  36352. */
  36353. detachControl(element: Nullable<HTMLElement>): void;
  36354. /**
  36355. * Update the current camera state depending on the inputs that have been used this frame.
  36356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36357. */
  36358. checkInputs(): void;
  36359. /**
  36360. * Gets the class name of the current input.
  36361. * @returns the class name
  36362. */
  36363. getClassName(): string;
  36364. /**
  36365. * Get the friendly name associated with the input class.
  36366. * @returns the input friendly name
  36367. */
  36368. getSimpleName(): string;
  36369. /**
  36370. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36371. * allow modification of the heightOffset value.
  36372. */
  36373. private _modifierHeightOffset;
  36374. /**
  36375. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36376. * allow modification of the rotationOffset value.
  36377. */
  36378. private _modifierRotationOffset;
  36379. /**
  36380. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36381. * allow modification of the radius value.
  36382. */
  36383. private _modifierRadius;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. interface FreeCameraInputsManager {
  36388. /**
  36389. * @hidden
  36390. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36391. /**
  36392. * Add orientation input support to the input manager.
  36393. * @returns the current input manager
  36394. */
  36395. addDeviceOrientation(): FreeCameraInputsManager;
  36396. }
  36397. /**
  36398. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36399. * Screen rotation is taken into account.
  36400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36401. */
  36402. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36403. private _camera;
  36404. private _screenOrientationAngle;
  36405. private _constantTranform;
  36406. private _screenQuaternion;
  36407. private _alpha;
  36408. private _beta;
  36409. private _gamma;
  36410. /**
  36411. * @hidden
  36412. */ onDeviceOrientationChangedObservable: Observable<void>;
  36413. /**
  36414. * Instantiates a new input
  36415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36416. */
  36417. constructor();
  36418. /**
  36419. * Define the camera controlled by the input.
  36420. */
  36421. camera: FreeCamera;
  36422. /**
  36423. * Attach the input controls to a specific dom element to get the input from.
  36424. * @param element Defines the element the controls should be listened from
  36425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36426. */
  36427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36428. private _orientationChanged;
  36429. private _deviceOrientation;
  36430. /**
  36431. * Detach the current controls from the specified dom element.
  36432. * @param element Defines the element to stop listening the inputs from
  36433. */
  36434. detachControl(element: Nullable<HTMLElement>): void;
  36435. /**
  36436. * Update the current camera state depending on the inputs that have been used this frame.
  36437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36438. */
  36439. checkInputs(): void;
  36440. /**
  36441. * Gets the class name of the current intput.
  36442. * @returns the class name
  36443. */
  36444. getClassName(): string;
  36445. /**
  36446. * Get the friendly name associated with the input class.
  36447. * @returns the input friendly name
  36448. */
  36449. getSimpleName(): string;
  36450. }
  36451. }
  36452. declare module BABYLON {
  36453. /**
  36454. * Manage the gamepad inputs to control a free camera.
  36455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36456. */
  36457. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36458. /**
  36459. * Define the camera the input is attached to.
  36460. */
  36461. camera: FreeCamera;
  36462. /**
  36463. * Define the Gamepad controlling the input
  36464. */
  36465. gamepad: Nullable<Gamepad>;
  36466. /**
  36467. * Defines the gamepad rotation sensiblity.
  36468. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36469. */
  36470. gamepadAngularSensibility: number;
  36471. /**
  36472. * Defines the gamepad move sensiblity.
  36473. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36474. */
  36475. gamepadMoveSensibility: number;
  36476. private _onGamepadConnectedObserver;
  36477. private _onGamepadDisconnectedObserver;
  36478. private _cameraTransform;
  36479. private _deltaTransform;
  36480. private _vector3;
  36481. private _vector2;
  36482. /**
  36483. * Attach the input controls to a specific dom element to get the input from.
  36484. * @param element Defines the element the controls should be listened from
  36485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36486. */
  36487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36488. /**
  36489. * Detach the current controls from the specified dom element.
  36490. * @param element Defines the element to stop listening the inputs from
  36491. */
  36492. detachControl(element: Nullable<HTMLElement>): void;
  36493. /**
  36494. * Update the current camera state depending on the inputs that have been used this frame.
  36495. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36496. */
  36497. checkInputs(): void;
  36498. /**
  36499. * Gets the class name of the current intput.
  36500. * @returns the class name
  36501. */
  36502. getClassName(): string;
  36503. /**
  36504. * Get the friendly name associated with the input class.
  36505. * @returns the input friendly name
  36506. */
  36507. getSimpleName(): string;
  36508. }
  36509. }
  36510. declare module BABYLON {
  36511. /**
  36512. * Defines the potential axis of a Joystick
  36513. */
  36514. export enum JoystickAxis {
  36515. /** X axis */
  36516. X = 0,
  36517. /** Y axis */
  36518. Y = 1,
  36519. /** Z axis */
  36520. Z = 2
  36521. }
  36522. /**
  36523. * Class used to define virtual joystick (used in touch mode)
  36524. */
  36525. export class VirtualJoystick {
  36526. /**
  36527. * Gets or sets a boolean indicating that left and right values must be inverted
  36528. */
  36529. reverseLeftRight: boolean;
  36530. /**
  36531. * Gets or sets a boolean indicating that up and down values must be inverted
  36532. */
  36533. reverseUpDown: boolean;
  36534. /**
  36535. * Gets the offset value for the position (ie. the change of the position value)
  36536. */
  36537. deltaPosition: Vector3;
  36538. /**
  36539. * Gets a boolean indicating if the virtual joystick was pressed
  36540. */
  36541. pressed: boolean;
  36542. /**
  36543. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36544. */
  36545. static Canvas: Nullable<HTMLCanvasElement>;
  36546. private static _globalJoystickIndex;
  36547. private static vjCanvasContext;
  36548. private static vjCanvasWidth;
  36549. private static vjCanvasHeight;
  36550. private static halfWidth;
  36551. private _action;
  36552. private _axisTargetedByLeftAndRight;
  36553. private _axisTargetedByUpAndDown;
  36554. private _joystickSensibility;
  36555. private _inversedSensibility;
  36556. private _joystickPointerID;
  36557. private _joystickColor;
  36558. private _joystickPointerPos;
  36559. private _joystickPreviousPointerPos;
  36560. private _joystickPointerStartPos;
  36561. private _deltaJoystickVector;
  36562. private _leftJoystick;
  36563. private _touches;
  36564. private _onPointerDownHandlerRef;
  36565. private _onPointerMoveHandlerRef;
  36566. private _onPointerUpHandlerRef;
  36567. private _onResize;
  36568. /**
  36569. * Creates a new virtual joystick
  36570. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36571. */
  36572. constructor(leftJoystick?: boolean);
  36573. /**
  36574. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36575. * @param newJoystickSensibility defines the new sensibility
  36576. */
  36577. setJoystickSensibility(newJoystickSensibility: number): void;
  36578. private _onPointerDown;
  36579. private _onPointerMove;
  36580. private _onPointerUp;
  36581. /**
  36582. * Change the color of the virtual joystick
  36583. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36584. */
  36585. setJoystickColor(newColor: string): void;
  36586. /**
  36587. * Defines a callback to call when the joystick is touched
  36588. * @param action defines the callback
  36589. */
  36590. setActionOnTouch(action: () => any): void;
  36591. /**
  36592. * Defines which axis you'd like to control for left & right
  36593. * @param axis defines the axis to use
  36594. */
  36595. setAxisForLeftRight(axis: JoystickAxis): void;
  36596. /**
  36597. * Defines which axis you'd like to control for up & down
  36598. * @param axis defines the axis to use
  36599. */
  36600. setAxisForUpDown(axis: JoystickAxis): void;
  36601. private _drawVirtualJoystick;
  36602. /**
  36603. * Release internal HTML canvas
  36604. */
  36605. releaseCanvas(): void;
  36606. }
  36607. }
  36608. declare module BABYLON {
  36609. interface FreeCameraInputsManager {
  36610. /**
  36611. * Add virtual joystick input support to the input manager.
  36612. * @returns the current input manager
  36613. */
  36614. addVirtualJoystick(): FreeCameraInputsManager;
  36615. }
  36616. /**
  36617. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36619. */
  36620. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36621. /**
  36622. * Defines the camera the input is attached to.
  36623. */
  36624. camera: FreeCamera;
  36625. private _leftjoystick;
  36626. private _rightjoystick;
  36627. /**
  36628. * Gets the left stick of the virtual joystick.
  36629. * @returns The virtual Joystick
  36630. */
  36631. getLeftJoystick(): VirtualJoystick;
  36632. /**
  36633. * Gets the right stick of the virtual joystick.
  36634. * @returns The virtual Joystick
  36635. */
  36636. getRightJoystick(): VirtualJoystick;
  36637. /**
  36638. * Update the current camera state depending on the inputs that have been used this frame.
  36639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36640. */
  36641. checkInputs(): void;
  36642. /**
  36643. * Attach the input controls to a specific dom element to get the input from.
  36644. * @param element Defines the element the controls should be listened from
  36645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36646. */
  36647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36648. /**
  36649. * Detach the current controls from the specified dom element.
  36650. * @param element Defines the element to stop listening the inputs from
  36651. */
  36652. detachControl(element: Nullable<HTMLElement>): void;
  36653. /**
  36654. * Gets the class name of the current intput.
  36655. * @returns the class name
  36656. */
  36657. getClassName(): string;
  36658. /**
  36659. * Get the friendly name associated with the input class.
  36660. * @returns the input friendly name
  36661. */
  36662. getSimpleName(): string;
  36663. }
  36664. }
  36665. declare module BABYLON {
  36666. /**
  36667. * This represents a FPS type of camera controlled by touch.
  36668. * This is like a universal camera minus the Gamepad controls.
  36669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36670. */
  36671. export class TouchCamera extends FreeCamera {
  36672. /**
  36673. * Defines the touch sensibility for rotation.
  36674. * The higher the faster.
  36675. */
  36676. touchAngularSensibility: number;
  36677. /**
  36678. * Defines the touch sensibility for move.
  36679. * The higher the faster.
  36680. */
  36681. touchMoveSensibility: number;
  36682. /**
  36683. * Instantiates a new touch camera.
  36684. * This represents a FPS type of camera controlled by touch.
  36685. * This is like a universal camera minus the Gamepad controls.
  36686. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36687. * @param name Define the name of the camera in the scene
  36688. * @param position Define the start position of the camera in the scene
  36689. * @param scene Define the scene the camera belongs to
  36690. */
  36691. constructor(name: string, position: Vector3, scene: Scene);
  36692. /**
  36693. * Gets the current object class name.
  36694. * @return the class name
  36695. */
  36696. getClassName(): string;
  36697. /** @hidden */ setupInputs(): void;
  36698. }
  36699. }
  36700. declare module BABYLON {
  36701. /**
  36702. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36703. * being tilted forward or back and left or right.
  36704. */
  36705. export class DeviceOrientationCamera extends FreeCamera {
  36706. private _initialQuaternion;
  36707. private _quaternionCache;
  36708. private _tmpDragQuaternion;
  36709. /**
  36710. * Creates a new device orientation camera
  36711. * @param name The name of the camera
  36712. * @param position The start position camera
  36713. * @param scene The scene the camera belongs to
  36714. */
  36715. constructor(name: string, position: Vector3, scene: Scene);
  36716. /**
  36717. * @hidden
  36718. * Disabled pointer input on first orientation sensor update (Default: true)
  36719. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36720. private _dragFactor;
  36721. /**
  36722. * Enabled turning on the y axis when the orientation sensor is active
  36723. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36724. */
  36725. enableHorizontalDragging(dragFactor?: number): void;
  36726. /**
  36727. * Gets the current instance class name ("DeviceOrientationCamera").
  36728. * This helps avoiding instanceof at run time.
  36729. * @returns the class name
  36730. */
  36731. getClassName(): string;
  36732. /**
  36733. * @hidden
  36734. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36735. */ checkInputs(): void;
  36736. /**
  36737. * Reset the camera to its default orientation on the specified axis only.
  36738. * @param axis The axis to reset
  36739. */
  36740. resetToCurrentRotation(axis?: Axis): void;
  36741. }
  36742. }
  36743. declare module BABYLON {
  36744. /**
  36745. * 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,
  36746. * which still works and will still be found in many Playgrounds.
  36747. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36748. */
  36749. export class UniversalCamera extends TouchCamera {
  36750. /**
  36751. * Defines the gamepad rotation sensiblity.
  36752. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36753. */
  36754. gamepadAngularSensibility: number;
  36755. /**
  36756. * Defines the gamepad move sensiblity.
  36757. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36758. */
  36759. gamepadMoveSensibility: number;
  36760. /**
  36761. * 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,
  36762. * which still works and will still be found in many Playgrounds.
  36763. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36764. * @param name Define the name of the camera in the scene
  36765. * @param position Define the start position of the camera in the scene
  36766. * @param scene Define the scene the camera belongs to
  36767. */
  36768. constructor(name: string, position: Vector3, scene: Scene);
  36769. /**
  36770. * Gets the current object class name.
  36771. * @return the class name
  36772. */
  36773. getClassName(): string;
  36774. }
  36775. }
  36776. declare module BABYLON {
  36777. /**
  36778. * This represents a FPS type of camera. This is only here for back compat purpose.
  36779. * Please use the UniversalCamera instead as both are identical.
  36780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36781. */
  36782. export class GamepadCamera extends UniversalCamera {
  36783. /**
  36784. * Instantiates a new Gamepad Camera
  36785. * This represents a FPS type of camera. This is only here for back compat purpose.
  36786. * Please use the UniversalCamera instead as both are identical.
  36787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36788. * @param name Define the name of the camera in the scene
  36789. * @param position Define the start position of the camera in the scene
  36790. * @param scene Define the scene the camera belongs to
  36791. */
  36792. constructor(name: string, position: Vector3, scene: Scene);
  36793. /**
  36794. * Gets the current object class name.
  36795. * @return the class name
  36796. */
  36797. getClassName(): string;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /** @hidden */
  36802. export var passPixelShader: {
  36803. name: string;
  36804. shader: string;
  36805. };
  36806. }
  36807. declare module BABYLON {
  36808. /** @hidden */
  36809. export var passCubePixelShader: {
  36810. name: string;
  36811. shader: string;
  36812. };
  36813. }
  36814. declare module BABYLON {
  36815. /**
  36816. * PassPostProcess which produces an output the same as it's input
  36817. */
  36818. export class PassPostProcess extends PostProcess {
  36819. /**
  36820. * Creates the PassPostProcess
  36821. * @param name The name of the effect.
  36822. * @param options The required width/height ratio to downsize to before computing the render pass.
  36823. * @param camera The camera to apply the render pass to.
  36824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36825. * @param engine The engine which the post process will be applied. (default: current engine)
  36826. * @param reusable If the post process can be reused on the same frame. (default: false)
  36827. * @param textureType The type of texture to be used when performing the post processing.
  36828. * @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)
  36829. */
  36830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36831. }
  36832. /**
  36833. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36834. */
  36835. export class PassCubePostProcess extends PostProcess {
  36836. private _face;
  36837. /**
  36838. * Gets or sets the cube face to display.
  36839. * * 0 is +X
  36840. * * 1 is -X
  36841. * * 2 is +Y
  36842. * * 3 is -Y
  36843. * * 4 is +Z
  36844. * * 5 is -Z
  36845. */
  36846. face: number;
  36847. /**
  36848. * Creates the PassCubePostProcess
  36849. * @param name The name of the effect.
  36850. * @param options The required width/height ratio to downsize to before computing the render pass.
  36851. * @param camera The camera to apply the render pass to.
  36852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36853. * @param engine The engine which the post process will be applied. (default: current engine)
  36854. * @param reusable If the post process can be reused on the same frame. (default: false)
  36855. * @param textureType The type of texture to be used when performing the post processing.
  36856. * @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)
  36857. */
  36858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36859. }
  36860. }
  36861. declare module BABYLON {
  36862. /** @hidden */
  36863. export var anaglyphPixelShader: {
  36864. name: string;
  36865. shader: string;
  36866. };
  36867. }
  36868. declare module BABYLON {
  36869. /**
  36870. * Postprocess used to generate anaglyphic rendering
  36871. */
  36872. export class AnaglyphPostProcess extends PostProcess {
  36873. private _passedProcess;
  36874. /**
  36875. * Creates a new AnaglyphPostProcess
  36876. * @param name defines postprocess name
  36877. * @param options defines creation options or target ratio scale
  36878. * @param rigCameras defines cameras using this postprocess
  36879. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36880. * @param engine defines hosting engine
  36881. * @param reusable defines if the postprocess will be reused multiple times per frame
  36882. */
  36883. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. /**
  36888. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36889. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36890. */
  36891. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36892. /**
  36893. * Creates a new AnaglyphArcRotateCamera
  36894. * @param name defines camera name
  36895. * @param alpha defines alpha angle (in radians)
  36896. * @param beta defines beta angle (in radians)
  36897. * @param radius defines radius
  36898. * @param target defines camera target
  36899. * @param interaxialDistance defines distance between each color axis
  36900. * @param scene defines the hosting scene
  36901. */
  36902. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36903. /**
  36904. * Gets camera class name
  36905. * @returns AnaglyphArcRotateCamera
  36906. */
  36907. getClassName(): string;
  36908. }
  36909. }
  36910. declare module BABYLON {
  36911. /**
  36912. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36913. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36914. */
  36915. export class AnaglyphFreeCamera extends FreeCamera {
  36916. /**
  36917. * Creates a new AnaglyphFreeCamera
  36918. * @param name defines camera name
  36919. * @param position defines initial position
  36920. * @param interaxialDistance defines distance between each color axis
  36921. * @param scene defines the hosting scene
  36922. */
  36923. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36924. /**
  36925. * Gets camera class name
  36926. * @returns AnaglyphFreeCamera
  36927. */
  36928. getClassName(): string;
  36929. }
  36930. }
  36931. declare module BABYLON {
  36932. /**
  36933. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36934. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36935. */
  36936. export class AnaglyphGamepadCamera extends GamepadCamera {
  36937. /**
  36938. * Creates a new AnaglyphGamepadCamera
  36939. * @param name defines camera name
  36940. * @param position defines initial position
  36941. * @param interaxialDistance defines distance between each color axis
  36942. * @param scene defines the hosting scene
  36943. */
  36944. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36945. /**
  36946. * Gets camera class name
  36947. * @returns AnaglyphGamepadCamera
  36948. */
  36949. getClassName(): string;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36955. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36956. */
  36957. export class AnaglyphUniversalCamera extends UniversalCamera {
  36958. /**
  36959. * Creates a new AnaglyphUniversalCamera
  36960. * @param name defines camera name
  36961. * @param position defines initial position
  36962. * @param interaxialDistance defines distance between each color axis
  36963. * @param scene defines the hosting scene
  36964. */
  36965. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36966. /**
  36967. * Gets camera class name
  36968. * @returns AnaglyphUniversalCamera
  36969. */
  36970. getClassName(): string;
  36971. }
  36972. }
  36973. declare module BABYLON {
  36974. /** @hidden */
  36975. export var stereoscopicInterlacePixelShader: {
  36976. name: string;
  36977. shader: string;
  36978. };
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36983. */
  36984. export class StereoscopicInterlacePostProcess extends PostProcess {
  36985. private _stepSize;
  36986. private _passedProcess;
  36987. /**
  36988. * Initializes a StereoscopicInterlacePostProcess
  36989. * @param name The name of the effect.
  36990. * @param rigCameras The rig cameras to be appled to the post process
  36991. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36993. * @param engine The engine which the post process will be applied. (default: current engine)
  36994. * @param reusable If the post process can be reused on the same frame. (default: false)
  36995. */
  36996. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36997. }
  36998. }
  36999. declare module BABYLON {
  37000. /**
  37001. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37002. * @see http://doc.babylonjs.com/features/cameras
  37003. */
  37004. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37005. /**
  37006. * Creates a new StereoscopicArcRotateCamera
  37007. * @param name defines camera name
  37008. * @param alpha defines alpha angle (in radians)
  37009. * @param beta defines beta angle (in radians)
  37010. * @param radius defines radius
  37011. * @param target defines camera target
  37012. * @param interaxialDistance defines distance between each color axis
  37013. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37014. * @param scene defines the hosting scene
  37015. */
  37016. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37017. /**
  37018. * Gets camera class name
  37019. * @returns StereoscopicArcRotateCamera
  37020. */
  37021. getClassName(): string;
  37022. }
  37023. }
  37024. declare module BABYLON {
  37025. /**
  37026. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37027. * @see http://doc.babylonjs.com/features/cameras
  37028. */
  37029. export class StereoscopicFreeCamera extends FreeCamera {
  37030. /**
  37031. * Creates a new StereoscopicFreeCamera
  37032. * @param name defines camera name
  37033. * @param position defines initial position
  37034. * @param interaxialDistance defines distance between each color axis
  37035. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37036. * @param scene defines the hosting scene
  37037. */
  37038. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37039. /**
  37040. * Gets camera class name
  37041. * @returns StereoscopicFreeCamera
  37042. */
  37043. getClassName(): string;
  37044. }
  37045. }
  37046. declare module BABYLON {
  37047. /**
  37048. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37049. * @see http://doc.babylonjs.com/features/cameras
  37050. */
  37051. export class StereoscopicGamepadCamera extends GamepadCamera {
  37052. /**
  37053. * Creates a new StereoscopicGamepadCamera
  37054. * @param name defines camera name
  37055. * @param position defines initial position
  37056. * @param interaxialDistance defines distance between each color axis
  37057. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37058. * @param scene defines the hosting scene
  37059. */
  37060. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37061. /**
  37062. * Gets camera class name
  37063. * @returns StereoscopicGamepadCamera
  37064. */
  37065. getClassName(): string;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. /**
  37070. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37071. * @see http://doc.babylonjs.com/features/cameras
  37072. */
  37073. export class StereoscopicUniversalCamera extends UniversalCamera {
  37074. /**
  37075. * Creates a new StereoscopicUniversalCamera
  37076. * @param name defines camera name
  37077. * @param position defines initial position
  37078. * @param interaxialDistance defines distance between each color axis
  37079. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37080. * @param scene defines the hosting scene
  37081. */
  37082. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37083. /**
  37084. * Gets camera class name
  37085. * @returns StereoscopicUniversalCamera
  37086. */
  37087. getClassName(): string;
  37088. }
  37089. }
  37090. declare module BABYLON {
  37091. /**
  37092. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37093. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37094. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37095. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37096. */
  37097. export class VirtualJoysticksCamera extends FreeCamera {
  37098. /**
  37099. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37100. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37101. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37102. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37103. * @param name Define the name of the camera in the scene
  37104. * @param position Define the start position of the camera in the scene
  37105. * @param scene Define the scene the camera belongs to
  37106. */
  37107. constructor(name: string, position: Vector3, scene: Scene);
  37108. /**
  37109. * Gets the current object class name.
  37110. * @return the class name
  37111. */
  37112. getClassName(): string;
  37113. }
  37114. }
  37115. declare module BABYLON {
  37116. /**
  37117. * This represents all the required metrics to create a VR camera.
  37118. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37119. */
  37120. export class VRCameraMetrics {
  37121. /**
  37122. * Define the horizontal resolution off the screen.
  37123. */
  37124. hResolution: number;
  37125. /**
  37126. * Define the vertical resolution off the screen.
  37127. */
  37128. vResolution: number;
  37129. /**
  37130. * Define the horizontal screen size.
  37131. */
  37132. hScreenSize: number;
  37133. /**
  37134. * Define the vertical screen size.
  37135. */
  37136. vScreenSize: number;
  37137. /**
  37138. * Define the vertical screen center position.
  37139. */
  37140. vScreenCenter: number;
  37141. /**
  37142. * Define the distance of the eyes to the screen.
  37143. */
  37144. eyeToScreenDistance: number;
  37145. /**
  37146. * Define the distance between both lenses
  37147. */
  37148. lensSeparationDistance: number;
  37149. /**
  37150. * Define the distance between both viewer's eyes.
  37151. */
  37152. interpupillaryDistance: number;
  37153. /**
  37154. * Define the distortion factor of the VR postprocess.
  37155. * Please, touch with care.
  37156. */
  37157. distortionK: number[];
  37158. /**
  37159. * Define the chromatic aberration correction factors for the VR post process.
  37160. */
  37161. chromaAbCorrection: number[];
  37162. /**
  37163. * Define the scale factor of the post process.
  37164. * The smaller the better but the slower.
  37165. */
  37166. postProcessScaleFactor: number;
  37167. /**
  37168. * Define an offset for the lens center.
  37169. */
  37170. lensCenterOffset: number;
  37171. /**
  37172. * Define if the current vr camera should compensate the distortion of the lense or not.
  37173. */
  37174. compensateDistortion: boolean;
  37175. /**
  37176. * Defines if multiview should be enabled when rendering (Default: false)
  37177. */
  37178. multiviewEnabled: boolean;
  37179. /**
  37180. * Gets the rendering aspect ratio based on the provided resolutions.
  37181. */
  37182. readonly aspectRatio: number;
  37183. /**
  37184. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37185. */
  37186. readonly aspectRatioFov: number;
  37187. /**
  37188. * @hidden
  37189. */
  37190. readonly leftHMatrix: Matrix;
  37191. /**
  37192. * @hidden
  37193. */
  37194. readonly rightHMatrix: Matrix;
  37195. /**
  37196. * @hidden
  37197. */
  37198. readonly leftPreViewMatrix: Matrix;
  37199. /**
  37200. * @hidden
  37201. */
  37202. readonly rightPreViewMatrix: Matrix;
  37203. /**
  37204. * Get the default VRMetrics based on the most generic setup.
  37205. * @returns the default vr metrics
  37206. */
  37207. static GetDefault(): VRCameraMetrics;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /** @hidden */
  37212. export var vrDistortionCorrectionPixelShader: {
  37213. name: string;
  37214. shader: string;
  37215. };
  37216. }
  37217. declare module BABYLON {
  37218. /**
  37219. * VRDistortionCorrectionPostProcess used for mobile VR
  37220. */
  37221. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37222. private _isRightEye;
  37223. private _distortionFactors;
  37224. private _postProcessScaleFactor;
  37225. private _lensCenterOffset;
  37226. private _scaleIn;
  37227. private _scaleFactor;
  37228. private _lensCenter;
  37229. /**
  37230. * Initializes the VRDistortionCorrectionPostProcess
  37231. * @param name The name of the effect.
  37232. * @param camera The camera to apply the render pass to.
  37233. * @param isRightEye If this is for the right eye distortion
  37234. * @param vrMetrics All the required metrics for the VR camera
  37235. */
  37236. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37237. }
  37238. }
  37239. declare module BABYLON {
  37240. /**
  37241. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37242. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37243. */
  37244. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37245. /**
  37246. * Creates a new VRDeviceOrientationArcRotateCamera
  37247. * @param name defines camera name
  37248. * @param alpha defines the camera rotation along the logitudinal axis
  37249. * @param beta defines the camera rotation along the latitudinal axis
  37250. * @param radius defines the camera distance from its target
  37251. * @param target defines the camera target
  37252. * @param scene defines the scene the camera belongs to
  37253. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37254. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37255. */
  37256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37257. /**
  37258. * Gets camera class name
  37259. * @returns VRDeviceOrientationArcRotateCamera
  37260. */
  37261. getClassName(): string;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * Camera used to simulate VR rendering (based on FreeCamera)
  37267. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37268. */
  37269. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37270. /**
  37271. * Creates a new VRDeviceOrientationFreeCamera
  37272. * @param name defines camera name
  37273. * @param position defines the start position of the camera
  37274. * @param scene defines the scene the camera belongs to
  37275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37277. */
  37278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37279. /**
  37280. * Gets camera class name
  37281. * @returns VRDeviceOrientationFreeCamera
  37282. */
  37283. getClassName(): string;
  37284. }
  37285. }
  37286. declare module BABYLON {
  37287. /**
  37288. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37289. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37290. */
  37291. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37292. /**
  37293. * Creates a new VRDeviceOrientationGamepadCamera
  37294. * @param name defines camera name
  37295. * @param position defines the start position of the camera
  37296. * @param scene defines the scene the camera belongs to
  37297. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37298. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37299. */
  37300. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37301. /**
  37302. * Gets camera class name
  37303. * @returns VRDeviceOrientationGamepadCamera
  37304. */
  37305. getClassName(): string;
  37306. }
  37307. }
  37308. declare module BABYLON {
  37309. /**
  37310. * Defines supported buttons for XBox360 compatible gamepads
  37311. */
  37312. export enum Xbox360Button {
  37313. /** A */
  37314. A = 0,
  37315. /** B */
  37316. B = 1,
  37317. /** X */
  37318. X = 2,
  37319. /** Y */
  37320. Y = 3,
  37321. /** Start */
  37322. Start = 4,
  37323. /** Back */
  37324. Back = 5,
  37325. /** Left button */
  37326. LB = 6,
  37327. /** Right button */
  37328. RB = 7,
  37329. /** Left stick */
  37330. LeftStick = 8,
  37331. /** Right stick */
  37332. RightStick = 9
  37333. }
  37334. /** Defines values for XBox360 DPad */
  37335. export enum Xbox360Dpad {
  37336. /** Up */
  37337. Up = 0,
  37338. /** Down */
  37339. Down = 1,
  37340. /** Left */
  37341. Left = 2,
  37342. /** Right */
  37343. Right = 3
  37344. }
  37345. /**
  37346. * Defines a XBox360 gamepad
  37347. */
  37348. export class Xbox360Pad extends Gamepad {
  37349. private _leftTrigger;
  37350. private _rightTrigger;
  37351. private _onlefttriggerchanged;
  37352. private _onrighttriggerchanged;
  37353. private _onbuttondown;
  37354. private _onbuttonup;
  37355. private _ondpaddown;
  37356. private _ondpadup;
  37357. /** Observable raised when a button is pressed */
  37358. onButtonDownObservable: Observable<Xbox360Button>;
  37359. /** Observable raised when a button is released */
  37360. onButtonUpObservable: Observable<Xbox360Button>;
  37361. /** Observable raised when a pad is pressed */
  37362. onPadDownObservable: Observable<Xbox360Dpad>;
  37363. /** Observable raised when a pad is released */
  37364. onPadUpObservable: Observable<Xbox360Dpad>;
  37365. private _buttonA;
  37366. private _buttonB;
  37367. private _buttonX;
  37368. private _buttonY;
  37369. private _buttonBack;
  37370. private _buttonStart;
  37371. private _buttonLB;
  37372. private _buttonRB;
  37373. private _buttonLeftStick;
  37374. private _buttonRightStick;
  37375. private _dPadUp;
  37376. private _dPadDown;
  37377. private _dPadLeft;
  37378. private _dPadRight;
  37379. private _isXboxOnePad;
  37380. /**
  37381. * Creates a new XBox360 gamepad object
  37382. * @param id defines the id of this gamepad
  37383. * @param index defines its index
  37384. * @param gamepad defines the internal HTML gamepad object
  37385. * @param xboxOne defines if it is a XBox One gamepad
  37386. */
  37387. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37388. /**
  37389. * Defines the callback to call when left trigger is pressed
  37390. * @param callback defines the callback to use
  37391. */
  37392. onlefttriggerchanged(callback: (value: number) => void): void;
  37393. /**
  37394. * Defines the callback to call when right trigger is pressed
  37395. * @param callback defines the callback to use
  37396. */
  37397. onrighttriggerchanged(callback: (value: number) => void): void;
  37398. /**
  37399. * Gets the left trigger value
  37400. */
  37401. /**
  37402. * Sets the left trigger value
  37403. */
  37404. leftTrigger: number;
  37405. /**
  37406. * Gets the right trigger value
  37407. */
  37408. /**
  37409. * Sets the right trigger value
  37410. */
  37411. rightTrigger: number;
  37412. /**
  37413. * Defines the callback to call when a button is pressed
  37414. * @param callback defines the callback to use
  37415. */
  37416. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37417. /**
  37418. * Defines the callback to call when a button is released
  37419. * @param callback defines the callback to use
  37420. */
  37421. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37422. /**
  37423. * Defines the callback to call when a pad is pressed
  37424. * @param callback defines the callback to use
  37425. */
  37426. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37427. /**
  37428. * Defines the callback to call when a pad is released
  37429. * @param callback defines the callback to use
  37430. */
  37431. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37432. private _setButtonValue;
  37433. private _setDPadValue;
  37434. /**
  37435. * Gets the value of the `A` button
  37436. */
  37437. /**
  37438. * Sets the value of the `A` button
  37439. */
  37440. buttonA: number;
  37441. /**
  37442. * Gets the value of the `B` button
  37443. */
  37444. /**
  37445. * Sets the value of the `B` button
  37446. */
  37447. buttonB: number;
  37448. /**
  37449. * Gets the value of the `X` button
  37450. */
  37451. /**
  37452. * Sets the value of the `X` button
  37453. */
  37454. buttonX: number;
  37455. /**
  37456. * Gets the value of the `Y` button
  37457. */
  37458. /**
  37459. * Sets the value of the `Y` button
  37460. */
  37461. buttonY: number;
  37462. /**
  37463. * Gets the value of the `Start` button
  37464. */
  37465. /**
  37466. * Sets the value of the `Start` button
  37467. */
  37468. buttonStart: number;
  37469. /**
  37470. * Gets the value of the `Back` button
  37471. */
  37472. /**
  37473. * Sets the value of the `Back` button
  37474. */
  37475. buttonBack: number;
  37476. /**
  37477. * Gets the value of the `Left` button
  37478. */
  37479. /**
  37480. * Sets the value of the `Left` button
  37481. */
  37482. buttonLB: number;
  37483. /**
  37484. * Gets the value of the `Right` button
  37485. */
  37486. /**
  37487. * Sets the value of the `Right` button
  37488. */
  37489. buttonRB: number;
  37490. /**
  37491. * Gets the value of the Left joystick
  37492. */
  37493. /**
  37494. * Sets the value of the Left joystick
  37495. */
  37496. buttonLeftStick: number;
  37497. /**
  37498. * Gets the value of the Right joystick
  37499. */
  37500. /**
  37501. * Sets the value of the Right joystick
  37502. */
  37503. buttonRightStick: number;
  37504. /**
  37505. * Gets the value of D-pad up
  37506. */
  37507. /**
  37508. * Sets the value of D-pad up
  37509. */
  37510. dPadUp: number;
  37511. /**
  37512. * Gets the value of D-pad down
  37513. */
  37514. /**
  37515. * Sets the value of D-pad down
  37516. */
  37517. dPadDown: number;
  37518. /**
  37519. * Gets the value of D-pad left
  37520. */
  37521. /**
  37522. * Sets the value of D-pad left
  37523. */
  37524. dPadLeft: number;
  37525. /**
  37526. * Gets the value of D-pad right
  37527. */
  37528. /**
  37529. * Sets the value of D-pad right
  37530. */
  37531. dPadRight: number;
  37532. /**
  37533. * Force the gamepad to synchronize with device values
  37534. */
  37535. update(): void;
  37536. /**
  37537. * Disposes the gamepad
  37538. */
  37539. dispose(): void;
  37540. }
  37541. }
  37542. declare module BABYLON {
  37543. /**
  37544. * Base class of materials working in push mode in babylon JS
  37545. * @hidden
  37546. */
  37547. export class PushMaterial extends Material {
  37548. protected _activeEffect: Effect;
  37549. protected _normalMatrix: Matrix;
  37550. /**
  37551. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37552. * This means that the material can keep using a previous shader while a new one is being compiled.
  37553. * This is mostly used when shader parallel compilation is supported (true by default)
  37554. */
  37555. allowShaderHotSwapping: boolean;
  37556. constructor(name: string, scene: Scene);
  37557. getEffect(): Effect;
  37558. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37559. /**
  37560. * Binds the given world matrix to the active effect
  37561. *
  37562. * @param world the matrix to bind
  37563. */
  37564. bindOnlyWorldMatrix(world: Matrix): void;
  37565. /**
  37566. * Binds the given normal matrix to the active effect
  37567. *
  37568. * @param normalMatrix the matrix to bind
  37569. */
  37570. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37571. bind(world: Matrix, mesh?: Mesh): void;
  37572. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37573. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37574. }
  37575. }
  37576. declare module BABYLON {
  37577. /**
  37578. * This groups all the flags used to control the materials channel.
  37579. */
  37580. export class MaterialFlags {
  37581. private static _DiffuseTextureEnabled;
  37582. /**
  37583. * Are diffuse textures enabled in the application.
  37584. */
  37585. static DiffuseTextureEnabled: boolean;
  37586. private static _AmbientTextureEnabled;
  37587. /**
  37588. * Are ambient textures enabled in the application.
  37589. */
  37590. static AmbientTextureEnabled: boolean;
  37591. private static _OpacityTextureEnabled;
  37592. /**
  37593. * Are opacity textures enabled in the application.
  37594. */
  37595. static OpacityTextureEnabled: boolean;
  37596. private static _ReflectionTextureEnabled;
  37597. /**
  37598. * Are reflection textures enabled in the application.
  37599. */
  37600. static ReflectionTextureEnabled: boolean;
  37601. private static _EmissiveTextureEnabled;
  37602. /**
  37603. * Are emissive textures enabled in the application.
  37604. */
  37605. static EmissiveTextureEnabled: boolean;
  37606. private static _SpecularTextureEnabled;
  37607. /**
  37608. * Are specular textures enabled in the application.
  37609. */
  37610. static SpecularTextureEnabled: boolean;
  37611. private static _BumpTextureEnabled;
  37612. /**
  37613. * Are bump textures enabled in the application.
  37614. */
  37615. static BumpTextureEnabled: boolean;
  37616. private static _LightmapTextureEnabled;
  37617. /**
  37618. * Are lightmap textures enabled in the application.
  37619. */
  37620. static LightmapTextureEnabled: boolean;
  37621. private static _RefractionTextureEnabled;
  37622. /**
  37623. * Are refraction textures enabled in the application.
  37624. */
  37625. static RefractionTextureEnabled: boolean;
  37626. private static _ColorGradingTextureEnabled;
  37627. /**
  37628. * Are color grading textures enabled in the application.
  37629. */
  37630. static ColorGradingTextureEnabled: boolean;
  37631. private static _FresnelEnabled;
  37632. /**
  37633. * Are fresnels enabled in the application.
  37634. */
  37635. static FresnelEnabled: boolean;
  37636. private static _ClearCoatTextureEnabled;
  37637. /**
  37638. * Are clear coat textures enabled in the application.
  37639. */
  37640. static ClearCoatTextureEnabled: boolean;
  37641. private static _ClearCoatBumpTextureEnabled;
  37642. /**
  37643. * Are clear coat bump textures enabled in the application.
  37644. */
  37645. static ClearCoatBumpTextureEnabled: boolean;
  37646. private static _ClearCoatTintTextureEnabled;
  37647. /**
  37648. * Are clear coat tint textures enabled in the application.
  37649. */
  37650. static ClearCoatTintTextureEnabled: boolean;
  37651. private static _SheenTextureEnabled;
  37652. /**
  37653. * Are sheen textures enabled in the application.
  37654. */
  37655. static SheenTextureEnabled: boolean;
  37656. private static _AnisotropicTextureEnabled;
  37657. /**
  37658. * Are anisotropic textures enabled in the application.
  37659. */
  37660. static AnisotropicTextureEnabled: boolean;
  37661. private static _ThicknessTextureEnabled;
  37662. /**
  37663. * Are thickness textures enabled in the application.
  37664. */
  37665. static ThicknessTextureEnabled: boolean;
  37666. }
  37667. }
  37668. declare module BABYLON {
  37669. /** @hidden */
  37670. export var defaultFragmentDeclaration: {
  37671. name: string;
  37672. shader: string;
  37673. };
  37674. }
  37675. declare module BABYLON {
  37676. /** @hidden */
  37677. export var defaultUboDeclaration: {
  37678. name: string;
  37679. shader: string;
  37680. };
  37681. }
  37682. declare module BABYLON {
  37683. /** @hidden */
  37684. export var lightFragmentDeclaration: {
  37685. name: string;
  37686. shader: string;
  37687. };
  37688. }
  37689. declare module BABYLON {
  37690. /** @hidden */
  37691. export var lightUboDeclaration: {
  37692. name: string;
  37693. shader: string;
  37694. };
  37695. }
  37696. declare module BABYLON {
  37697. /** @hidden */
  37698. export var lightsFragmentFunctions: {
  37699. name: string;
  37700. shader: string;
  37701. };
  37702. }
  37703. declare module BABYLON {
  37704. /** @hidden */
  37705. export var shadowsFragmentFunctions: {
  37706. name: string;
  37707. shader: string;
  37708. };
  37709. }
  37710. declare module BABYLON {
  37711. /** @hidden */
  37712. export var fresnelFunction: {
  37713. name: string;
  37714. shader: string;
  37715. };
  37716. }
  37717. declare module BABYLON {
  37718. /** @hidden */
  37719. export var reflectionFunction: {
  37720. name: string;
  37721. shader: string;
  37722. };
  37723. }
  37724. declare module BABYLON {
  37725. /** @hidden */
  37726. export var bumpFragmentFunctions: {
  37727. name: string;
  37728. shader: string;
  37729. };
  37730. }
  37731. declare module BABYLON {
  37732. /** @hidden */
  37733. export var logDepthDeclaration: {
  37734. name: string;
  37735. shader: string;
  37736. };
  37737. }
  37738. declare module BABYLON {
  37739. /** @hidden */
  37740. export var bumpFragment: {
  37741. name: string;
  37742. shader: string;
  37743. };
  37744. }
  37745. declare module BABYLON {
  37746. /** @hidden */
  37747. export var depthPrePass: {
  37748. name: string;
  37749. shader: string;
  37750. };
  37751. }
  37752. declare module BABYLON {
  37753. /** @hidden */
  37754. export var lightFragment: {
  37755. name: string;
  37756. shader: string;
  37757. };
  37758. }
  37759. declare module BABYLON {
  37760. /** @hidden */
  37761. export var logDepthFragment: {
  37762. name: string;
  37763. shader: string;
  37764. };
  37765. }
  37766. declare module BABYLON {
  37767. /** @hidden */
  37768. export var defaultPixelShader: {
  37769. name: string;
  37770. shader: string;
  37771. };
  37772. }
  37773. declare module BABYLON {
  37774. /** @hidden */
  37775. export var defaultVertexDeclaration: {
  37776. name: string;
  37777. shader: string;
  37778. };
  37779. }
  37780. declare module BABYLON {
  37781. /** @hidden */
  37782. export var bumpVertexDeclaration: {
  37783. name: string;
  37784. shader: string;
  37785. };
  37786. }
  37787. declare module BABYLON {
  37788. /** @hidden */
  37789. export var bumpVertex: {
  37790. name: string;
  37791. shader: string;
  37792. };
  37793. }
  37794. declare module BABYLON {
  37795. /** @hidden */
  37796. export var fogVertex: {
  37797. name: string;
  37798. shader: string;
  37799. };
  37800. }
  37801. declare module BABYLON {
  37802. /** @hidden */
  37803. export var shadowsVertex: {
  37804. name: string;
  37805. shader: string;
  37806. };
  37807. }
  37808. declare module BABYLON {
  37809. /** @hidden */
  37810. export var pointCloudVertex: {
  37811. name: string;
  37812. shader: string;
  37813. };
  37814. }
  37815. declare module BABYLON {
  37816. /** @hidden */
  37817. export var logDepthVertex: {
  37818. name: string;
  37819. shader: string;
  37820. };
  37821. }
  37822. declare module BABYLON {
  37823. /** @hidden */
  37824. export var defaultVertexShader: {
  37825. name: string;
  37826. shader: string;
  37827. };
  37828. }
  37829. declare module BABYLON {
  37830. /** @hidden */
  37831. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37832. MAINUV1: boolean;
  37833. MAINUV2: boolean;
  37834. DIFFUSE: boolean;
  37835. DIFFUSEDIRECTUV: number;
  37836. AMBIENT: boolean;
  37837. AMBIENTDIRECTUV: number;
  37838. OPACITY: boolean;
  37839. OPACITYDIRECTUV: number;
  37840. OPACITYRGB: boolean;
  37841. REFLECTION: boolean;
  37842. EMISSIVE: boolean;
  37843. EMISSIVEDIRECTUV: number;
  37844. SPECULAR: boolean;
  37845. SPECULARDIRECTUV: number;
  37846. BUMP: boolean;
  37847. BUMPDIRECTUV: number;
  37848. PARALLAX: boolean;
  37849. PARALLAXOCCLUSION: boolean;
  37850. SPECULAROVERALPHA: boolean;
  37851. CLIPPLANE: boolean;
  37852. CLIPPLANE2: boolean;
  37853. CLIPPLANE3: boolean;
  37854. CLIPPLANE4: boolean;
  37855. ALPHATEST: boolean;
  37856. DEPTHPREPASS: boolean;
  37857. ALPHAFROMDIFFUSE: boolean;
  37858. POINTSIZE: boolean;
  37859. FOG: boolean;
  37860. SPECULARTERM: boolean;
  37861. DIFFUSEFRESNEL: boolean;
  37862. OPACITYFRESNEL: boolean;
  37863. REFLECTIONFRESNEL: boolean;
  37864. REFRACTIONFRESNEL: boolean;
  37865. EMISSIVEFRESNEL: boolean;
  37866. FRESNEL: boolean;
  37867. NORMAL: boolean;
  37868. UV1: boolean;
  37869. UV2: boolean;
  37870. VERTEXCOLOR: boolean;
  37871. VERTEXALPHA: boolean;
  37872. NUM_BONE_INFLUENCERS: number;
  37873. BonesPerMesh: number;
  37874. BONETEXTURE: boolean;
  37875. INSTANCES: boolean;
  37876. GLOSSINESS: boolean;
  37877. ROUGHNESS: boolean;
  37878. EMISSIVEASILLUMINATION: boolean;
  37879. LINKEMISSIVEWITHDIFFUSE: boolean;
  37880. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37881. LIGHTMAP: boolean;
  37882. LIGHTMAPDIRECTUV: number;
  37883. OBJECTSPACE_NORMALMAP: boolean;
  37884. USELIGHTMAPASSHADOWMAP: boolean;
  37885. REFLECTIONMAP_3D: boolean;
  37886. REFLECTIONMAP_SPHERICAL: boolean;
  37887. REFLECTIONMAP_PLANAR: boolean;
  37888. REFLECTIONMAP_CUBIC: boolean;
  37889. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37890. REFLECTIONMAP_PROJECTION: boolean;
  37891. REFLECTIONMAP_SKYBOX: boolean;
  37892. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37893. REFLECTIONMAP_EXPLICIT: boolean;
  37894. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37895. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37896. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37897. INVERTCUBICMAP: boolean;
  37898. LOGARITHMICDEPTH: boolean;
  37899. REFRACTION: boolean;
  37900. REFRACTIONMAP_3D: boolean;
  37901. REFLECTIONOVERALPHA: boolean;
  37902. TWOSIDEDLIGHTING: boolean;
  37903. SHADOWFLOAT: boolean;
  37904. MORPHTARGETS: boolean;
  37905. MORPHTARGETS_NORMAL: boolean;
  37906. MORPHTARGETS_TANGENT: boolean;
  37907. NUM_MORPH_INFLUENCERS: number;
  37908. NONUNIFORMSCALING: boolean;
  37909. PREMULTIPLYALPHA: boolean;
  37910. IMAGEPROCESSING: boolean;
  37911. VIGNETTE: boolean;
  37912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37913. VIGNETTEBLENDMODEOPAQUE: boolean;
  37914. TONEMAPPING: boolean;
  37915. TONEMAPPING_ACES: boolean;
  37916. CONTRAST: boolean;
  37917. COLORCURVES: boolean;
  37918. COLORGRADING: boolean;
  37919. COLORGRADING3D: boolean;
  37920. SAMPLER3DGREENDEPTH: boolean;
  37921. SAMPLER3DBGRMAP: boolean;
  37922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37923. MULTIVIEW: boolean;
  37924. /**
  37925. * If the reflection texture on this material is in linear color space
  37926. * @hidden
  37927. */
  37928. IS_REFLECTION_LINEAR: boolean;
  37929. /**
  37930. * If the refraction texture on this material is in linear color space
  37931. * @hidden
  37932. */
  37933. IS_REFRACTION_LINEAR: boolean;
  37934. EXPOSURE: boolean;
  37935. constructor();
  37936. setReflectionMode(modeToEnable: string): void;
  37937. }
  37938. /**
  37939. * This is the default material used in Babylon. It is the best trade off between quality
  37940. * and performances.
  37941. * @see http://doc.babylonjs.com/babylon101/materials
  37942. */
  37943. export class StandardMaterial extends PushMaterial {
  37944. private _diffuseTexture;
  37945. /**
  37946. * The basic texture of the material as viewed under a light.
  37947. */
  37948. diffuseTexture: Nullable<BaseTexture>;
  37949. private _ambientTexture;
  37950. /**
  37951. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37952. */
  37953. ambientTexture: Nullable<BaseTexture>;
  37954. private _opacityTexture;
  37955. /**
  37956. * Define the transparency of the material from a texture.
  37957. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37958. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37959. */
  37960. opacityTexture: Nullable<BaseTexture>;
  37961. private _reflectionTexture;
  37962. /**
  37963. * Define the texture used to display the reflection.
  37964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37965. */
  37966. reflectionTexture: Nullable<BaseTexture>;
  37967. private _emissiveTexture;
  37968. /**
  37969. * Define texture of the material as if self lit.
  37970. * This will be mixed in the final result even in the absence of light.
  37971. */
  37972. emissiveTexture: Nullable<BaseTexture>;
  37973. private _specularTexture;
  37974. /**
  37975. * Define how the color and intensity of the highlight given by the light in the material.
  37976. */
  37977. specularTexture: Nullable<BaseTexture>;
  37978. private _bumpTexture;
  37979. /**
  37980. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37981. * 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.
  37982. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37983. */
  37984. bumpTexture: Nullable<BaseTexture>;
  37985. private _lightmapTexture;
  37986. /**
  37987. * Complex lighting can be computationally expensive to compute at runtime.
  37988. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37989. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37990. */
  37991. lightmapTexture: Nullable<BaseTexture>;
  37992. private _refractionTexture;
  37993. /**
  37994. * Define the texture used to display the refraction.
  37995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37996. */
  37997. refractionTexture: Nullable<BaseTexture>;
  37998. /**
  37999. * The color of the material lit by the environmental background lighting.
  38000. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38001. */
  38002. ambientColor: Color3;
  38003. /**
  38004. * The basic color of the material as viewed under a light.
  38005. */
  38006. diffuseColor: Color3;
  38007. /**
  38008. * Define how the color and intensity of the highlight given by the light in the material.
  38009. */
  38010. specularColor: Color3;
  38011. /**
  38012. * Define the color of the material as if self lit.
  38013. * This will be mixed in the final result even in the absence of light.
  38014. */
  38015. emissiveColor: Color3;
  38016. /**
  38017. * Defines how sharp are the highlights in the material.
  38018. * The bigger the value the sharper giving a more glossy feeling to the result.
  38019. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38020. */
  38021. specularPower: number;
  38022. private _useAlphaFromDiffuseTexture;
  38023. /**
  38024. * Does the transparency come from the diffuse texture alpha channel.
  38025. */
  38026. useAlphaFromDiffuseTexture: boolean;
  38027. private _useEmissiveAsIllumination;
  38028. /**
  38029. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38030. */
  38031. useEmissiveAsIllumination: boolean;
  38032. private _linkEmissiveWithDiffuse;
  38033. /**
  38034. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38035. * the emissive level when the final color is close to one.
  38036. */
  38037. linkEmissiveWithDiffuse: boolean;
  38038. private _useSpecularOverAlpha;
  38039. /**
  38040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38042. */
  38043. useSpecularOverAlpha: boolean;
  38044. private _useReflectionOverAlpha;
  38045. /**
  38046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38048. */
  38049. useReflectionOverAlpha: boolean;
  38050. private _disableLighting;
  38051. /**
  38052. * Does lights from the scene impacts this material.
  38053. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38054. */
  38055. disableLighting: boolean;
  38056. private _useObjectSpaceNormalMap;
  38057. /**
  38058. * Allows using an object space normal map (instead of tangent space).
  38059. */
  38060. useObjectSpaceNormalMap: boolean;
  38061. private _useParallax;
  38062. /**
  38063. * Is parallax enabled or not.
  38064. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38065. */
  38066. useParallax: boolean;
  38067. private _useParallaxOcclusion;
  38068. /**
  38069. * Is parallax occlusion enabled or not.
  38070. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38072. */
  38073. useParallaxOcclusion: boolean;
  38074. /**
  38075. * 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.
  38076. */
  38077. parallaxScaleBias: number;
  38078. private _roughness;
  38079. /**
  38080. * Helps to define how blurry the reflections should appears in the material.
  38081. */
  38082. roughness: number;
  38083. /**
  38084. * In case of refraction, define the value of the indice of refraction.
  38085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38086. */
  38087. indexOfRefraction: number;
  38088. /**
  38089. * Invert the refraction texture alongside the y axis.
  38090. * It can be useful with procedural textures or probe for instance.
  38091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38092. */
  38093. invertRefractionY: boolean;
  38094. /**
  38095. * Defines the alpha limits in alpha test mode.
  38096. */
  38097. alphaCutOff: number;
  38098. private _useLightmapAsShadowmap;
  38099. /**
  38100. * In case of light mapping, define whether the map contains light or shadow informations.
  38101. */
  38102. useLightmapAsShadowmap: boolean;
  38103. private _diffuseFresnelParameters;
  38104. /**
  38105. * Define the diffuse fresnel parameters of the material.
  38106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38107. */
  38108. diffuseFresnelParameters: FresnelParameters;
  38109. private _opacityFresnelParameters;
  38110. /**
  38111. * Define the opacity fresnel parameters of the material.
  38112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38113. */
  38114. opacityFresnelParameters: FresnelParameters;
  38115. private _reflectionFresnelParameters;
  38116. /**
  38117. * Define the reflection fresnel parameters of the material.
  38118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38119. */
  38120. reflectionFresnelParameters: FresnelParameters;
  38121. private _refractionFresnelParameters;
  38122. /**
  38123. * Define the refraction fresnel parameters of the material.
  38124. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38125. */
  38126. refractionFresnelParameters: FresnelParameters;
  38127. private _emissiveFresnelParameters;
  38128. /**
  38129. * Define the emissive fresnel parameters of the material.
  38130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38131. */
  38132. emissiveFresnelParameters: FresnelParameters;
  38133. private _useReflectionFresnelFromSpecular;
  38134. /**
  38135. * If true automatically deducts the fresnels values from the material specularity.
  38136. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38137. */
  38138. useReflectionFresnelFromSpecular: boolean;
  38139. private _useGlossinessFromSpecularMapAlpha;
  38140. /**
  38141. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38142. */
  38143. useGlossinessFromSpecularMapAlpha: boolean;
  38144. private _maxSimultaneousLights;
  38145. /**
  38146. * Defines the maximum number of lights that can be used in the material
  38147. */
  38148. maxSimultaneousLights: number;
  38149. private _invertNormalMapX;
  38150. /**
  38151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38152. */
  38153. invertNormalMapX: boolean;
  38154. private _invertNormalMapY;
  38155. /**
  38156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38157. */
  38158. invertNormalMapY: boolean;
  38159. private _twoSidedLighting;
  38160. /**
  38161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38162. */
  38163. twoSidedLighting: boolean;
  38164. /**
  38165. * Default configuration related to image processing available in the standard Material.
  38166. */
  38167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38168. /**
  38169. * Gets the image processing configuration used either in this material.
  38170. */
  38171. /**
  38172. * Sets the Default image processing configuration used either in the this material.
  38173. *
  38174. * If sets to null, the scene one is in use.
  38175. */
  38176. imageProcessingConfiguration: ImageProcessingConfiguration;
  38177. /**
  38178. * Keep track of the image processing observer to allow dispose and replace.
  38179. */
  38180. private _imageProcessingObserver;
  38181. /**
  38182. * Attaches a new image processing configuration to the Standard Material.
  38183. * @param configuration
  38184. */
  38185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38186. /**
  38187. * Gets wether the color curves effect is enabled.
  38188. */
  38189. /**
  38190. * Sets wether the color curves effect is enabled.
  38191. */
  38192. cameraColorCurvesEnabled: boolean;
  38193. /**
  38194. * Gets wether the color grading effect is enabled.
  38195. */
  38196. /**
  38197. * Gets wether the color grading effect is enabled.
  38198. */
  38199. cameraColorGradingEnabled: boolean;
  38200. /**
  38201. * Gets wether tonemapping is enabled or not.
  38202. */
  38203. /**
  38204. * Sets wether tonemapping is enabled or not
  38205. */
  38206. cameraToneMappingEnabled: boolean;
  38207. /**
  38208. * The camera exposure used on this material.
  38209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38210. * This corresponds to a photographic exposure.
  38211. */
  38212. /**
  38213. * The camera exposure used on this material.
  38214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38215. * This corresponds to a photographic exposure.
  38216. */
  38217. cameraExposure: number;
  38218. /**
  38219. * Gets The camera contrast used on this material.
  38220. */
  38221. /**
  38222. * Sets The camera contrast used on this material.
  38223. */
  38224. cameraContrast: number;
  38225. /**
  38226. * Gets the Color Grading 2D Lookup Texture.
  38227. */
  38228. /**
  38229. * Sets the Color Grading 2D Lookup Texture.
  38230. */
  38231. cameraColorGradingTexture: Nullable<BaseTexture>;
  38232. /**
  38233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38235. * 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;
  38236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38237. */
  38238. /**
  38239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38241. * 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;
  38242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38243. */
  38244. cameraColorCurves: Nullable<ColorCurves>;
  38245. /**
  38246. * Custom callback helping to override the default shader used in the material.
  38247. */
  38248. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38249. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38250. protected _worldViewProjectionMatrix: Matrix;
  38251. protected _globalAmbientColor: Color3;
  38252. protected _useLogarithmicDepth: boolean;
  38253. /**
  38254. * Instantiates a new standard material.
  38255. * This is the default material used in Babylon. It is the best trade off between quality
  38256. * and performances.
  38257. * @see http://doc.babylonjs.com/babylon101/materials
  38258. * @param name Define the name of the material in the scene
  38259. * @param scene Define the scene the material belong to
  38260. */
  38261. constructor(name: string, scene: Scene);
  38262. /**
  38263. * Gets a boolean indicating that current material needs to register RTT
  38264. */
  38265. readonly hasRenderTargetTextures: boolean;
  38266. /**
  38267. * Gets the current class name of the material e.g. "StandardMaterial"
  38268. * Mainly use in serialization.
  38269. * @returns the class name
  38270. */
  38271. getClassName(): string;
  38272. /**
  38273. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38274. * You can try switching to logarithmic depth.
  38275. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38276. */
  38277. useLogarithmicDepth: boolean;
  38278. /**
  38279. * Specifies if the material will require alpha blending
  38280. * @returns a boolean specifying if alpha blending is needed
  38281. */
  38282. needAlphaBlending(): boolean;
  38283. /**
  38284. * Specifies if this material should be rendered in alpha test mode
  38285. * @returns a boolean specifying if an alpha test is needed.
  38286. */
  38287. needAlphaTesting(): boolean;
  38288. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38289. /**
  38290. * Get the texture used for alpha test purpose.
  38291. * @returns the diffuse texture in case of the standard material.
  38292. */
  38293. getAlphaTestTexture(): Nullable<BaseTexture>;
  38294. /**
  38295. * Get if the submesh is ready to be used and all its information available.
  38296. * Child classes can use it to update shaders
  38297. * @param mesh defines the mesh to check
  38298. * @param subMesh defines which submesh to check
  38299. * @param useInstances specifies that instances should be used
  38300. * @returns a boolean indicating that the submesh is ready or not
  38301. */
  38302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38303. /**
  38304. * Builds the material UBO layouts.
  38305. * Used internally during the effect preparation.
  38306. */
  38307. buildUniformLayout(): void;
  38308. /**
  38309. * Unbinds the material from the mesh
  38310. */
  38311. unbind(): void;
  38312. /**
  38313. * Binds the submesh to this material by preparing the effect and shader to draw
  38314. * @param world defines the world transformation matrix
  38315. * @param mesh defines the mesh containing the submesh
  38316. * @param subMesh defines the submesh to bind the material to
  38317. */
  38318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38319. /**
  38320. * Get the list of animatables in the material.
  38321. * @returns the list of animatables object used in the material
  38322. */
  38323. getAnimatables(): IAnimatable[];
  38324. /**
  38325. * Gets the active textures from the material
  38326. * @returns an array of textures
  38327. */
  38328. getActiveTextures(): BaseTexture[];
  38329. /**
  38330. * Specifies if the material uses a texture
  38331. * @param texture defines the texture to check against the material
  38332. * @returns a boolean specifying if the material uses the texture
  38333. */
  38334. hasTexture(texture: BaseTexture): boolean;
  38335. /**
  38336. * Disposes the material
  38337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38339. */
  38340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38341. /**
  38342. * Makes a duplicate of the material, and gives it a new name
  38343. * @param name defines the new name for the duplicated material
  38344. * @returns the cloned material
  38345. */
  38346. clone(name: string): StandardMaterial;
  38347. /**
  38348. * Serializes this material in a JSON representation
  38349. * @returns the serialized material object
  38350. */
  38351. serialize(): any;
  38352. /**
  38353. * Creates a standard material from parsed material data
  38354. * @param source defines the JSON representation of the material
  38355. * @param scene defines the hosting scene
  38356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38357. * @returns a new standard material
  38358. */
  38359. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38360. /**
  38361. * Are diffuse textures enabled in the application.
  38362. */
  38363. static DiffuseTextureEnabled: boolean;
  38364. /**
  38365. * Are ambient textures enabled in the application.
  38366. */
  38367. static AmbientTextureEnabled: boolean;
  38368. /**
  38369. * Are opacity textures enabled in the application.
  38370. */
  38371. static OpacityTextureEnabled: boolean;
  38372. /**
  38373. * Are reflection textures enabled in the application.
  38374. */
  38375. static ReflectionTextureEnabled: boolean;
  38376. /**
  38377. * Are emissive textures enabled in the application.
  38378. */
  38379. static EmissiveTextureEnabled: boolean;
  38380. /**
  38381. * Are specular textures enabled in the application.
  38382. */
  38383. static SpecularTextureEnabled: boolean;
  38384. /**
  38385. * Are bump textures enabled in the application.
  38386. */
  38387. static BumpTextureEnabled: boolean;
  38388. /**
  38389. * Are lightmap textures enabled in the application.
  38390. */
  38391. static LightmapTextureEnabled: boolean;
  38392. /**
  38393. * Are refraction textures enabled in the application.
  38394. */
  38395. static RefractionTextureEnabled: boolean;
  38396. /**
  38397. * Are color grading textures enabled in the application.
  38398. */
  38399. static ColorGradingTextureEnabled: boolean;
  38400. /**
  38401. * Are fresnels enabled in the application.
  38402. */
  38403. static FresnelEnabled: boolean;
  38404. }
  38405. }
  38406. declare module BABYLON {
  38407. /**
  38408. * A class extending Texture allowing drawing on a texture
  38409. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38410. */
  38411. export class DynamicTexture extends Texture {
  38412. private _generateMipMaps;
  38413. private _canvas;
  38414. private _context;
  38415. private _engine;
  38416. /**
  38417. * Creates a DynamicTexture
  38418. * @param name defines the name of the texture
  38419. * @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
  38420. * @param scene defines the scene where you want the texture
  38421. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38423. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38424. */
  38425. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38426. /**
  38427. * Get the current class name of the texture useful for serialization or dynamic coding.
  38428. * @returns "DynamicTexture"
  38429. */
  38430. getClassName(): string;
  38431. /**
  38432. * Gets the current state of canRescale
  38433. */
  38434. readonly canRescale: boolean;
  38435. private _recreate;
  38436. /**
  38437. * Scales the texture
  38438. * @param ratio the scale factor to apply to both width and height
  38439. */
  38440. scale(ratio: number): void;
  38441. /**
  38442. * Resizes the texture
  38443. * @param width the new width
  38444. * @param height the new height
  38445. */
  38446. scaleTo(width: number, height: number): void;
  38447. /**
  38448. * Gets the context of the canvas used by the texture
  38449. * @returns the canvas context of the dynamic texture
  38450. */
  38451. getContext(): CanvasRenderingContext2D;
  38452. /**
  38453. * Clears the texture
  38454. */
  38455. clear(): void;
  38456. /**
  38457. * Updates the texture
  38458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38459. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38460. */
  38461. update(invertY?: boolean, premulAlpha?: boolean): void;
  38462. /**
  38463. * Draws text onto the texture
  38464. * @param text defines the text to be drawn
  38465. * @param x defines the placement of the text from the left
  38466. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38467. * @param font defines the font to be used with font-style, font-size, font-name
  38468. * @param color defines the color used for the text
  38469. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38470. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38471. * @param update defines whether texture is immediately update (default is true)
  38472. */
  38473. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38474. /**
  38475. * Clones the texture
  38476. * @returns the clone of the texture.
  38477. */
  38478. clone(): DynamicTexture;
  38479. /**
  38480. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38481. * @returns a serialized dynamic texture object
  38482. */
  38483. serialize(): any;
  38484. /** @hidden */ rebuild(): void;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. /** @hidden */
  38489. export var imageProcessingPixelShader: {
  38490. name: string;
  38491. shader: string;
  38492. };
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * ImageProcessingPostProcess
  38497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38498. */
  38499. export class ImageProcessingPostProcess extends PostProcess {
  38500. /**
  38501. * Default configuration related to image processing available in the PBR Material.
  38502. */
  38503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38504. /**
  38505. * Gets the image processing configuration used either in this material.
  38506. */
  38507. /**
  38508. * Sets the Default image processing configuration used either in the this material.
  38509. *
  38510. * If sets to null, the scene one is in use.
  38511. */
  38512. imageProcessingConfiguration: ImageProcessingConfiguration;
  38513. /**
  38514. * Keep track of the image processing observer to allow dispose and replace.
  38515. */
  38516. private _imageProcessingObserver;
  38517. /**
  38518. * Attaches a new image processing configuration to the PBR Material.
  38519. * @param configuration
  38520. */
  38521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38522. /**
  38523. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38524. */
  38525. /**
  38526. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38527. */
  38528. colorCurves: Nullable<ColorCurves>;
  38529. /**
  38530. * Gets wether the color curves effect is enabled.
  38531. */
  38532. /**
  38533. * Sets wether the color curves effect is enabled.
  38534. */
  38535. colorCurvesEnabled: boolean;
  38536. /**
  38537. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38538. */
  38539. /**
  38540. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38541. */
  38542. colorGradingTexture: Nullable<BaseTexture>;
  38543. /**
  38544. * Gets wether the color grading effect is enabled.
  38545. */
  38546. /**
  38547. * Gets wether the color grading effect is enabled.
  38548. */
  38549. colorGradingEnabled: boolean;
  38550. /**
  38551. * Gets exposure used in the effect.
  38552. */
  38553. /**
  38554. * Sets exposure used in the effect.
  38555. */
  38556. exposure: number;
  38557. /**
  38558. * Gets wether tonemapping is enabled or not.
  38559. */
  38560. /**
  38561. * Sets wether tonemapping is enabled or not
  38562. */
  38563. toneMappingEnabled: boolean;
  38564. /**
  38565. * Gets the type of tone mapping effect.
  38566. */
  38567. /**
  38568. * Sets the type of tone mapping effect.
  38569. */
  38570. toneMappingType: number;
  38571. /**
  38572. * Gets contrast used in the effect.
  38573. */
  38574. /**
  38575. * Sets contrast used in the effect.
  38576. */
  38577. contrast: number;
  38578. /**
  38579. * Gets Vignette stretch size.
  38580. */
  38581. /**
  38582. * Sets Vignette stretch size.
  38583. */
  38584. vignetteStretch: number;
  38585. /**
  38586. * Gets Vignette centre X Offset.
  38587. */
  38588. /**
  38589. * Sets Vignette centre X Offset.
  38590. */
  38591. vignetteCentreX: number;
  38592. /**
  38593. * Gets Vignette centre Y Offset.
  38594. */
  38595. /**
  38596. * Sets Vignette centre Y Offset.
  38597. */
  38598. vignetteCentreY: number;
  38599. /**
  38600. * Gets Vignette weight or intensity of the vignette effect.
  38601. */
  38602. /**
  38603. * Sets Vignette weight or intensity of the vignette effect.
  38604. */
  38605. vignetteWeight: number;
  38606. /**
  38607. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38608. * if vignetteEnabled is set to true.
  38609. */
  38610. /**
  38611. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38612. * if vignetteEnabled is set to true.
  38613. */
  38614. vignetteColor: Color4;
  38615. /**
  38616. * Gets Camera field of view used by the Vignette effect.
  38617. */
  38618. /**
  38619. * Sets Camera field of view used by the Vignette effect.
  38620. */
  38621. vignetteCameraFov: number;
  38622. /**
  38623. * Gets the vignette blend mode allowing different kind of effect.
  38624. */
  38625. /**
  38626. * Sets the vignette blend mode allowing different kind of effect.
  38627. */
  38628. vignetteBlendMode: number;
  38629. /**
  38630. * Gets wether the vignette effect is enabled.
  38631. */
  38632. /**
  38633. * Sets wether the vignette effect is enabled.
  38634. */
  38635. vignetteEnabled: boolean;
  38636. private _fromLinearSpace;
  38637. /**
  38638. * Gets wether the input of the processing is in Gamma or Linear Space.
  38639. */
  38640. /**
  38641. * Sets wether the input of the processing is in Gamma or Linear Space.
  38642. */
  38643. fromLinearSpace: boolean;
  38644. /**
  38645. * Defines cache preventing GC.
  38646. */
  38647. private _defines;
  38648. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38649. /**
  38650. * "ImageProcessingPostProcess"
  38651. * @returns "ImageProcessingPostProcess"
  38652. */
  38653. getClassName(): string;
  38654. protected _updateParameters(): void;
  38655. dispose(camera?: Camera): void;
  38656. }
  38657. }
  38658. declare module BABYLON {
  38659. /**
  38660. * Class containing static functions to help procedurally build meshes
  38661. */
  38662. export class GroundBuilder {
  38663. /**
  38664. * Creates a ground mesh
  38665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38668. * @param name defines the name of the mesh
  38669. * @param options defines the options used to create the mesh
  38670. * @param scene defines the hosting scene
  38671. * @returns the ground mesh
  38672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38673. */
  38674. static CreateGround(name: string, options: {
  38675. width?: number;
  38676. height?: number;
  38677. subdivisions?: number;
  38678. subdivisionsX?: number;
  38679. subdivisionsY?: number;
  38680. updatable?: boolean;
  38681. }, scene: any): Mesh;
  38682. /**
  38683. * Creates a tiled ground mesh
  38684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38686. * * 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
  38687. * * 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
  38688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38689. * @param name defines the name of the mesh
  38690. * @param options defines the options used to create the mesh
  38691. * @param scene defines the hosting scene
  38692. * @returns the tiled ground mesh
  38693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38694. */
  38695. static CreateTiledGround(name: string, options: {
  38696. xmin: number;
  38697. zmin: number;
  38698. xmax: number;
  38699. zmax: number;
  38700. subdivisions?: {
  38701. w: number;
  38702. h: number;
  38703. };
  38704. precision?: {
  38705. w: number;
  38706. h: number;
  38707. };
  38708. updatable?: boolean;
  38709. }, scene?: Nullable<Scene>): Mesh;
  38710. /**
  38711. * Creates a ground mesh from a height map
  38712. * * The parameter `url` sets the URL of the height map image resource.
  38713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38717. * * 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.
  38718. * * 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).
  38719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38721. * @param name defines the name of the mesh
  38722. * @param url defines the url to the height map
  38723. * @param options defines the options used to create the mesh
  38724. * @param scene defines the hosting scene
  38725. * @returns the ground mesh
  38726. * @see https://doc.babylonjs.com/babylon101/height_map
  38727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38728. */
  38729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38730. width?: number;
  38731. height?: number;
  38732. subdivisions?: number;
  38733. minHeight?: number;
  38734. maxHeight?: number;
  38735. colorFilter?: Color3;
  38736. alphaFilter?: number;
  38737. updatable?: boolean;
  38738. onReady?: (mesh: GroundMesh) => void;
  38739. }, scene?: Nullable<Scene>): GroundMesh;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /**
  38744. * Class containing static functions to help procedurally build meshes
  38745. */
  38746. export class TorusBuilder {
  38747. /**
  38748. * Creates a torus mesh
  38749. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38750. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38751. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38753. * * 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
  38754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38755. * @param name defines the name of the mesh
  38756. * @param options defines the options used to create the mesh
  38757. * @param scene defines the hosting scene
  38758. * @returns the torus mesh
  38759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38760. */
  38761. static CreateTorus(name: string, options: {
  38762. diameter?: number;
  38763. thickness?: number;
  38764. tessellation?: number;
  38765. updatable?: boolean;
  38766. sideOrientation?: number;
  38767. frontUVs?: Vector4;
  38768. backUVs?: Vector4;
  38769. }, scene: any): Mesh;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Class containing static functions to help procedurally build meshes
  38775. */
  38776. export class CylinderBuilder {
  38777. /**
  38778. * Creates a cylinder or a cone mesh
  38779. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38780. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38781. * * 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.
  38782. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38783. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38784. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38785. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38786. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38787. * * 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).
  38788. * * 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
  38789. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38790. * * 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
  38791. * * 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.
  38792. * * If `enclose` is false, a ring surface is one element.
  38793. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38794. * * 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
  38795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38796. * * 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
  38797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38798. * @param name defines the name of the mesh
  38799. * @param options defines the options used to create the mesh
  38800. * @param scene defines the hosting scene
  38801. * @returns the cylinder mesh
  38802. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38803. */
  38804. static CreateCylinder(name: string, options: {
  38805. height?: number;
  38806. diameterTop?: number;
  38807. diameterBottom?: number;
  38808. diameter?: number;
  38809. tessellation?: number;
  38810. subdivisions?: number;
  38811. arc?: number;
  38812. faceColors?: Color4[];
  38813. faceUV?: Vector4[];
  38814. updatable?: boolean;
  38815. hasRings?: boolean;
  38816. enclose?: boolean;
  38817. sideOrientation?: number;
  38818. frontUVs?: Vector4;
  38819. backUVs?: Vector4;
  38820. }, scene: any): Mesh;
  38821. }
  38822. }
  38823. declare module BABYLON {
  38824. /**
  38825. * Manager for handling gamepads
  38826. */
  38827. export class GamepadManager {
  38828. private _scene?;
  38829. private _babylonGamepads;
  38830. private _oneGamepadConnected;
  38831. /** @hidden */ isMonitoring: boolean;
  38832. private _gamepadEventSupported;
  38833. private _gamepadSupport;
  38834. /**
  38835. * observable to be triggered when the gamepad controller has been connected
  38836. */
  38837. onGamepadConnectedObservable: Observable<Gamepad>;
  38838. /**
  38839. * observable to be triggered when the gamepad controller has been disconnected
  38840. */
  38841. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38842. private _onGamepadConnectedEvent;
  38843. private _onGamepadDisconnectedEvent;
  38844. /**
  38845. * Initializes the gamepad manager
  38846. * @param _scene BabylonJS scene
  38847. */
  38848. constructor(_scene?: Scene | undefined);
  38849. /**
  38850. * The gamepads in the game pad manager
  38851. */
  38852. readonly gamepads: Gamepad[];
  38853. /**
  38854. * Get the gamepad controllers based on type
  38855. * @param type The type of gamepad controller
  38856. * @returns Nullable gamepad
  38857. */
  38858. getGamepadByType(type?: number): Nullable<Gamepad>;
  38859. /**
  38860. * Disposes the gamepad manager
  38861. */
  38862. dispose(): void;
  38863. private _addNewGamepad;
  38864. private _startMonitoringGamepads;
  38865. private _stopMonitoringGamepads;
  38866. /** @hidden */ checkGamepadsStatus(): void;
  38867. private _updateGamepadObjects;
  38868. }
  38869. }
  38870. declare module BABYLON {
  38871. interface Scene {
  38872. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38873. /**
  38874. * Gets the gamepad manager associated with the scene
  38875. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38876. */
  38877. gamepadManager: GamepadManager;
  38878. }
  38879. /**
  38880. * Interface representing a free camera inputs manager
  38881. */
  38882. interface FreeCameraInputsManager {
  38883. /**
  38884. * Adds gamepad input support to the FreeCameraInputsManager.
  38885. * @returns the FreeCameraInputsManager
  38886. */
  38887. addGamepad(): FreeCameraInputsManager;
  38888. }
  38889. /**
  38890. * Interface representing an arc rotate camera inputs manager
  38891. */
  38892. interface ArcRotateCameraInputsManager {
  38893. /**
  38894. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38895. * @returns the camera inputs manager
  38896. */
  38897. addGamepad(): ArcRotateCameraInputsManager;
  38898. }
  38899. /**
  38900. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38901. */
  38902. export class GamepadSystemSceneComponent implements ISceneComponent {
  38903. /**
  38904. * The component name helpfull to identify the component in the list of scene components.
  38905. */
  38906. readonly name: string;
  38907. /**
  38908. * The scene the component belongs to.
  38909. */
  38910. scene: Scene;
  38911. /**
  38912. * Creates a new instance of the component for the given scene
  38913. * @param scene Defines the scene to register the component in
  38914. */
  38915. constructor(scene: Scene);
  38916. /**
  38917. * Registers the component in a given scene
  38918. */
  38919. register(): void;
  38920. /**
  38921. * Rebuilds the elements related to this component in case of
  38922. * context lost for instance.
  38923. */
  38924. rebuild(): void;
  38925. /**
  38926. * Disposes the component and the associated ressources
  38927. */
  38928. dispose(): void;
  38929. private _beforeCameraUpdate;
  38930. }
  38931. }
  38932. declare module BABYLON {
  38933. /**
  38934. * Options to modify the vr teleportation behavior.
  38935. */
  38936. export interface VRTeleportationOptions {
  38937. /**
  38938. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38939. */
  38940. floorMeshName?: string;
  38941. /**
  38942. * A list of meshes to be used as the teleportation floor. (default: empty)
  38943. */
  38944. floorMeshes?: Mesh[];
  38945. }
  38946. /**
  38947. * Options to modify the vr experience helper's behavior.
  38948. */
  38949. export interface VRExperienceHelperOptions extends WebVROptions {
  38950. /**
  38951. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38952. */
  38953. createDeviceOrientationCamera?: boolean;
  38954. /**
  38955. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38956. */
  38957. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38958. /**
  38959. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38960. */
  38961. laserToggle?: boolean;
  38962. /**
  38963. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38964. */
  38965. floorMeshes?: Mesh[];
  38966. /**
  38967. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38968. */
  38969. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38970. }
  38971. /**
  38972. * Event containing information after VR has been entered
  38973. */
  38974. export class OnAfterEnteringVRObservableEvent {
  38975. /**
  38976. * If entering vr was successful
  38977. */
  38978. success: boolean;
  38979. }
  38980. /**
  38981. * Helps to quickly add VR support to an existing scene.
  38982. * See http://doc.babylonjs.com/how_to/webvr_helper
  38983. */
  38984. export class VRExperienceHelper {
  38985. /** Options to modify the vr experience helper's behavior. */
  38986. webVROptions: VRExperienceHelperOptions;
  38987. private _scene;
  38988. private _position;
  38989. private _btnVR;
  38990. private _btnVRDisplayed;
  38991. private _webVRsupported;
  38992. private _webVRready;
  38993. private _webVRrequesting;
  38994. private _webVRpresenting;
  38995. private _hasEnteredVR;
  38996. private _fullscreenVRpresenting;
  38997. private _canvas;
  38998. private _webVRCamera;
  38999. private _vrDeviceOrientationCamera;
  39000. private _deviceOrientationCamera;
  39001. private _existingCamera;
  39002. private _onKeyDown;
  39003. private _onVrDisplayPresentChange;
  39004. private _onVRDisplayChanged;
  39005. private _onVRRequestPresentStart;
  39006. private _onVRRequestPresentComplete;
  39007. /**
  39008. * Observable raised right before entering VR.
  39009. */
  39010. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39011. /**
  39012. * Observable raised when entering VR has completed.
  39013. */
  39014. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39015. /**
  39016. * Observable raised when exiting VR.
  39017. */
  39018. onExitingVRObservable: Observable<VRExperienceHelper>;
  39019. /**
  39020. * Observable raised when controller mesh is loaded.
  39021. */
  39022. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39023. /** Return this.onEnteringVRObservable
  39024. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39025. */
  39026. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39027. /** Return this.onExitingVRObservable
  39028. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39029. */
  39030. readonly onExitingVR: Observable<VRExperienceHelper>;
  39031. /** Return this.onControllerMeshLoadedObservable
  39032. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39033. */
  39034. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39035. private _rayLength;
  39036. private _useCustomVRButton;
  39037. private _teleportationRequested;
  39038. private _teleportActive;
  39039. private _floorMeshName;
  39040. private _floorMeshesCollection;
  39041. private _rotationAllowed;
  39042. private _teleportBackwardsVector;
  39043. private _teleportationTarget;
  39044. private _isDefaultTeleportationTarget;
  39045. private _postProcessMove;
  39046. private _teleportationFillColor;
  39047. private _teleportationBorderColor;
  39048. private _rotationAngle;
  39049. private _haloCenter;
  39050. private _cameraGazer;
  39051. private _padSensibilityUp;
  39052. private _padSensibilityDown;
  39053. private _leftController;
  39054. private _rightController;
  39055. /**
  39056. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39057. */
  39058. onNewMeshSelected: Observable<AbstractMesh>;
  39059. /**
  39060. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39061. */
  39062. onNewMeshPicked: Observable<PickingInfo>;
  39063. private _circleEase;
  39064. /**
  39065. * Observable raised before camera teleportation
  39066. */
  39067. onBeforeCameraTeleport: Observable<Vector3>;
  39068. /**
  39069. * Observable raised after camera teleportation
  39070. */
  39071. onAfterCameraTeleport: Observable<Vector3>;
  39072. /**
  39073. * Observable raised when current selected mesh gets unselected
  39074. */
  39075. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39076. private _raySelectionPredicate;
  39077. /**
  39078. * To be optionaly changed by user to define custom ray selection
  39079. */
  39080. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39081. /**
  39082. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39083. */
  39084. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39085. /**
  39086. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39087. */
  39088. teleportationEnabled: boolean;
  39089. private _defaultHeight;
  39090. private _teleportationInitialized;
  39091. private _interactionsEnabled;
  39092. private _interactionsRequested;
  39093. private _displayGaze;
  39094. private _displayLaserPointer;
  39095. /**
  39096. * The mesh used to display where the user is going to teleport.
  39097. */
  39098. /**
  39099. * Sets the mesh to be used to display where the user is going to teleport.
  39100. */
  39101. teleportationTarget: Mesh;
  39102. /**
  39103. * 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
  39104. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39105. * See http://doc.babylonjs.com/resources/baking_transformations
  39106. */
  39107. gazeTrackerMesh: Mesh;
  39108. /**
  39109. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39110. */
  39111. updateGazeTrackerScale: boolean;
  39112. /**
  39113. * If the gaze trackers color should be updated when selecting meshes
  39114. */
  39115. updateGazeTrackerColor: boolean;
  39116. /**
  39117. * The gaze tracking mesh corresponding to the left controller
  39118. */
  39119. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39120. /**
  39121. * The gaze tracking mesh corresponding to the right controller
  39122. */
  39123. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39124. /**
  39125. * If the ray of the gaze should be displayed.
  39126. */
  39127. /**
  39128. * Sets if the ray of the gaze should be displayed.
  39129. */
  39130. displayGaze: boolean;
  39131. /**
  39132. * If the ray of the LaserPointer should be displayed.
  39133. */
  39134. /**
  39135. * Sets if the ray of the LaserPointer should be displayed.
  39136. */
  39137. displayLaserPointer: boolean;
  39138. /**
  39139. * The deviceOrientationCamera used as the camera when not in VR.
  39140. */
  39141. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39142. /**
  39143. * Based on the current WebVR support, returns the current VR camera used.
  39144. */
  39145. readonly currentVRCamera: Nullable<Camera>;
  39146. /**
  39147. * The webVRCamera which is used when in VR.
  39148. */
  39149. readonly webVRCamera: WebVRFreeCamera;
  39150. /**
  39151. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39152. */
  39153. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39154. private readonly _teleportationRequestInitiated;
  39155. /**
  39156. * Defines wether or not Pointer lock should be requested when switching to
  39157. * full screen.
  39158. */
  39159. requestPointerLockOnFullScreen: boolean;
  39160. /**
  39161. * Instantiates a VRExperienceHelper.
  39162. * Helps to quickly add VR support to an existing scene.
  39163. * @param scene The scene the VRExperienceHelper belongs to.
  39164. * @param webVROptions Options to modify the vr experience helper's behavior.
  39165. */
  39166. constructor(scene: Scene,
  39167. /** Options to modify the vr experience helper's behavior. */
  39168. webVROptions?: VRExperienceHelperOptions);
  39169. private _onDefaultMeshLoaded;
  39170. private _onResize;
  39171. private _onFullscreenChange;
  39172. /**
  39173. * Gets a value indicating if we are currently in VR mode.
  39174. */
  39175. readonly isInVRMode: boolean;
  39176. private onVrDisplayPresentChange;
  39177. private onVRDisplayChanged;
  39178. private moveButtonToBottomRight;
  39179. private displayVRButton;
  39180. private updateButtonVisibility;
  39181. private _cachedAngularSensibility;
  39182. /**
  39183. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39184. * Otherwise, will use the fullscreen API.
  39185. */
  39186. enterVR(): void;
  39187. /**
  39188. * Attempt to exit VR, or fullscreen.
  39189. */
  39190. exitVR(): void;
  39191. /**
  39192. * The position of the vr experience helper.
  39193. */
  39194. /**
  39195. * Sets the position of the vr experience helper.
  39196. */
  39197. position: Vector3;
  39198. /**
  39199. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39200. */
  39201. enableInteractions(): void;
  39202. private readonly _noControllerIsActive;
  39203. private beforeRender;
  39204. private _isTeleportationFloor;
  39205. /**
  39206. * Adds a floor mesh to be used for teleportation.
  39207. * @param floorMesh the mesh to be used for teleportation.
  39208. */
  39209. addFloorMesh(floorMesh: Mesh): void;
  39210. /**
  39211. * Removes a floor mesh from being used for teleportation.
  39212. * @param floorMesh the mesh to be removed.
  39213. */
  39214. removeFloorMesh(floorMesh: Mesh): void;
  39215. /**
  39216. * Enables interactions and teleportation using the VR controllers and gaze.
  39217. * @param vrTeleportationOptions options to modify teleportation behavior.
  39218. */
  39219. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39220. private _onNewGamepadConnected;
  39221. private _tryEnableInteractionOnController;
  39222. private _onNewGamepadDisconnected;
  39223. private _enableInteractionOnController;
  39224. private _checkTeleportWithRay;
  39225. private _checkRotate;
  39226. private _checkTeleportBackwards;
  39227. private _enableTeleportationOnController;
  39228. private _createTeleportationCircles;
  39229. private _displayTeleportationTarget;
  39230. private _hideTeleportationTarget;
  39231. private _rotateCamera;
  39232. private _moveTeleportationSelectorTo;
  39233. private _workingVector;
  39234. private _workingQuaternion;
  39235. private _workingMatrix;
  39236. /**
  39237. * Teleports the users feet to the desired location
  39238. * @param location The location where the user's feet should be placed
  39239. */
  39240. teleportCamera(location: Vector3): void;
  39241. private _convertNormalToDirectionOfRay;
  39242. private _castRayAndSelectObject;
  39243. private _notifySelectedMeshUnselected;
  39244. /**
  39245. * Sets the color of the laser ray from the vr controllers.
  39246. * @param color new color for the ray.
  39247. */
  39248. changeLaserColor(color: Color3): void;
  39249. /**
  39250. * Sets the color of the ray from the vr headsets gaze.
  39251. * @param color new color for the ray.
  39252. */
  39253. changeGazeColor(color: Color3): void;
  39254. /**
  39255. * Exits VR and disposes of the vr experience helper
  39256. */
  39257. dispose(): void;
  39258. /**
  39259. * Gets the name of the VRExperienceHelper class
  39260. * @returns "VRExperienceHelper"
  39261. */
  39262. getClassName(): string;
  39263. }
  39264. }
  39265. declare module BABYLON {
  39266. /**
  39267. * Manages an XRSession
  39268. * @see https://doc.babylonjs.com/how_to/webxr
  39269. */
  39270. export class WebXRSessionManager implements IDisposable {
  39271. private scene;
  39272. /**
  39273. * Fires every time a new xrFrame arrives which can be used to update the camera
  39274. */
  39275. onXRFrameObservable: Observable<any>;
  39276. /**
  39277. * Fires when the xr session is ended either by the device or manually done
  39278. */
  39279. onXRSessionEnded: Observable<any>;
  39280. /** @hidden */ xrSession: XRSession;
  39281. /** @hidden */ frameOfReference: XRFrameOfReference;
  39282. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39283. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39284. private _xrNavigator;
  39285. private _xrDevice;
  39286. private _tmpMatrix;
  39287. /**
  39288. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39289. * @param scene The scene which the session should be created for
  39290. */
  39291. constructor(scene: Scene);
  39292. /**
  39293. * Initializes the manager
  39294. * After initialization enterXR can be called to start an XR session
  39295. * @returns Promise which resolves after it is initialized
  39296. */
  39297. initializeAsync(): Promise<void>;
  39298. /**
  39299. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39300. * @param sessionCreationOptions xr options to create the session with
  39301. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39302. * @returns Promise which resolves after it enters XR
  39303. */
  39304. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39305. /**
  39306. * Stops the xrSession and restores the renderloop
  39307. * @returns Promise which resolves after it exits XR
  39308. */
  39309. exitXRAsync(): Promise<void>;
  39310. /**
  39311. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39312. * @param ray ray to cast into the environment
  39313. * @returns Promise which resolves with a collision point in the environment if it exists
  39314. */
  39315. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39316. /**
  39317. * Checks if a session would be supported for the creation options specified
  39318. * @param options creation options to check if they are supported
  39319. * @returns true if supported
  39320. */
  39321. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39322. /**
  39323. * @hidden
  39324. * Converts the render layer of xrSession to a render target
  39325. * @param session session to create render target for
  39326. * @param scene scene the new render target should be created for
  39327. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39328. /**
  39329. * Disposes of the session manager
  39330. */
  39331. dispose(): void;
  39332. }
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * WebXR Camera which holds the views for the xrSession
  39337. * @see https://doc.babylonjs.com/how_to/webxr
  39338. */
  39339. export class WebXRCamera extends FreeCamera {
  39340. private static _TmpMatrix;
  39341. /**
  39342. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39343. * @param name the name of the camera
  39344. * @param scene the scene to add the camera to
  39345. */
  39346. constructor(name: string, scene: Scene);
  39347. private _updateNumberOfRigCameras;
  39348. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39349. /**
  39350. * Updates the cameras position from the current pose information of the XR session
  39351. * @param xrSessionManager the session containing pose information
  39352. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39353. */
  39354. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39355. }
  39356. }
  39357. declare module BABYLON {
  39358. /**
  39359. * States of the webXR experience
  39360. */
  39361. export enum WebXRState {
  39362. /**
  39363. * Transitioning to being in XR mode
  39364. */
  39365. ENTERING_XR = 0,
  39366. /**
  39367. * Transitioning to non XR mode
  39368. */
  39369. EXITING_XR = 1,
  39370. /**
  39371. * In XR mode and presenting
  39372. */
  39373. IN_XR = 2,
  39374. /**
  39375. * Not entered XR mode
  39376. */
  39377. NOT_IN_XR = 3
  39378. }
  39379. /**
  39380. * Helper class used to enable XR
  39381. * @see https://doc.babylonjs.com/how_to/webxr
  39382. */
  39383. export class WebXRExperienceHelper implements IDisposable {
  39384. private scene;
  39385. /**
  39386. * 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
  39387. */
  39388. container: AbstractMesh;
  39389. /**
  39390. * Camera used to render xr content
  39391. */
  39392. camera: WebXRCamera;
  39393. /**
  39394. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39395. */
  39396. state: WebXRState;
  39397. private _setState;
  39398. private static _TmpVector;
  39399. /**
  39400. * Fires when the state of the experience helper has changed
  39401. */
  39402. onStateChangedObservable: Observable<WebXRState>;
  39403. /** @hidden */ sessionManager: WebXRSessionManager;
  39404. private _nonVRCamera;
  39405. private _originalSceneAutoClear;
  39406. private _supported;
  39407. /**
  39408. * Creates the experience helper
  39409. * @param scene the scene to attach the experience helper to
  39410. * @returns a promise for the experience helper
  39411. */
  39412. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39413. /**
  39414. * Creates a WebXRExperienceHelper
  39415. * @param scene The scene the helper should be created in
  39416. */
  39417. private constructor();
  39418. /**
  39419. * Exits XR mode and returns the scene to its original state
  39420. * @returns promise that resolves after xr mode has exited
  39421. */
  39422. exitXRAsync(): Promise<void>;
  39423. /**
  39424. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39425. * @param sessionCreationOptions options for the XR session
  39426. * @param frameOfReference frame of reference of the XR session
  39427. * @returns promise that resolves after xr mode has entered
  39428. */
  39429. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39430. /**
  39431. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39432. * @param ray ray to cast into the environment
  39433. * @returns Promise which resolves with a collision point in the environment if it exists
  39434. */
  39435. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39436. /**
  39437. * Updates the global position of the camera by moving the camera's container
  39438. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39439. * @param position The desired global position of the camera
  39440. */
  39441. setPositionOfCameraUsingContainer(position: Vector3): void;
  39442. /**
  39443. * Rotates the xr camera by rotating the camera's container around the camera's position
  39444. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39445. * @param rotation the desired quaternion rotation to apply to the camera
  39446. */
  39447. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39448. /**
  39449. * Checks if the creation options are supported by the xr session
  39450. * @param options creation options
  39451. * @returns true if supported
  39452. */
  39453. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39454. /**
  39455. * Disposes of the experience helper
  39456. */
  39457. dispose(): void;
  39458. }
  39459. }
  39460. declare module BABYLON {
  39461. /**
  39462. * Button which can be used to enter a different mode of XR
  39463. */
  39464. export class WebXREnterExitUIButton {
  39465. /** button element */
  39466. element: HTMLElement;
  39467. /** XR initialization options for the button */
  39468. initializationOptions: XRSessionCreationOptions;
  39469. /**
  39470. * Creates a WebXREnterExitUIButton
  39471. * @param element button element
  39472. * @param initializationOptions XR initialization options for the button
  39473. */
  39474. constructor(
  39475. /** button element */
  39476. element: HTMLElement,
  39477. /** XR initialization options for the button */
  39478. initializationOptions: XRSessionCreationOptions);
  39479. /**
  39480. * Overwritable function which can be used to update the button's visuals when the state changes
  39481. * @param activeButton the current active button in the UI
  39482. */
  39483. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39484. }
  39485. /**
  39486. * Options to create the webXR UI
  39487. */
  39488. export class WebXREnterExitUIOptions {
  39489. /**
  39490. * Context to enter xr with
  39491. */
  39492. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39493. /**
  39494. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39495. */
  39496. customButtons?: Array<WebXREnterExitUIButton>;
  39497. }
  39498. /**
  39499. * UI to allow the user to enter/exit XR mode
  39500. */
  39501. export class WebXREnterExitUI implements IDisposable {
  39502. private scene;
  39503. private _overlay;
  39504. private _buttons;
  39505. private _activeButton;
  39506. /**
  39507. * Fired every time the active button is changed.
  39508. *
  39509. * When xr is entered via a button that launches xr that button will be the callback parameter
  39510. *
  39511. * When exiting xr the callback parameter will be null)
  39512. */
  39513. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39514. /**
  39515. * Creates UI to allow the user to enter/exit XR mode
  39516. * @param scene the scene to add the ui to
  39517. * @param helper the xr experience helper to enter/exit xr with
  39518. * @param options options to configure the UI
  39519. * @returns the created ui
  39520. */
  39521. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39522. private constructor();
  39523. private _updateButtons;
  39524. /**
  39525. * Disposes of the object
  39526. */
  39527. dispose(): void;
  39528. }
  39529. }
  39530. declare module BABYLON {
  39531. /**
  39532. * Represents an XR input
  39533. */
  39534. export class WebXRController {
  39535. /**
  39536. * 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
  39537. */
  39538. grip?: AbstractMesh;
  39539. /**
  39540. * Pointer which can be used to select objects or attach a visible laser to
  39541. */
  39542. pointer: AbstractMesh;
  39543. /**
  39544. * Creates the controller
  39545. * @see https://doc.babylonjs.com/how_to/webxr
  39546. * @param scene the scene which the controller should be associated to
  39547. */
  39548. constructor(scene: Scene);
  39549. /**
  39550. * Disposes of the object
  39551. */
  39552. dispose(): void;
  39553. }
  39554. /**
  39555. * XR input used to track XR inputs such as controllers/rays
  39556. */
  39557. export class WebXRInput implements IDisposable {
  39558. private helper;
  39559. /**
  39560. * XR controllers being tracked
  39561. */
  39562. controllers: Array<WebXRController>;
  39563. private _tmpMatrix;
  39564. private _frameObserver;
  39565. /**
  39566. * Initializes the WebXRInput
  39567. * @param helper experience helper which the input should be created for
  39568. */
  39569. constructor(helper: WebXRExperienceHelper);
  39570. /**
  39571. * Disposes of the object
  39572. */
  39573. dispose(): void;
  39574. }
  39575. }
  39576. declare module BABYLON {
  39577. /**
  39578. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39579. */
  39580. export class WebXRManagedOutputCanvas implements IDisposable {
  39581. private _canvas;
  39582. /**
  39583. * xrpresent context of the canvas which can be used to display/mirror xr content
  39584. */
  39585. canvasContext: Nullable<WebGLRenderingContext>;
  39586. /**
  39587. * Initializes the canvas to be added/removed upon entering/exiting xr
  39588. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39589. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39590. */
  39591. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39592. /**
  39593. * Disposes of the object
  39594. */
  39595. dispose(): void;
  39596. private _setManagedOutputCanvas;
  39597. private _addCanvas;
  39598. private _removeCanvas;
  39599. }
  39600. }
  39601. declare module BABYLON {
  39602. /**
  39603. * Contains an array of blocks representing the octree
  39604. */
  39605. export interface IOctreeContainer<T> {
  39606. /**
  39607. * Blocks within the octree
  39608. */
  39609. blocks: Array<OctreeBlock<T>>;
  39610. }
  39611. /**
  39612. * Class used to store a cell in an octree
  39613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39614. */
  39615. export class OctreeBlock<T> {
  39616. /**
  39617. * Gets the content of the current block
  39618. */
  39619. entries: T[];
  39620. /**
  39621. * Gets the list of block children
  39622. */
  39623. blocks: Array<OctreeBlock<T>>;
  39624. private _depth;
  39625. private _maxDepth;
  39626. private _capacity;
  39627. private _minPoint;
  39628. private _maxPoint;
  39629. private _boundingVectors;
  39630. private _creationFunc;
  39631. /**
  39632. * Creates a new block
  39633. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39634. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39635. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39636. * @param depth defines the current depth of this block in the octree
  39637. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39638. * @param creationFunc defines a callback to call when an element is added to the block
  39639. */
  39640. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39641. /**
  39642. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39643. */
  39644. readonly capacity: number;
  39645. /**
  39646. * Gets the minimum vector (in world space) of the block's bounding box
  39647. */
  39648. readonly minPoint: Vector3;
  39649. /**
  39650. * Gets the maximum vector (in world space) of the block's bounding box
  39651. */
  39652. readonly maxPoint: Vector3;
  39653. /**
  39654. * Add a new element to this block
  39655. * @param entry defines the element to add
  39656. */
  39657. addEntry(entry: T): void;
  39658. /**
  39659. * Remove an element from this block
  39660. * @param entry defines the element to remove
  39661. */
  39662. removeEntry(entry: T): void;
  39663. /**
  39664. * Add an array of elements to this block
  39665. * @param entries defines the array of elements to add
  39666. */
  39667. addEntries(entries: T[]): void;
  39668. /**
  39669. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39670. * @param frustumPlanes defines the frustum planes to test
  39671. * @param selection defines the array to store current content if selection is positive
  39672. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39673. */
  39674. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39675. /**
  39676. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39677. * @param sphereCenter defines the bounding sphere center
  39678. * @param sphereRadius defines the bounding sphere radius
  39679. * @param selection defines the array to store current content if selection is positive
  39680. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39681. */
  39682. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39683. /**
  39684. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39685. * @param ray defines the ray to test with
  39686. * @param selection defines the array to store current content if selection is positive
  39687. */
  39688. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39689. /**
  39690. * Subdivide the content into child blocks (this block will then be empty)
  39691. */
  39692. createInnerBlocks(): void;
  39693. /**
  39694. * @hidden
  39695. */ 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;
  39696. }
  39697. }
  39698. declare module BABYLON {
  39699. /**
  39700. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39702. */
  39703. export class Octree<T> {
  39704. /** 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.) */
  39705. maxDepth: number;
  39706. /**
  39707. * Blocks within the octree containing objects
  39708. */
  39709. blocks: Array<OctreeBlock<T>>;
  39710. /**
  39711. * Content stored in the octree
  39712. */
  39713. dynamicContent: T[];
  39714. private _maxBlockCapacity;
  39715. private _selectionContent;
  39716. private _creationFunc;
  39717. /**
  39718. * Creates a octree
  39719. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39720. * @param creationFunc function to be used to instatiate the octree
  39721. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39722. * @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.)
  39723. */
  39724. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39725. /** 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.) */
  39726. maxDepth?: number);
  39727. /**
  39728. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39729. * @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);
  39730. * @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);
  39731. * @param entries meshes to be added to the octree blocks
  39732. */
  39733. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39734. /**
  39735. * Adds a mesh to the octree
  39736. * @param entry Mesh to add to the octree
  39737. */
  39738. addMesh(entry: T): void;
  39739. /**
  39740. * Remove an element from the octree
  39741. * @param entry defines the element to remove
  39742. */
  39743. removeMesh(entry: T): void;
  39744. /**
  39745. * Selects an array of meshes within the frustum
  39746. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39747. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39748. * @returns array of meshes within the frustum
  39749. */
  39750. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39751. /**
  39752. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39753. * @param sphereCenter defines the bounding sphere center
  39754. * @param sphereRadius defines the bounding sphere radius
  39755. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39756. * @returns an array of objects that intersect the sphere
  39757. */
  39758. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39759. /**
  39760. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39761. * @param ray defines the ray to test with
  39762. * @returns array of intersected objects
  39763. */
  39764. intersectsRay(ray: Ray): SmartArray<T>;
  39765. /**
  39766. * Adds a mesh into the octree block if it intersects the block
  39767. */
  39768. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39769. /**
  39770. * Adds a submesh into the octree block if it intersects the block
  39771. */
  39772. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39773. }
  39774. }
  39775. declare module BABYLON {
  39776. interface Scene {
  39777. /**
  39778. * @hidden
  39779. * Backing Filed
  39780. */ selectionOctree: Octree<AbstractMesh>;
  39781. /**
  39782. * Gets the octree used to boost mesh selection (picking)
  39783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39784. */
  39785. selectionOctree: Octree<AbstractMesh>;
  39786. /**
  39787. * Creates or updates the octree used to boost selection (picking)
  39788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39789. * @param maxCapacity defines the maximum capacity per leaf
  39790. * @param maxDepth defines the maximum depth of the octree
  39791. * @returns an octree of AbstractMesh
  39792. */
  39793. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39794. }
  39795. interface AbstractMesh {
  39796. /**
  39797. * @hidden
  39798. * Backing Field
  39799. */ submeshesOctree: Octree<SubMesh>;
  39800. /**
  39801. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39802. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39803. * @param maxCapacity defines the maximum size of each block (64 by default)
  39804. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39805. * @returns the new octree
  39806. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39808. */
  39809. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39810. }
  39811. /**
  39812. * Defines the octree scene component responsible to manage any octrees
  39813. * in a given scene.
  39814. */
  39815. export class OctreeSceneComponent {
  39816. /**
  39817. * The component name help to identify the component in the list of scene components.
  39818. */
  39819. readonly name: string;
  39820. /**
  39821. * The scene the component belongs to.
  39822. */
  39823. scene: Scene;
  39824. /**
  39825. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39826. */
  39827. readonly checksIsEnabled: boolean;
  39828. /**
  39829. * Creates a new instance of the component for the given scene
  39830. * @param scene Defines the scene to register the component in
  39831. */
  39832. constructor(scene: Scene);
  39833. /**
  39834. * Registers the component in a given scene
  39835. */
  39836. register(): void;
  39837. /**
  39838. * Return the list of active meshes
  39839. * @returns the list of active meshes
  39840. */
  39841. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39842. /**
  39843. * Return the list of active sub meshes
  39844. * @param mesh The mesh to get the candidates sub meshes from
  39845. * @returns the list of active sub meshes
  39846. */
  39847. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39848. private _tempRay;
  39849. /**
  39850. * Return the list of sub meshes intersecting with a given local ray
  39851. * @param mesh defines the mesh to find the submesh for
  39852. * @param localRay defines the ray in local space
  39853. * @returns the list of intersecting sub meshes
  39854. */
  39855. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39856. /**
  39857. * Return the list of sub meshes colliding with a collider
  39858. * @param mesh defines the mesh to find the submesh for
  39859. * @param collider defines the collider to evaluate the collision against
  39860. * @returns the list of colliding sub meshes
  39861. */
  39862. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39863. /**
  39864. * Rebuilds the elements related to this component in case of
  39865. * context lost for instance.
  39866. */
  39867. rebuild(): void;
  39868. /**
  39869. * Disposes the component and the associated ressources.
  39870. */
  39871. dispose(): void;
  39872. }
  39873. }
  39874. declare module BABYLON {
  39875. /**
  39876. * Renders a layer on top of an existing scene
  39877. */
  39878. export class UtilityLayerRenderer implements IDisposable {
  39879. /** the original scene that will be rendered on top of */
  39880. originalScene: Scene;
  39881. private _pointerCaptures;
  39882. private _lastPointerEvents;
  39883. private static _DefaultUtilityLayer;
  39884. private static _DefaultKeepDepthUtilityLayer;
  39885. private _sharedGizmoLight;
  39886. /**
  39887. * @hidden
  39888. * Light which used by gizmos to get light shading
  39889. */ getSharedGizmoLight(): HemisphericLight;
  39890. /**
  39891. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39892. */
  39893. pickUtilitySceneFirst: boolean;
  39894. /**
  39895. * 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)
  39896. */
  39897. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39898. /**
  39899. * 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)
  39900. */
  39901. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39902. /**
  39903. * The scene that is rendered on top of the original scene
  39904. */
  39905. utilityLayerScene: Scene;
  39906. /**
  39907. * If the utility layer should automatically be rendered on top of existing scene
  39908. */
  39909. shouldRender: boolean;
  39910. /**
  39911. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39912. */
  39913. onlyCheckPointerDownEvents: boolean;
  39914. /**
  39915. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39916. */
  39917. processAllEvents: boolean;
  39918. /**
  39919. * Observable raised when the pointer move from the utility layer scene to the main scene
  39920. */
  39921. onPointerOutObservable: Observable<number>;
  39922. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39923. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39924. private _afterRenderObserver;
  39925. private _sceneDisposeObserver;
  39926. private _originalPointerObserver;
  39927. /**
  39928. * Instantiates a UtilityLayerRenderer
  39929. * @param originalScene the original scene that will be rendered on top of
  39930. * @param handleEvents boolean indicating if the utility layer should handle events
  39931. */
  39932. constructor(
  39933. /** the original scene that will be rendered on top of */
  39934. originalScene: Scene, handleEvents?: boolean);
  39935. private _notifyObservers;
  39936. /**
  39937. * Renders the utility layers scene on top of the original scene
  39938. */
  39939. render(): void;
  39940. /**
  39941. * Disposes of the renderer
  39942. */
  39943. dispose(): void;
  39944. private _updateCamera;
  39945. }
  39946. }
  39947. declare module BABYLON {
  39948. /**
  39949. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39950. */
  39951. export class Gizmo implements IDisposable {
  39952. /** The utility layer the gizmo will be added to */
  39953. gizmoLayer: UtilityLayerRenderer;
  39954. /**
  39955. * The root mesh of the gizmo
  39956. */ rootMesh: Mesh;
  39957. private _attachedMesh;
  39958. /**
  39959. * Ratio for the scale of the gizmo (Default: 1)
  39960. */
  39961. scaleRatio: number;
  39962. /**
  39963. * If a custom mesh has been set (Default: false)
  39964. */
  39965. protected _customMeshSet: boolean;
  39966. /**
  39967. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39968. * * When set, interactions will be enabled
  39969. */
  39970. attachedMesh: Nullable<AbstractMesh>;
  39971. /**
  39972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39973. * @param mesh The mesh to replace the default mesh of the gizmo
  39974. */
  39975. setCustomMesh(mesh: Mesh): void;
  39976. /**
  39977. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39978. */
  39979. updateGizmoRotationToMatchAttachedMesh: boolean;
  39980. /**
  39981. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39982. */
  39983. updateGizmoPositionToMatchAttachedMesh: boolean;
  39984. /**
  39985. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39986. */
  39987. protected _updateScale: boolean;
  39988. protected _interactionsEnabled: boolean;
  39989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39990. private _beforeRenderObserver;
  39991. private _tempVector;
  39992. /**
  39993. * Creates a gizmo
  39994. * @param gizmoLayer The utility layer the gizmo will be added to
  39995. */
  39996. constructor(
  39997. /** The utility layer the gizmo will be added to */
  39998. gizmoLayer?: UtilityLayerRenderer);
  39999. /**
  40000. * Updates the gizmo to match the attached mesh's position/rotation
  40001. */
  40002. protected _update(): void;
  40003. /**
  40004. * Disposes of the gizmo
  40005. */
  40006. dispose(): void;
  40007. }
  40008. }
  40009. declare module BABYLON {
  40010. /**
  40011. * Single axis drag gizmo
  40012. */
  40013. export class AxisDragGizmo extends Gizmo {
  40014. /**
  40015. * Drag behavior responsible for the gizmos dragging interactions
  40016. */
  40017. dragBehavior: PointerDragBehavior;
  40018. private _pointerObserver;
  40019. /**
  40020. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40021. */
  40022. snapDistance: number;
  40023. /**
  40024. * Event that fires each time the gizmo snaps to a new location.
  40025. * * snapDistance is the the change in distance
  40026. */
  40027. onSnapObservable: Observable<{
  40028. snapDistance: number;
  40029. }>;
  40030. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40031. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40032. /**
  40033. * Creates an AxisDragGizmo
  40034. * @param gizmoLayer The utility layer the gizmo will be added to
  40035. * @param dragAxis The axis which the gizmo will be able to drag on
  40036. * @param color The color of the gizmo
  40037. */
  40038. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40039. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40040. /**
  40041. * Disposes of the gizmo
  40042. */
  40043. dispose(): void;
  40044. }
  40045. }
  40046. declare module BABYLON.Debug {
  40047. /**
  40048. * The Axes viewer will show 3 axes in a specific point in space
  40049. */
  40050. export class AxesViewer {
  40051. private _xAxis;
  40052. private _yAxis;
  40053. private _zAxis;
  40054. private _scaleLinesFactor;
  40055. private _instanced;
  40056. /**
  40057. * Gets the hosting scene
  40058. */
  40059. scene: Scene;
  40060. /**
  40061. * Gets or sets a number used to scale line length
  40062. */
  40063. scaleLines: number;
  40064. /** Gets the node hierarchy used to render x-axis */
  40065. readonly xAxis: TransformNode;
  40066. /** Gets the node hierarchy used to render y-axis */
  40067. readonly yAxis: TransformNode;
  40068. /** Gets the node hierarchy used to render z-axis */
  40069. readonly zAxis: TransformNode;
  40070. /**
  40071. * Creates a new AxesViewer
  40072. * @param scene defines the hosting scene
  40073. * @param scaleLines defines a number used to scale line length (1 by default)
  40074. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40075. * @param xAxis defines the node hierarchy used to render the x-axis
  40076. * @param yAxis defines the node hierarchy used to render the y-axis
  40077. * @param zAxis defines the node hierarchy used to render the z-axis
  40078. */
  40079. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40080. /**
  40081. * Force the viewer to update
  40082. * @param position defines the position of the viewer
  40083. * @param xaxis defines the x axis of the viewer
  40084. * @param yaxis defines the y axis of the viewer
  40085. * @param zaxis defines the z axis of the viewer
  40086. */
  40087. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40088. /**
  40089. * Creates an instance of this axes viewer.
  40090. * @returns a new axes viewer with instanced meshes
  40091. */
  40092. createInstance(): AxesViewer;
  40093. /** Releases resources */
  40094. dispose(): void;
  40095. private static _SetRenderingGroupId;
  40096. }
  40097. }
  40098. declare module BABYLON.Debug {
  40099. /**
  40100. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40101. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40102. */
  40103. export class BoneAxesViewer extends AxesViewer {
  40104. /**
  40105. * Gets or sets the target mesh where to display the axes viewer
  40106. */
  40107. mesh: Nullable<Mesh>;
  40108. /**
  40109. * Gets or sets the target bone where to display the axes viewer
  40110. */
  40111. bone: Nullable<Bone>;
  40112. /** Gets current position */
  40113. pos: Vector3;
  40114. /** Gets direction of X axis */
  40115. xaxis: Vector3;
  40116. /** Gets direction of Y axis */
  40117. yaxis: Vector3;
  40118. /** Gets direction of Z axis */
  40119. zaxis: Vector3;
  40120. /**
  40121. * Creates a new BoneAxesViewer
  40122. * @param scene defines the hosting scene
  40123. * @param bone defines the target bone
  40124. * @param mesh defines the target mesh
  40125. * @param scaleLines defines a scaling factor for line length (1 by default)
  40126. */
  40127. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40128. /**
  40129. * Force the viewer to update
  40130. */
  40131. update(): void;
  40132. /** Releases resources */
  40133. dispose(): void;
  40134. }
  40135. }
  40136. declare module BABYLON {
  40137. /**
  40138. * Interface used to define scene explorer extensibility option
  40139. */
  40140. export interface IExplorerExtensibilityOption {
  40141. /**
  40142. * Define the option label
  40143. */
  40144. label: string;
  40145. /**
  40146. * Defines the action to execute on click
  40147. */
  40148. action: (entity: any) => void;
  40149. }
  40150. /**
  40151. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40152. */
  40153. export interface IExplorerExtensibilityGroup {
  40154. /**
  40155. * Defines a predicate to test if a given type mut be extended
  40156. */
  40157. predicate: (entity: any) => boolean;
  40158. /**
  40159. * Gets the list of options added to a type
  40160. */
  40161. entries: IExplorerExtensibilityOption[];
  40162. }
  40163. /**
  40164. * Interface used to define the options to use to create the Inspector
  40165. */
  40166. export interface IInspectorOptions {
  40167. /**
  40168. * Display in overlay mode (default: false)
  40169. */
  40170. overlay?: boolean;
  40171. /**
  40172. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40173. */
  40174. globalRoot?: HTMLElement;
  40175. /**
  40176. * Display the Scene explorer
  40177. */
  40178. showExplorer?: boolean;
  40179. /**
  40180. * Display the property inspector
  40181. */
  40182. showInspector?: boolean;
  40183. /**
  40184. * Display in embed mode (both panes on the right)
  40185. */
  40186. embedMode?: boolean;
  40187. /**
  40188. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40189. */
  40190. handleResize?: boolean;
  40191. /**
  40192. * Allow the panes to popup (default: true)
  40193. */
  40194. enablePopup?: boolean;
  40195. /**
  40196. * Allow the panes to be closed by users (default: true)
  40197. */
  40198. enableClose?: boolean;
  40199. /**
  40200. * Optional list of extensibility entries
  40201. */
  40202. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40203. /**
  40204. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40205. */
  40206. inspectorURL?: string;
  40207. }
  40208. interface Scene {
  40209. /**
  40210. * @hidden
  40211. * Backing field
  40212. */ debugLayer: DebugLayer;
  40213. /**
  40214. * Gets the debug layer (aka Inspector) associated with the scene
  40215. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40216. */
  40217. debugLayer: DebugLayer;
  40218. }
  40219. /**
  40220. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40221. * what is happening in your scene
  40222. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40223. */
  40224. export class DebugLayer {
  40225. /**
  40226. * Define the url to get the inspector script from.
  40227. * By default it uses the babylonjs CDN.
  40228. * @ignoreNaming
  40229. */
  40230. static InspectorURL: string;
  40231. private _scene;
  40232. private BJSINSPECTOR;
  40233. /**
  40234. * Observable triggered when a property is changed through the inspector.
  40235. */
  40236. onPropertyChangedObservable: Observable<{
  40237. object: any;
  40238. property: string;
  40239. value: any;
  40240. initialValue: any;
  40241. }>;
  40242. /**
  40243. * Instantiates a new debug layer.
  40244. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40245. * what is happening in your scene
  40246. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40247. * @param scene Defines the scene to inspect
  40248. */
  40249. constructor(scene: Scene);
  40250. /** Creates the inspector window. */
  40251. private _createInspector;
  40252. /**
  40253. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40254. * @param entity defines the entity to select
  40255. * @param lineContainerTitle defines the specific block to highlight
  40256. */
  40257. select(entity: any, lineContainerTitle?: string): void;
  40258. /** Get the inspector from bundle or global */
  40259. private _getGlobalInspector;
  40260. /**
  40261. * Get if the inspector is visible or not.
  40262. * @returns true if visible otherwise, false
  40263. */
  40264. isVisible(): boolean;
  40265. /**
  40266. * Hide the inspector and close its window.
  40267. */
  40268. hide(): void;
  40269. /**
  40270. * Launch the debugLayer.
  40271. * @param config Define the configuration of the inspector
  40272. * @return a promise fulfilled when the debug layer is visible
  40273. */
  40274. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40275. }
  40276. }
  40277. declare module BABYLON {
  40278. /**
  40279. * Class containing static functions to help procedurally build meshes
  40280. */
  40281. export class BoxBuilder {
  40282. /**
  40283. * Creates a box mesh
  40284. * * The parameter `size` sets the size (float) of each box side (default 1)
  40285. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40286. * * 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)
  40287. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40289. * * 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
  40290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40291. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40292. * @param name defines the name of the mesh
  40293. * @param options defines the options used to create the mesh
  40294. * @param scene defines the hosting scene
  40295. * @returns the box mesh
  40296. */
  40297. static CreateBox(name: string, options: {
  40298. size?: number;
  40299. width?: number;
  40300. height?: number;
  40301. depth?: number;
  40302. faceUV?: Vector4[];
  40303. faceColors?: Color4[];
  40304. sideOrientation?: number;
  40305. frontUVs?: Vector4;
  40306. backUVs?: Vector4;
  40307. wrap?: boolean;
  40308. topBaseAt?: number;
  40309. bottomBaseAt?: number;
  40310. updatable?: boolean;
  40311. }, scene?: Nullable<Scene>): Mesh;
  40312. }
  40313. }
  40314. declare module BABYLON {
  40315. /**
  40316. * Class containing static functions to help procedurally build meshes
  40317. */
  40318. export class SphereBuilder {
  40319. /**
  40320. * Creates a sphere mesh
  40321. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40322. * * 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`)
  40323. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40324. * * 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
  40325. * * 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)
  40326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40327. * * 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
  40328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40329. * @param name defines the name of the mesh
  40330. * @param options defines the options used to create the mesh
  40331. * @param scene defines the hosting scene
  40332. * @returns the sphere mesh
  40333. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40334. */
  40335. static CreateSphere(name: string, options: {
  40336. segments?: number;
  40337. diameter?: number;
  40338. diameterX?: number;
  40339. diameterY?: number;
  40340. diameterZ?: number;
  40341. arc?: number;
  40342. slice?: number;
  40343. sideOrientation?: number;
  40344. frontUVs?: Vector4;
  40345. backUVs?: Vector4;
  40346. updatable?: boolean;
  40347. }, scene: any): Mesh;
  40348. }
  40349. }
  40350. declare module BABYLON.Debug {
  40351. /**
  40352. * Used to show the physics impostor around the specific mesh
  40353. */
  40354. export class PhysicsViewer {
  40355. /** @hidden */
  40356. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40357. /** @hidden */
  40358. protected _meshes: Array<Nullable<AbstractMesh>>;
  40359. /** @hidden */
  40360. protected _scene: Nullable<Scene>;
  40361. /** @hidden */
  40362. protected _numMeshes: number;
  40363. /** @hidden */
  40364. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40365. private _renderFunction;
  40366. private _utilityLayer;
  40367. private _debugBoxMesh;
  40368. private _debugSphereMesh;
  40369. private _debugCylinderMesh;
  40370. private _debugMaterial;
  40371. private _debugMeshMeshes;
  40372. /**
  40373. * Creates a new PhysicsViewer
  40374. * @param scene defines the hosting scene
  40375. */
  40376. constructor(scene: Scene);
  40377. /** @hidden */
  40378. protected _updateDebugMeshes(): void;
  40379. /**
  40380. * Renders a specified physic impostor
  40381. * @param impostor defines the impostor to render
  40382. * @param targetMesh defines the mesh represented by the impostor
  40383. * @returns the new debug mesh used to render the impostor
  40384. */
  40385. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40386. /**
  40387. * Hides a specified physic impostor
  40388. * @param impostor defines the impostor to hide
  40389. */
  40390. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40391. private _getDebugMaterial;
  40392. private _getDebugBoxMesh;
  40393. private _getDebugSphereMesh;
  40394. private _getDebugCylinderMesh;
  40395. private _getDebugMeshMesh;
  40396. private _getDebugMesh;
  40397. /** Releases all resources */
  40398. dispose(): void;
  40399. }
  40400. }
  40401. declare module BABYLON {
  40402. /**
  40403. * Class containing static functions to help procedurally build meshes
  40404. */
  40405. export class LinesBuilder {
  40406. /**
  40407. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40408. * * 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
  40409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40410. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40411. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40412. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40414. * * 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
  40415. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40418. * @param name defines the name of the new line system
  40419. * @param options defines the options used to create the line system
  40420. * @param scene defines the hosting scene
  40421. * @returns a new line system mesh
  40422. */
  40423. static CreateLineSystem(name: string, options: {
  40424. lines: Vector3[][];
  40425. updatable?: boolean;
  40426. instance?: Nullable<LinesMesh>;
  40427. colors?: Nullable<Color4[][]>;
  40428. useVertexAlpha?: boolean;
  40429. }, scene: Nullable<Scene>): LinesMesh;
  40430. /**
  40431. * Creates a line mesh
  40432. * 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
  40433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40434. * * The parameter `points` is an array successive Vector3
  40435. * * 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
  40436. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40437. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40438. * * When updating an instance, remember that only point positions can change, not the number of points
  40439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40441. * @param name defines the name of the new line system
  40442. * @param options defines the options used to create the line system
  40443. * @param scene defines the hosting scene
  40444. * @returns a new line mesh
  40445. */
  40446. static CreateLines(name: string, options: {
  40447. points: Vector3[];
  40448. updatable?: boolean;
  40449. instance?: Nullable<LinesMesh>;
  40450. colors?: Color4[];
  40451. useVertexAlpha?: boolean;
  40452. }, scene?: Nullable<Scene>): LinesMesh;
  40453. /**
  40454. * Creates a dashed line mesh
  40455. * * 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
  40456. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40457. * * The parameter `points` is an array successive Vector3
  40458. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40459. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40460. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40461. * * 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
  40462. * * When updating an instance, remember that only point positions can change, not the number of points
  40463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40464. * @param name defines the name of the mesh
  40465. * @param options defines the options used to create the mesh
  40466. * @param scene defines the hosting scene
  40467. * @returns the dashed line mesh
  40468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40469. */
  40470. static CreateDashedLines(name: string, options: {
  40471. points: Vector3[];
  40472. dashSize?: number;
  40473. gapSize?: number;
  40474. dashNb?: number;
  40475. updatable?: boolean;
  40476. instance?: LinesMesh;
  40477. }, scene?: Nullable<Scene>): LinesMesh;
  40478. }
  40479. }
  40480. declare module BABYLON {
  40481. /**
  40482. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40483. * in order to better appreciate the issue one might have.
  40484. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40485. */
  40486. export class RayHelper {
  40487. /**
  40488. * Defines the ray we are currently tryin to visualize.
  40489. */
  40490. ray: Nullable<Ray>;
  40491. private _renderPoints;
  40492. private _renderLine;
  40493. private _renderFunction;
  40494. private _scene;
  40495. private _updateToMeshFunction;
  40496. private _attachedToMesh;
  40497. private _meshSpaceDirection;
  40498. private _meshSpaceOrigin;
  40499. /**
  40500. * Helper function to create a colored helper in a scene in one line.
  40501. * @param ray Defines the ray we are currently tryin to visualize
  40502. * @param scene Defines the scene the ray is used in
  40503. * @param color Defines the color we want to see the ray in
  40504. * @returns The newly created ray helper.
  40505. */
  40506. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40507. /**
  40508. * Instantiate a new ray helper.
  40509. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40510. * in order to better appreciate the issue one might have.
  40511. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40512. * @param ray Defines the ray we are currently tryin to visualize
  40513. */
  40514. constructor(ray: Ray);
  40515. /**
  40516. * Shows the ray we are willing to debug.
  40517. * @param scene Defines the scene the ray needs to be rendered in
  40518. * @param color Defines the color the ray needs to be rendered in
  40519. */
  40520. show(scene: Scene, color?: Color3): void;
  40521. /**
  40522. * Hides the ray we are debugging.
  40523. */
  40524. hide(): void;
  40525. private _render;
  40526. /**
  40527. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40528. * @param mesh Defines the mesh we want the helper attached to
  40529. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40530. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40531. * @param length Defines the length of the ray
  40532. */
  40533. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40534. /**
  40535. * Detach the ray helper from the mesh it has previously been attached to.
  40536. */
  40537. detachFromMesh(): void;
  40538. private _updateToMesh;
  40539. /**
  40540. * Dispose the helper and release its associated resources.
  40541. */
  40542. dispose(): void;
  40543. }
  40544. }
  40545. declare module BABYLON.Debug {
  40546. /**
  40547. * Class used to render a debug view of a given skeleton
  40548. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40549. */
  40550. export class SkeletonViewer {
  40551. /** defines the skeleton to render */
  40552. skeleton: Skeleton;
  40553. /** defines the mesh attached to the skeleton */
  40554. mesh: AbstractMesh;
  40555. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40556. autoUpdateBonesMatrices: boolean;
  40557. /** defines the rendering group id to use with the viewer */
  40558. renderingGroupId: number;
  40559. /** Gets or sets the color used to render the skeleton */
  40560. color: Color3;
  40561. private _scene;
  40562. private _debugLines;
  40563. private _debugMesh;
  40564. private _isEnabled;
  40565. private _renderFunction;
  40566. private _utilityLayer;
  40567. /**
  40568. * Returns the mesh used to render the bones
  40569. */
  40570. readonly debugMesh: Nullable<LinesMesh>;
  40571. /**
  40572. * Creates a new SkeletonViewer
  40573. * @param skeleton defines the skeleton to render
  40574. * @param mesh defines the mesh attached to the skeleton
  40575. * @param scene defines the hosting scene
  40576. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40577. * @param renderingGroupId defines the rendering group id to use with the viewer
  40578. */
  40579. constructor(
  40580. /** defines the skeleton to render */
  40581. skeleton: Skeleton,
  40582. /** defines the mesh attached to the skeleton */
  40583. mesh: AbstractMesh, scene: Scene,
  40584. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40585. autoUpdateBonesMatrices?: boolean,
  40586. /** defines the rendering group id to use with the viewer */
  40587. renderingGroupId?: number);
  40588. /** Gets or sets a boolean indicating if the viewer is enabled */
  40589. isEnabled: boolean;
  40590. private _getBonePosition;
  40591. private _getLinesForBonesWithLength;
  40592. private _getLinesForBonesNoLength;
  40593. /** Update the viewer to sync with current skeleton state */
  40594. update(): void;
  40595. /** Release associated resources */
  40596. dispose(): void;
  40597. }
  40598. }
  40599. declare module BABYLON {
  40600. /**
  40601. * Options to create the null engine
  40602. */
  40603. export class NullEngineOptions {
  40604. /**
  40605. * Render width (Default: 512)
  40606. */
  40607. renderWidth: number;
  40608. /**
  40609. * Render height (Default: 256)
  40610. */
  40611. renderHeight: number;
  40612. /**
  40613. * Texture size (Default: 512)
  40614. */
  40615. textureSize: number;
  40616. /**
  40617. * If delta time between frames should be constant
  40618. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40619. */
  40620. deterministicLockstep: boolean;
  40621. /**
  40622. * Maximum about of steps between frames (Default: 4)
  40623. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40624. */
  40625. lockstepMaxSteps: number;
  40626. }
  40627. /**
  40628. * The null engine class provides support for headless version of babylon.js.
  40629. * This can be used in server side scenario or for testing purposes
  40630. */
  40631. export class NullEngine extends Engine {
  40632. private _options;
  40633. /**
  40634. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40635. */
  40636. isDeterministicLockStep(): boolean;
  40637. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40638. getLockstepMaxSteps(): number;
  40639. /**
  40640. * Sets hardware scaling, used to save performance if needed
  40641. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40642. */
  40643. getHardwareScalingLevel(): number;
  40644. constructor(options?: NullEngineOptions);
  40645. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40646. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40647. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40648. getRenderWidth(useScreen?: boolean): number;
  40649. getRenderHeight(useScreen?: boolean): number;
  40650. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40651. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40652. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40653. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40654. bindSamplers(effect: Effect): void;
  40655. enableEffect(effect: Effect): void;
  40656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40657. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40658. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40659. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40660. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40661. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40662. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40663. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40664. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40665. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40666. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40667. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40668. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40669. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40670. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40671. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40674. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40676. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40677. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40678. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40679. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40681. bindBuffers(vertexBuffers: {
  40682. [key: string]: VertexBuffer;
  40683. }, indexBuffer: DataBuffer, effect: Effect): void;
  40684. wipeCaches(bruteForce?: boolean): void;
  40685. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40686. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40687. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40688. /** @hidden */ createTexture(): WebGLTexture;
  40689. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40690. 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;
  40691. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40692. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40693. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40694. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40695. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40696. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40697. areAllEffectsReady(): boolean;
  40698. /**
  40699. * @hidden
  40700. * Get the current error code of the webGL context
  40701. * @returns the error code
  40702. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40703. */
  40704. getError(): number;
  40705. /** @hidden */ getUnpackAlignement(): number;
  40706. /** @hidden */ unpackFlipY(value: boolean): void;
  40707. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40708. /**
  40709. * Updates a dynamic vertex buffer.
  40710. * @param vertexBuffer the vertex buffer to update
  40711. * @param data the data used to update the vertex buffer
  40712. * @param byteOffset the byte offset of the data (optional)
  40713. * @param byteLength the byte length of the data (optional)
  40714. */
  40715. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40716. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40717. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40718. releaseEffects(): void;
  40719. displayLoadingUI(): void;
  40720. hideLoadingUI(): void;
  40721. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40722. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40723. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40724. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40725. }
  40726. }
  40727. declare module BABYLON {
  40728. /** @hidden */
  40729. export class _OcclusionDataStorage {
  40730. /** @hidden */
  40731. occlusionInternalRetryCounter: number;
  40732. /** @hidden */
  40733. isOcclusionQueryInProgress: boolean;
  40734. /** @hidden */
  40735. isOccluded: boolean;
  40736. /** @hidden */
  40737. occlusionRetryCount: number;
  40738. /** @hidden */
  40739. occlusionType: number;
  40740. /** @hidden */
  40741. occlusionQueryAlgorithmType: number;
  40742. }
  40743. interface Engine {
  40744. /**
  40745. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40746. * @return the new query
  40747. */
  40748. createQuery(): WebGLQuery;
  40749. /**
  40750. * Delete and release a webGL query
  40751. * @param query defines the query to delete
  40752. * @return the current engine
  40753. */
  40754. deleteQuery(query: WebGLQuery): Engine;
  40755. /**
  40756. * Check if a given query has resolved and got its value
  40757. * @param query defines the query to check
  40758. * @returns true if the query got its value
  40759. */
  40760. isQueryResultAvailable(query: WebGLQuery): boolean;
  40761. /**
  40762. * Gets the value of a given query
  40763. * @param query defines the query to check
  40764. * @returns the value of the query
  40765. */
  40766. getQueryResult(query: WebGLQuery): number;
  40767. /**
  40768. * Initiates an occlusion query
  40769. * @param algorithmType defines the algorithm to use
  40770. * @param query defines the query to use
  40771. * @returns the current engine
  40772. * @see http://doc.babylonjs.com/features/occlusionquery
  40773. */
  40774. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40775. /**
  40776. * Ends an occlusion query
  40777. * @see http://doc.babylonjs.com/features/occlusionquery
  40778. * @param algorithmType defines the algorithm to use
  40779. * @returns the current engine
  40780. */
  40781. endOcclusionQuery(algorithmType: number): Engine;
  40782. /**
  40783. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40784. * Please note that only one query can be issued at a time
  40785. * @returns a time token used to track the time span
  40786. */
  40787. startTimeQuery(): Nullable<_TimeToken>;
  40788. /**
  40789. * Ends a time query
  40790. * @param token defines the token used to measure the time span
  40791. * @returns the time spent (in ns)
  40792. */
  40793. endTimeQuery(token: _TimeToken): int;
  40794. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40795. /** @hidden */ createTimeQuery(): WebGLQuery;
  40796. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40797. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40798. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40799. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40800. }
  40801. interface AbstractMesh {
  40802. /**
  40803. * Backing filed
  40804. * @hidden
  40805. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40806. /**
  40807. * Access property
  40808. * @hidden
  40809. */ occlusionDataStorage: _OcclusionDataStorage;
  40810. /**
  40811. * 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.
  40812. * The default value is -1 which means don't break the query and wait till the result
  40813. * @see http://doc.babylonjs.com/features/occlusionquery
  40814. */
  40815. occlusionRetryCount: number;
  40816. /**
  40817. * 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:
  40818. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40819. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40820. * * 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.
  40821. * @see http://doc.babylonjs.com/features/occlusionquery
  40822. */
  40823. occlusionType: number;
  40824. /**
  40825. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40826. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40827. * * 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.
  40828. * @see http://doc.babylonjs.com/features/occlusionquery
  40829. */
  40830. occlusionQueryAlgorithmType: number;
  40831. /**
  40832. * 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
  40833. * @see http://doc.babylonjs.com/features/occlusionquery
  40834. */
  40835. isOccluded: boolean;
  40836. /**
  40837. * Flag to check the progress status of the query
  40838. * @see http://doc.babylonjs.com/features/occlusionquery
  40839. */
  40840. isOcclusionQueryInProgress: boolean;
  40841. }
  40842. }
  40843. declare module BABYLON {
  40844. /** @hidden */
  40845. export var _forceTransformFeedbackToBundle: boolean;
  40846. interface Engine {
  40847. /**
  40848. * Creates a webGL transform feedback object
  40849. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40850. * @returns the webGL transform feedback object
  40851. */
  40852. createTransformFeedback(): WebGLTransformFeedback;
  40853. /**
  40854. * Delete a webGL transform feedback object
  40855. * @param value defines the webGL transform feedback object to delete
  40856. */
  40857. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40858. /**
  40859. * Bind a webGL transform feedback object to the webgl context
  40860. * @param value defines the webGL transform feedback object to bind
  40861. */
  40862. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40863. /**
  40864. * Begins a transform feedback operation
  40865. * @param usePoints defines if points or triangles must be used
  40866. */
  40867. beginTransformFeedback(usePoints: boolean): void;
  40868. /**
  40869. * Ends a transform feedback operation
  40870. */
  40871. endTransformFeedback(): void;
  40872. /**
  40873. * Specify the varyings to use with transform feedback
  40874. * @param program defines the associated webGL program
  40875. * @param value defines the list of strings representing the varying names
  40876. */
  40877. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40878. /**
  40879. * Bind a webGL buffer for a transform feedback operation
  40880. * @param value defines the webGL buffer to bind
  40881. */
  40882. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40883. }
  40884. }
  40885. declare module BABYLON {
  40886. /**
  40887. * Creation options of the multi render target texture.
  40888. */
  40889. export interface IMultiRenderTargetOptions {
  40890. /**
  40891. * Define if the texture needs to create mip maps after render.
  40892. */
  40893. generateMipMaps?: boolean;
  40894. /**
  40895. * Define the types of all the draw buffers we want to create
  40896. */
  40897. types?: number[];
  40898. /**
  40899. * Define the sampling modes of all the draw buffers we want to create
  40900. */
  40901. samplingModes?: number[];
  40902. /**
  40903. * Define if a depth buffer is required
  40904. */
  40905. generateDepthBuffer?: boolean;
  40906. /**
  40907. * Define if a stencil buffer is required
  40908. */
  40909. generateStencilBuffer?: boolean;
  40910. /**
  40911. * Define if a depth texture is required instead of a depth buffer
  40912. */
  40913. generateDepthTexture?: boolean;
  40914. /**
  40915. * Define the number of desired draw buffers
  40916. */
  40917. textureCount?: number;
  40918. /**
  40919. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40920. */
  40921. doNotChangeAspectRatio?: boolean;
  40922. /**
  40923. * Define the default type of the buffers we are creating
  40924. */
  40925. defaultType?: number;
  40926. }
  40927. /**
  40928. * A multi render target, like a render target provides the ability to render to a texture.
  40929. * Unlike the render target, it can render to several draw buffers in one draw.
  40930. * This is specially interesting in deferred rendering or for any effects requiring more than
  40931. * just one color from a single pass.
  40932. */
  40933. export class MultiRenderTarget extends RenderTargetTexture {
  40934. private _internalTextures;
  40935. private _textures;
  40936. private _multiRenderTargetOptions;
  40937. /**
  40938. * Get if draw buffers are currently supported by the used hardware and browser.
  40939. */
  40940. readonly isSupported: boolean;
  40941. /**
  40942. * Get the list of textures generated by the multi render target.
  40943. */
  40944. readonly textures: Texture[];
  40945. /**
  40946. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40947. */
  40948. readonly depthTexture: Texture;
  40949. /**
  40950. * Set the wrapping mode on U of all the textures we are rendering to.
  40951. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40952. */
  40953. wrapU: number;
  40954. /**
  40955. * Set the wrapping mode on V of all the textures we are rendering to.
  40956. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40957. */
  40958. wrapV: number;
  40959. /**
  40960. * Instantiate a new multi render target texture.
  40961. * A multi render target, like a render target provides the ability to render to a texture.
  40962. * Unlike the render target, it can render to several draw buffers in one draw.
  40963. * This is specially interesting in deferred rendering or for any effects requiring more than
  40964. * just one color from a single pass.
  40965. * @param name Define the name of the texture
  40966. * @param size Define the size of the buffers to render to
  40967. * @param count Define the number of target we are rendering into
  40968. * @param scene Define the scene the texture belongs to
  40969. * @param options Define the options used to create the multi render target
  40970. */
  40971. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  40972. /** @hidden */ rebuild(): void;
  40973. private _createInternalTextures;
  40974. private _createTextures;
  40975. /**
  40976. * Define the number of samples used if MSAA is enabled.
  40977. */
  40978. samples: number;
  40979. /**
  40980. * Resize all the textures in the multi render target.
  40981. * Be carrefull as it will recreate all the data in the new texture.
  40982. * @param size Define the new size
  40983. */
  40984. resize(size: any): void;
  40985. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40986. /**
  40987. * Dispose the render targets and their associated resources
  40988. */
  40989. dispose(): void;
  40990. /**
  40991. * Release all the underlying texture used as draw buffers.
  40992. */
  40993. releaseInternalTextures(): void;
  40994. }
  40995. }
  40996. declare module BABYLON {
  40997. interface Engine {
  40998. /**
  40999. * Unbind a list of render target textures from the webGL context
  41000. * This is used only when drawBuffer extension or webGL2 are active
  41001. * @param textures defines the render target textures to unbind
  41002. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41003. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41004. */
  41005. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41006. /**
  41007. * Create a multi render target texture
  41008. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41009. * @param size defines the size of the texture
  41010. * @param options defines the creation options
  41011. * @returns the cube texture as an InternalTexture
  41012. */
  41013. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41014. /**
  41015. * Update the sample count for a given multiple render target texture
  41016. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41017. * @param textures defines the textures to update
  41018. * @param samples defines the sample count to set
  41019. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41020. */
  41021. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41022. }
  41023. }
  41024. declare module BABYLON {
  41025. /**
  41026. * Gather the list of clipboard event types as constants.
  41027. */
  41028. export class ClipboardEventTypes {
  41029. /**
  41030. * The clipboard event is fired when a copy command is active (pressed).
  41031. */
  41032. static readonly COPY: number;
  41033. /**
  41034. * The clipboard event is fired when a cut command is active (pressed).
  41035. */
  41036. static readonly CUT: number;
  41037. /**
  41038. * The clipboard event is fired when a paste command is active (pressed).
  41039. */
  41040. static readonly PASTE: number;
  41041. }
  41042. /**
  41043. * This class is used to store clipboard related info for the onClipboardObservable event.
  41044. */
  41045. export class ClipboardInfo {
  41046. /**
  41047. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41048. */
  41049. type: number;
  41050. /**
  41051. * Defines the related dom event
  41052. */
  41053. event: ClipboardEvent;
  41054. /**
  41055. *Creates an instance of ClipboardInfo.
  41056. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41057. * @param event Defines the related dom event
  41058. */
  41059. constructor(
  41060. /**
  41061. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41062. */
  41063. type: number,
  41064. /**
  41065. * Defines the related dom event
  41066. */
  41067. event: ClipboardEvent);
  41068. /**
  41069. * Get the clipboard event's type from the keycode.
  41070. * @param keyCode Defines the keyCode for the current keyboard event.
  41071. * @return {number}
  41072. */
  41073. static GetTypeFromCharacter(keyCode: number): number;
  41074. }
  41075. }
  41076. declare module BABYLON {
  41077. /**
  41078. * Class used to represent data loading progression
  41079. */
  41080. export class SceneLoaderProgressEvent {
  41081. /** defines if data length to load can be evaluated */
  41082. readonly lengthComputable: boolean;
  41083. /** defines the loaded data length */
  41084. readonly loaded: number;
  41085. /** defines the data length to load */
  41086. readonly total: number;
  41087. /**
  41088. * Create a new progress event
  41089. * @param lengthComputable defines if data length to load can be evaluated
  41090. * @param loaded defines the loaded data length
  41091. * @param total defines the data length to load
  41092. */
  41093. constructor(
  41094. /** defines if data length to load can be evaluated */
  41095. lengthComputable: boolean,
  41096. /** defines the loaded data length */
  41097. loaded: number,
  41098. /** defines the data length to load */
  41099. total: number);
  41100. /**
  41101. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41102. * @param event defines the source event
  41103. * @returns a new SceneLoaderProgressEvent
  41104. */
  41105. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41106. }
  41107. /**
  41108. * Interface used by SceneLoader plugins to define supported file extensions
  41109. */
  41110. export interface ISceneLoaderPluginExtensions {
  41111. /**
  41112. * Defines the list of supported extensions
  41113. */
  41114. [extension: string]: {
  41115. isBinary: boolean;
  41116. };
  41117. }
  41118. /**
  41119. * Interface used by SceneLoader plugin factory
  41120. */
  41121. export interface ISceneLoaderPluginFactory {
  41122. /**
  41123. * Defines the name of the factory
  41124. */
  41125. name: string;
  41126. /**
  41127. * Function called to create a new plugin
  41128. * @return the new plugin
  41129. */
  41130. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41131. /**
  41132. * Boolean indicating if the plugin can direct load specific data
  41133. */
  41134. canDirectLoad?: (data: string) => boolean;
  41135. }
  41136. /**
  41137. * Interface used to define a SceneLoader plugin
  41138. */
  41139. export interface ISceneLoaderPlugin {
  41140. /**
  41141. * The friendly name of this plugin.
  41142. */
  41143. name: string;
  41144. /**
  41145. * The file extensions supported by this plugin.
  41146. */
  41147. extensions: string | ISceneLoaderPluginExtensions;
  41148. /**
  41149. * Import meshes into a scene.
  41150. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41151. * @param scene The scene to import into
  41152. * @param data The data to import
  41153. * @param rootUrl The root url for scene and resources
  41154. * @param meshes The meshes array to import into
  41155. * @param particleSystems The particle systems array to import into
  41156. * @param skeletons The skeletons array to import into
  41157. * @param onError The callback when import fails
  41158. * @returns True if successful or false otherwise
  41159. */
  41160. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41161. /**
  41162. * Load into a scene.
  41163. * @param scene The scene to load into
  41164. * @param data The data to import
  41165. * @param rootUrl The root url for scene and resources
  41166. * @param onError The callback when import fails
  41167. * @returns true if successful or false otherwise
  41168. */
  41169. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41170. /**
  41171. * The callback that returns true if the data can be directly loaded.
  41172. */
  41173. canDirectLoad?: (data: string) => boolean;
  41174. /**
  41175. * The callback that allows custom handling of the root url based on the response url.
  41176. */
  41177. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41178. /**
  41179. * Load into an asset container.
  41180. * @param scene The scene to load into
  41181. * @param data The data to import
  41182. * @param rootUrl The root url for scene and resources
  41183. * @param onError The callback when import fails
  41184. * @returns The loaded asset container
  41185. */
  41186. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41187. }
  41188. /**
  41189. * Interface used to define an async SceneLoader plugin
  41190. */
  41191. export interface ISceneLoaderPluginAsync {
  41192. /**
  41193. * The friendly name of this plugin.
  41194. */
  41195. name: string;
  41196. /**
  41197. * The file extensions supported by this plugin.
  41198. */
  41199. extensions: string | ISceneLoaderPluginExtensions;
  41200. /**
  41201. * Import meshes into a scene.
  41202. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41203. * @param scene The scene to import into
  41204. * @param data The data to import
  41205. * @param rootUrl The root url for scene and resources
  41206. * @param onProgress The callback when the load progresses
  41207. * @param fileName Defines the name of the file to load
  41208. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41209. */
  41210. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41211. meshes: AbstractMesh[];
  41212. particleSystems: IParticleSystem[];
  41213. skeletons: Skeleton[];
  41214. animationGroups: AnimationGroup[];
  41215. }>;
  41216. /**
  41217. * Load into a scene.
  41218. * @param scene The scene to load into
  41219. * @param data The data to import
  41220. * @param rootUrl The root url for scene and resources
  41221. * @param onProgress The callback when the load progresses
  41222. * @param fileName Defines the name of the file to load
  41223. * @returns Nothing
  41224. */
  41225. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41226. /**
  41227. * The callback that returns true if the data can be directly loaded.
  41228. */
  41229. canDirectLoad?: (data: string) => boolean;
  41230. /**
  41231. * The callback that allows custom handling of the root url based on the response url.
  41232. */
  41233. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41234. /**
  41235. * Load into an asset container.
  41236. * @param scene The scene to load into
  41237. * @param data The data to import
  41238. * @param rootUrl The root url for scene and resources
  41239. * @param onProgress The callback when the load progresses
  41240. * @param fileName Defines the name of the file to load
  41241. * @returns The loaded asset container
  41242. */
  41243. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41244. }
  41245. /**
  41246. * Class used to load scene from various file formats using registered plugins
  41247. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41248. */
  41249. export class SceneLoader {
  41250. /**
  41251. * No logging while loading
  41252. */
  41253. static readonly NO_LOGGING: number;
  41254. /**
  41255. * Minimal logging while loading
  41256. */
  41257. static readonly MINIMAL_LOGGING: number;
  41258. /**
  41259. * Summary logging while loading
  41260. */
  41261. static readonly SUMMARY_LOGGING: number;
  41262. /**
  41263. * Detailled logging while loading
  41264. */
  41265. static readonly DETAILED_LOGGING: number;
  41266. /**
  41267. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41268. */
  41269. static ForceFullSceneLoadingForIncremental: boolean;
  41270. /**
  41271. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41272. */
  41273. static ShowLoadingScreen: boolean;
  41274. /**
  41275. * Defines the current logging level (while loading the scene)
  41276. * @ignorenaming
  41277. */
  41278. static loggingLevel: number;
  41279. /**
  41280. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41281. */
  41282. static CleanBoneMatrixWeights: boolean;
  41283. /**
  41284. * Event raised when a plugin is used to load a scene
  41285. */
  41286. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41287. private static _registeredPlugins;
  41288. private static _getDefaultPlugin;
  41289. private static _getPluginForExtension;
  41290. private static _getPluginForDirectLoad;
  41291. private static _getPluginForFilename;
  41292. private static _getDirectLoad;
  41293. private static _loadData;
  41294. private static _getFileInfo;
  41295. /**
  41296. * Gets a plugin that can load the given extension
  41297. * @param extension defines the extension to load
  41298. * @returns a plugin or null if none works
  41299. */
  41300. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41301. /**
  41302. * Gets a boolean indicating that the given extension can be loaded
  41303. * @param extension defines the extension to load
  41304. * @returns true if the extension is supported
  41305. */
  41306. static IsPluginForExtensionAvailable(extension: string): boolean;
  41307. /**
  41308. * Adds a new plugin to the list of registered plugins
  41309. * @param plugin defines the plugin to add
  41310. */
  41311. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41312. /**
  41313. * Import meshes into a scene
  41314. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41315. * @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)
  41316. * @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)
  41317. * @param scene the instance of BABYLON.Scene to append to
  41318. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41319. * @param onProgress a callback with a progress event for each file being loaded
  41320. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41321. * @param pluginExtension the extension used to determine the plugin
  41322. * @returns The loaded plugin
  41323. */
  41324. 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>;
  41325. /**
  41326. * Import meshes into a scene
  41327. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41328. * @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)
  41329. * @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)
  41330. * @param scene the instance of BABYLON.Scene to append to
  41331. * @param onProgress a callback with a progress event for each file being loaded
  41332. * @param pluginExtension the extension used to determine the plugin
  41333. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41334. */
  41335. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41336. meshes: AbstractMesh[];
  41337. particleSystems: IParticleSystem[];
  41338. skeletons: Skeleton[];
  41339. animationGroups: AnimationGroup[];
  41340. }>;
  41341. /**
  41342. * Load a scene
  41343. * @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)
  41344. * @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)
  41345. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41346. * @param onSuccess a callback with the scene when import succeeds
  41347. * @param onProgress a callback with a progress event for each file being loaded
  41348. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41349. * @param pluginExtension the extension used to determine the plugin
  41350. * @returns The loaded plugin
  41351. */
  41352. 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>;
  41353. /**
  41354. * Load a scene
  41355. * @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)
  41356. * @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)
  41357. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41358. * @param onProgress a callback with a progress event for each file being loaded
  41359. * @param pluginExtension the extension used to determine the plugin
  41360. * @returns The loaded scene
  41361. */
  41362. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41363. /**
  41364. * Append a scene
  41365. * @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)
  41366. * @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)
  41367. * @param scene is the instance of BABYLON.Scene to append to
  41368. * @param onSuccess a callback with the scene when import succeeds
  41369. * @param onProgress a callback with a progress event for each file being loaded
  41370. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41371. * @param pluginExtension the extension used to determine the plugin
  41372. * @returns The loaded plugin
  41373. */
  41374. 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>;
  41375. /**
  41376. * Append a scene
  41377. * @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)
  41378. * @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)
  41379. * @param scene is the instance of BABYLON.Scene to append to
  41380. * @param onProgress a callback with a progress event for each file being loaded
  41381. * @param pluginExtension the extension used to determine the plugin
  41382. * @returns The given scene
  41383. */
  41384. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41385. /**
  41386. * Load a scene into an asset container
  41387. * @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)
  41388. * @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)
  41389. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41390. * @param onSuccess a callback with the scene when import succeeds
  41391. * @param onProgress a callback with a progress event for each file being loaded
  41392. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41393. * @param pluginExtension the extension used to determine the plugin
  41394. * @returns The loaded plugin
  41395. */
  41396. 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>;
  41397. /**
  41398. * Load a scene into an asset container
  41399. * @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)
  41400. * @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)
  41401. * @param scene is the instance of Scene to append to
  41402. * @param onProgress a callback with a progress event for each file being loaded
  41403. * @param pluginExtension the extension used to determine the plugin
  41404. * @returns The loaded asset container
  41405. */
  41406. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41407. }
  41408. }
  41409. declare module BABYLON {
  41410. /**
  41411. * Google Daydream controller
  41412. */
  41413. export class DaydreamController extends WebVRController {
  41414. /**
  41415. * Base Url for the controller model.
  41416. */
  41417. static MODEL_BASE_URL: string;
  41418. /**
  41419. * File name for the controller model.
  41420. */
  41421. static MODEL_FILENAME: string;
  41422. /**
  41423. * Gamepad Id prefix used to identify Daydream Controller.
  41424. */
  41425. static readonly GAMEPAD_ID_PREFIX: string;
  41426. /**
  41427. * Creates a new DaydreamController from a gamepad
  41428. * @param vrGamepad the gamepad that the controller should be created from
  41429. */
  41430. constructor(vrGamepad: any);
  41431. /**
  41432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41433. * @param scene scene in which to add meshes
  41434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41435. */
  41436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41437. /**
  41438. * Called once for each button that changed state since the last frame
  41439. * @param buttonIdx Which button index changed
  41440. * @param state New state of the button
  41441. * @param changes Which properties on the state changed since last frame
  41442. */
  41443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41444. }
  41445. }
  41446. declare module BABYLON {
  41447. /**
  41448. * Gear VR Controller
  41449. */
  41450. export class GearVRController extends WebVRController {
  41451. /**
  41452. * Base Url for the controller model.
  41453. */
  41454. static MODEL_BASE_URL: string;
  41455. /**
  41456. * File name for the controller model.
  41457. */
  41458. static MODEL_FILENAME: string;
  41459. /**
  41460. * Gamepad Id prefix used to identify this controller.
  41461. */
  41462. static readonly GAMEPAD_ID_PREFIX: string;
  41463. private readonly _buttonIndexToObservableNameMap;
  41464. /**
  41465. * Creates a new GearVRController from a gamepad
  41466. * @param vrGamepad the gamepad that the controller should be created from
  41467. */
  41468. constructor(vrGamepad: any);
  41469. /**
  41470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41471. * @param scene scene in which to add meshes
  41472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41473. */
  41474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41475. /**
  41476. * Called once for each button that changed state since the last frame
  41477. * @param buttonIdx Which button index changed
  41478. * @param state New state of the button
  41479. * @param changes Which properties on the state changed since last frame
  41480. */
  41481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * Generic Controller
  41487. */
  41488. export class GenericController extends WebVRController {
  41489. /**
  41490. * Base Url for the controller model.
  41491. */
  41492. static readonly MODEL_BASE_URL: string;
  41493. /**
  41494. * File name for the controller model.
  41495. */
  41496. static readonly MODEL_FILENAME: string;
  41497. /**
  41498. * Creates a new GenericController from a gamepad
  41499. * @param vrGamepad the gamepad that the controller should be created from
  41500. */
  41501. constructor(vrGamepad: any);
  41502. /**
  41503. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41504. * @param scene scene in which to add meshes
  41505. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41506. */
  41507. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41508. /**
  41509. * Called once for each button that changed state since the last frame
  41510. * @param buttonIdx Which button index changed
  41511. * @param state New state of the button
  41512. * @param changes Which properties on the state changed since last frame
  41513. */
  41514. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41515. }
  41516. }
  41517. declare module BABYLON {
  41518. /**
  41519. * Oculus Touch Controller
  41520. */
  41521. export class OculusTouchController extends WebVRController {
  41522. /**
  41523. * Base Url for the controller model.
  41524. */
  41525. static MODEL_BASE_URL: string;
  41526. /**
  41527. * File name for the left controller model.
  41528. */
  41529. static MODEL_LEFT_FILENAME: string;
  41530. /**
  41531. * File name for the right controller model.
  41532. */
  41533. static MODEL_RIGHT_FILENAME: string;
  41534. /**
  41535. * Fired when the secondary trigger on this controller is modified
  41536. */
  41537. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41538. /**
  41539. * Fired when the thumb rest on this controller is modified
  41540. */
  41541. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41542. /**
  41543. * Creates a new OculusTouchController from a gamepad
  41544. * @param vrGamepad the gamepad that the controller should be created from
  41545. */
  41546. constructor(vrGamepad: any);
  41547. /**
  41548. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41549. * @param scene scene in which to add meshes
  41550. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41551. */
  41552. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41553. /**
  41554. * Fired when the A button on this controller is modified
  41555. */
  41556. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41557. /**
  41558. * Fired when the B button on this controller is modified
  41559. */
  41560. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41561. /**
  41562. * Fired when the X button on this controller is modified
  41563. */
  41564. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41565. /**
  41566. * Fired when the Y button on this controller is modified
  41567. */
  41568. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41569. /**
  41570. * Called once for each button that changed state since the last frame
  41571. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41572. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41573. * 2) secondary trigger (same)
  41574. * 3) A (right) X (left), touch, pressed = value
  41575. * 4) B / Y
  41576. * 5) thumb rest
  41577. * @param buttonIdx Which button index changed
  41578. * @param state New state of the button
  41579. * @param changes Which properties on the state changed since last frame
  41580. */
  41581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41582. }
  41583. }
  41584. declare module BABYLON {
  41585. /**
  41586. * Vive Controller
  41587. */
  41588. export class ViveController extends WebVRController {
  41589. /**
  41590. * Base Url for the controller model.
  41591. */
  41592. static MODEL_BASE_URL: string;
  41593. /**
  41594. * File name for the controller model.
  41595. */
  41596. static MODEL_FILENAME: string;
  41597. /**
  41598. * Creates a new ViveController from a gamepad
  41599. * @param vrGamepad the gamepad that the controller should be created from
  41600. */
  41601. constructor(vrGamepad: any);
  41602. /**
  41603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41604. * @param scene scene in which to add meshes
  41605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41606. */
  41607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41608. /**
  41609. * Fired when the left button on this controller is modified
  41610. */
  41611. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41612. /**
  41613. * Fired when the right button on this controller is modified
  41614. */
  41615. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41616. /**
  41617. * Fired when the menu button on this controller is modified
  41618. */
  41619. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41620. /**
  41621. * Called once for each button that changed state since the last frame
  41622. * Vive mapping:
  41623. * 0: touchpad
  41624. * 1: trigger
  41625. * 2: left AND right buttons
  41626. * 3: menu button
  41627. * @param buttonIdx Which button index changed
  41628. * @param state New state of the button
  41629. * @param changes Which properties on the state changed since last frame
  41630. */
  41631. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41632. }
  41633. }
  41634. declare module BABYLON {
  41635. /**
  41636. * Defines the WindowsMotionController object that the state of the windows motion controller
  41637. */
  41638. export class WindowsMotionController extends WebVRController {
  41639. /**
  41640. * The base url used to load the left and right controller models
  41641. */
  41642. static MODEL_BASE_URL: string;
  41643. /**
  41644. * The name of the left controller model file
  41645. */
  41646. static MODEL_LEFT_FILENAME: string;
  41647. /**
  41648. * The name of the right controller model file
  41649. */
  41650. static MODEL_RIGHT_FILENAME: string;
  41651. /**
  41652. * The controller name prefix for this controller type
  41653. */
  41654. static readonly GAMEPAD_ID_PREFIX: string;
  41655. /**
  41656. * The controller id pattern for this controller type
  41657. */
  41658. private static readonly GAMEPAD_ID_PATTERN;
  41659. private _loadedMeshInfo;
  41660. private readonly _mapping;
  41661. /**
  41662. * Fired when the trackpad on this controller is clicked
  41663. */
  41664. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41665. /**
  41666. * Fired when the trackpad on this controller is modified
  41667. */
  41668. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41669. /**
  41670. * The current x and y values of this controller's trackpad
  41671. */
  41672. trackpad: StickValues;
  41673. /**
  41674. * Creates a new WindowsMotionController from a gamepad
  41675. * @param vrGamepad the gamepad that the controller should be created from
  41676. */
  41677. constructor(vrGamepad: any);
  41678. /**
  41679. * Fired when the trigger on this controller is modified
  41680. */
  41681. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41682. /**
  41683. * Fired when the menu button on this controller is modified
  41684. */
  41685. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41686. /**
  41687. * Fired when the grip button on this controller is modified
  41688. */
  41689. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41690. /**
  41691. * Fired when the thumbstick button on this controller is modified
  41692. */
  41693. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41694. /**
  41695. * Fired when the touchpad button on this controller is modified
  41696. */
  41697. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41698. /**
  41699. * Fired when the touchpad values on this controller are modified
  41700. */
  41701. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41702. private _updateTrackpad;
  41703. /**
  41704. * Called once per frame by the engine.
  41705. */
  41706. update(): void;
  41707. /**
  41708. * Called once for each button that changed state since the last frame
  41709. * @param buttonIdx Which button index changed
  41710. * @param state New state of the button
  41711. * @param changes Which properties on the state changed since last frame
  41712. */
  41713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41714. /**
  41715. * Moves the buttons on the controller mesh based on their current state
  41716. * @param buttonName the name of the button to move
  41717. * @param buttonValue the value of the button which determines the buttons new position
  41718. */
  41719. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41720. /**
  41721. * Moves the axis on the controller mesh based on its current state
  41722. * @param axis the index of the axis
  41723. * @param axisValue the value of the axis which determines the meshes new position
  41724. * @hidden
  41725. */
  41726. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41727. /**
  41728. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41729. * @param scene scene in which to add meshes
  41730. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41731. */
  41732. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41733. /**
  41734. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41735. * can be transformed by button presses and axes values, based on this._mapping.
  41736. *
  41737. * @param scene scene in which the meshes exist
  41738. * @param meshes list of meshes that make up the controller model to process
  41739. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41740. */
  41741. private processModel;
  41742. private createMeshInfo;
  41743. /**
  41744. * Gets the ray of the controller in the direction the controller is pointing
  41745. * @param length the length the resulting ray should be
  41746. * @returns a ray in the direction the controller is pointing
  41747. */
  41748. getForwardRay(length?: number): Ray;
  41749. /**
  41750. * Disposes of the controller
  41751. */
  41752. dispose(): void;
  41753. }
  41754. }
  41755. declare module BABYLON {
  41756. /**
  41757. * Single axis scale gizmo
  41758. */
  41759. export class AxisScaleGizmo extends Gizmo {
  41760. private _coloredMaterial;
  41761. /**
  41762. * Drag behavior responsible for the gizmos dragging interactions
  41763. */
  41764. dragBehavior: PointerDragBehavior;
  41765. private _pointerObserver;
  41766. /**
  41767. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41768. */
  41769. snapDistance: number;
  41770. /**
  41771. * Event that fires each time the gizmo snaps to a new location.
  41772. * * snapDistance is the the change in distance
  41773. */
  41774. onSnapObservable: Observable<{
  41775. snapDistance: number;
  41776. }>;
  41777. /**
  41778. * If the scaling operation should be done on all axis (default: false)
  41779. */
  41780. uniformScaling: boolean;
  41781. /**
  41782. * Creates an AxisScaleGizmo
  41783. * @param gizmoLayer The utility layer the gizmo will be added to
  41784. * @param dragAxis The axis which the gizmo will be able to scale on
  41785. * @param color The color of the gizmo
  41786. */
  41787. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41789. /**
  41790. * Disposes of the gizmo
  41791. */
  41792. dispose(): void;
  41793. /**
  41794. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41795. * @param mesh The mesh to replace the default mesh of the gizmo
  41796. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41797. */
  41798. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41799. }
  41800. }
  41801. declare module BABYLON {
  41802. /**
  41803. * Bounding box gizmo
  41804. */
  41805. export class BoundingBoxGizmo extends Gizmo {
  41806. private _lineBoundingBox;
  41807. private _rotateSpheresParent;
  41808. private _scaleBoxesParent;
  41809. private _boundingDimensions;
  41810. private _renderObserver;
  41811. private _pointerObserver;
  41812. private _scaleDragSpeed;
  41813. private _tmpQuaternion;
  41814. private _tmpVector;
  41815. private _tmpRotationMatrix;
  41816. /**
  41817. * 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)
  41818. */
  41819. ignoreChildren: boolean;
  41820. /**
  41821. * 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)
  41822. */
  41823. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41824. /**
  41825. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41826. */
  41827. rotationSphereSize: number;
  41828. /**
  41829. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41830. */
  41831. scaleBoxSize: number;
  41832. /**
  41833. * 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)
  41834. */
  41835. fixedDragMeshScreenSize: boolean;
  41836. /**
  41837. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41838. */
  41839. fixedDragMeshScreenSizeDistanceFactor: number;
  41840. /**
  41841. * Fired when a rotation sphere or scale box is dragged
  41842. */
  41843. onDragStartObservable: Observable<{}>;
  41844. /**
  41845. * Fired when a scale box is dragged
  41846. */
  41847. onScaleBoxDragObservable: Observable<{}>;
  41848. /**
  41849. * Fired when a scale box drag is ended
  41850. */
  41851. onScaleBoxDragEndObservable: Observable<{}>;
  41852. /**
  41853. * Fired when a rotation sphere is dragged
  41854. */
  41855. onRotationSphereDragObservable: Observable<{}>;
  41856. /**
  41857. * Fired when a rotation sphere drag is ended
  41858. */
  41859. onRotationSphereDragEndObservable: Observable<{}>;
  41860. /**
  41861. * 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)
  41862. */
  41863. scalePivot: Nullable<Vector3>;
  41864. /**
  41865. * Mesh used as a pivot to rotate the attached mesh
  41866. */
  41867. private _anchorMesh;
  41868. private _existingMeshScale;
  41869. private _dragMesh;
  41870. private pointerDragBehavior;
  41871. private coloredMaterial;
  41872. private hoverColoredMaterial;
  41873. /**
  41874. * Sets the color of the bounding box gizmo
  41875. * @param color the color to set
  41876. */
  41877. setColor(color: Color3): void;
  41878. /**
  41879. * Creates an BoundingBoxGizmo
  41880. * @param gizmoLayer The utility layer the gizmo will be added to
  41881. * @param color The color of the gizmo
  41882. */
  41883. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41884. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41885. private _selectNode;
  41886. /**
  41887. * Updates the bounding box information for the Gizmo
  41888. */
  41889. updateBoundingBox(): void;
  41890. private _updateRotationSpheres;
  41891. private _updateScaleBoxes;
  41892. /**
  41893. * Enables rotation on the specified axis and disables rotation on the others
  41894. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41895. */
  41896. setEnabledRotationAxis(axis: string): void;
  41897. /**
  41898. * Enables/disables scaling
  41899. * @param enable if scaling should be enabled
  41900. */
  41901. setEnabledScaling(enable: boolean): void;
  41902. private _updateDummy;
  41903. /**
  41904. * Enables a pointer drag behavior on the bounding box of the gizmo
  41905. */
  41906. enableDragBehavior(): void;
  41907. /**
  41908. * Disposes of the gizmo
  41909. */
  41910. dispose(): void;
  41911. /**
  41912. * 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)
  41913. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41914. * @returns the bounding box mesh with the passed in mesh as a child
  41915. */
  41916. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41917. /**
  41918. * CustomMeshes are not supported by this gizmo
  41919. * @param mesh The mesh to replace the default mesh of the gizmo
  41920. */
  41921. setCustomMesh(mesh: Mesh): void;
  41922. }
  41923. }
  41924. declare module BABYLON {
  41925. /**
  41926. * Single plane rotation gizmo
  41927. */
  41928. export class PlaneRotationGizmo extends Gizmo {
  41929. /**
  41930. * Drag behavior responsible for the gizmos dragging interactions
  41931. */
  41932. dragBehavior: PointerDragBehavior;
  41933. private _pointerObserver;
  41934. /**
  41935. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41936. */
  41937. snapDistance: number;
  41938. /**
  41939. * Event that fires each time the gizmo snaps to a new location.
  41940. * * snapDistance is the the change in distance
  41941. */
  41942. onSnapObservable: Observable<{
  41943. snapDistance: number;
  41944. }>;
  41945. /**
  41946. * Creates a PlaneRotationGizmo
  41947. * @param gizmoLayer The utility layer the gizmo will be added to
  41948. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41949. * @param color The color of the gizmo
  41950. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41951. */
  41952. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41953. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41954. /**
  41955. * Disposes of the gizmo
  41956. */
  41957. dispose(): void;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * Gizmo that enables rotating a mesh along 3 axis
  41963. */
  41964. export class RotationGizmo extends Gizmo {
  41965. /**
  41966. * Internal gizmo used for interactions on the x axis
  41967. */
  41968. xGizmo: PlaneRotationGizmo;
  41969. /**
  41970. * Internal gizmo used for interactions on the y axis
  41971. */
  41972. yGizmo: PlaneRotationGizmo;
  41973. /**
  41974. * Internal gizmo used for interactions on the z axis
  41975. */
  41976. zGizmo: PlaneRotationGizmo;
  41977. /** Fires an event when any of it's sub gizmos are dragged */
  41978. onDragStartObservable: Observable<{}>;
  41979. /** Fires an event when any of it's sub gizmos are released from dragging */
  41980. onDragEndObservable: Observable<{}>;
  41981. attachedMesh: Nullable<AbstractMesh>;
  41982. /**
  41983. * Creates a RotationGizmo
  41984. * @param gizmoLayer The utility layer the gizmo will be added to
  41985. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41986. */
  41987. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41988. updateGizmoRotationToMatchAttachedMesh: boolean;
  41989. /**
  41990. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41991. */
  41992. snapDistance: number;
  41993. /**
  41994. * Ratio for the scale of the gizmo (Default: 1)
  41995. */
  41996. scaleRatio: number;
  41997. /**
  41998. * Disposes of the gizmo
  41999. */
  42000. dispose(): void;
  42001. /**
  42002. * CustomMeshes are not supported by this gizmo
  42003. * @param mesh The mesh to replace the default mesh of the gizmo
  42004. */
  42005. setCustomMesh(mesh: Mesh): void;
  42006. }
  42007. }
  42008. declare module BABYLON {
  42009. /**
  42010. * Gizmo that enables dragging a mesh along 3 axis
  42011. */
  42012. export class PositionGizmo extends Gizmo {
  42013. /**
  42014. * Internal gizmo used for interactions on the x axis
  42015. */
  42016. xGizmo: AxisDragGizmo;
  42017. /**
  42018. * Internal gizmo used for interactions on the y axis
  42019. */
  42020. yGizmo: AxisDragGizmo;
  42021. /**
  42022. * Internal gizmo used for interactions on the z axis
  42023. */
  42024. zGizmo: AxisDragGizmo;
  42025. /** Fires an event when any of it's sub gizmos are dragged */
  42026. onDragStartObservable: Observable<{}>;
  42027. /** Fires an event when any of it's sub gizmos are released from dragging */
  42028. onDragEndObservable: Observable<{}>;
  42029. attachedMesh: Nullable<AbstractMesh>;
  42030. /**
  42031. * Creates a PositionGizmo
  42032. * @param gizmoLayer The utility layer the gizmo will be added to
  42033. */
  42034. constructor(gizmoLayer?: UtilityLayerRenderer);
  42035. updateGizmoRotationToMatchAttachedMesh: boolean;
  42036. /**
  42037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42038. */
  42039. snapDistance: number;
  42040. /**
  42041. * Ratio for the scale of the gizmo (Default: 1)
  42042. */
  42043. scaleRatio: number;
  42044. /**
  42045. * Disposes of the gizmo
  42046. */
  42047. dispose(): void;
  42048. /**
  42049. * CustomMeshes are not supported by this gizmo
  42050. * @param mesh The mesh to replace the default mesh of the gizmo
  42051. */
  42052. setCustomMesh(mesh: Mesh): void;
  42053. }
  42054. }
  42055. declare module BABYLON {
  42056. /**
  42057. * Class containing static functions to help procedurally build meshes
  42058. */
  42059. export class PolyhedronBuilder {
  42060. /**
  42061. * Creates a polyhedron mesh
  42062. * * 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
  42063. * * The parameter `size` (positive float, default 1) sets the polygon size
  42064. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42065. * * 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`
  42066. * * 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
  42067. * * 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)`)
  42068. * * 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
  42069. * * 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
  42070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42071. * * 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
  42072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42073. * @param name defines the name of the mesh
  42074. * @param options defines the options used to create the mesh
  42075. * @param scene defines the hosting scene
  42076. * @returns the polyhedron mesh
  42077. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42078. */
  42079. static CreatePolyhedron(name: string, options: {
  42080. type?: number;
  42081. size?: number;
  42082. sizeX?: number;
  42083. sizeY?: number;
  42084. sizeZ?: number;
  42085. custom?: any;
  42086. faceUV?: Vector4[];
  42087. faceColors?: Color4[];
  42088. flat?: boolean;
  42089. updatable?: boolean;
  42090. sideOrientation?: number;
  42091. frontUVs?: Vector4;
  42092. backUVs?: Vector4;
  42093. }, scene?: Nullable<Scene>): Mesh;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Gizmo that enables scaling a mesh along 3 axis
  42099. */
  42100. export class ScaleGizmo extends Gizmo {
  42101. /**
  42102. * Internal gizmo used for interactions on the x axis
  42103. */
  42104. xGizmo: AxisScaleGizmo;
  42105. /**
  42106. * Internal gizmo used for interactions on the y axis
  42107. */
  42108. yGizmo: AxisScaleGizmo;
  42109. /**
  42110. * Internal gizmo used for interactions on the z axis
  42111. */
  42112. zGizmo: AxisScaleGizmo;
  42113. /**
  42114. * Internal gizmo used to scale all axis equally
  42115. */
  42116. uniformScaleGizmo: AxisScaleGizmo;
  42117. /** Fires an event when any of it's sub gizmos are dragged */
  42118. onDragStartObservable: Observable<{}>;
  42119. /** Fires an event when any of it's sub gizmos are released from dragging */
  42120. onDragEndObservable: Observable<{}>;
  42121. attachedMesh: Nullable<AbstractMesh>;
  42122. /**
  42123. * Creates a ScaleGizmo
  42124. * @param gizmoLayer The utility layer the gizmo will be added to
  42125. */
  42126. constructor(gizmoLayer?: UtilityLayerRenderer);
  42127. updateGizmoRotationToMatchAttachedMesh: boolean;
  42128. /**
  42129. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42130. */
  42131. snapDistance: number;
  42132. /**
  42133. * Ratio for the scale of the gizmo (Default: 1)
  42134. */
  42135. scaleRatio: number;
  42136. /**
  42137. * Disposes of the gizmo
  42138. */
  42139. dispose(): void;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42145. */
  42146. export class GizmoManager implements IDisposable {
  42147. private scene;
  42148. /**
  42149. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42150. */
  42151. gizmos: {
  42152. positionGizmo: Nullable<PositionGizmo>;
  42153. rotationGizmo: Nullable<RotationGizmo>;
  42154. scaleGizmo: Nullable<ScaleGizmo>;
  42155. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42156. };
  42157. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42158. clearGizmoOnEmptyPointerEvent: boolean;
  42159. /** Fires an event when the manager is attached to a mesh */
  42160. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42161. private _gizmosEnabled;
  42162. private _pointerObserver;
  42163. private _attachedMesh;
  42164. private _boundingBoxColor;
  42165. private _defaultUtilityLayer;
  42166. private _defaultKeepDepthUtilityLayer;
  42167. /**
  42168. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42169. */
  42170. boundingBoxDragBehavior: SixDofDragBehavior;
  42171. /**
  42172. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42173. */
  42174. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42175. /**
  42176. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42177. */
  42178. usePointerToAttachGizmos: boolean;
  42179. /**
  42180. * Instatiates a gizmo manager
  42181. * @param scene the scene to overlay the gizmos on top of
  42182. */
  42183. constructor(scene: Scene);
  42184. /**
  42185. * Attaches a set of gizmos to the specified mesh
  42186. * @param mesh The mesh the gizmo's should be attached to
  42187. */
  42188. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42189. /**
  42190. * If the position gizmo is enabled
  42191. */
  42192. positionGizmoEnabled: boolean;
  42193. /**
  42194. * If the rotation gizmo is enabled
  42195. */
  42196. rotationGizmoEnabled: boolean;
  42197. /**
  42198. * If the scale gizmo is enabled
  42199. */
  42200. scaleGizmoEnabled: boolean;
  42201. /**
  42202. * If the boundingBox gizmo is enabled
  42203. */
  42204. boundingBoxGizmoEnabled: boolean;
  42205. /**
  42206. * Disposes of the gizmo manager
  42207. */
  42208. dispose(): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * A directional light is defined by a direction (what a surprise!).
  42214. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42215. * 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.
  42216. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42217. */
  42218. export class DirectionalLight extends ShadowLight {
  42219. private _shadowFrustumSize;
  42220. /**
  42221. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42222. */
  42223. /**
  42224. * Specifies a fix frustum size for the shadow generation.
  42225. */
  42226. shadowFrustumSize: number;
  42227. private _shadowOrthoScale;
  42228. /**
  42229. * Gets the shadow projection scale against the optimal computed one.
  42230. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42231. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42232. */
  42233. /**
  42234. * Sets the shadow projection scale against the optimal computed one.
  42235. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42236. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42237. */
  42238. shadowOrthoScale: number;
  42239. /**
  42240. * Automatically compute the projection matrix to best fit (including all the casters)
  42241. * on each frame.
  42242. */
  42243. autoUpdateExtends: boolean;
  42244. private _orthoLeft;
  42245. private _orthoRight;
  42246. private _orthoTop;
  42247. private _orthoBottom;
  42248. /**
  42249. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42250. * The directional light is emitted from everywhere in the given direction.
  42251. * It can cast shadows.
  42252. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42253. * @param name The friendly name of the light
  42254. * @param direction The direction of the light
  42255. * @param scene The scene the light belongs to
  42256. */
  42257. constructor(name: string, direction: Vector3, scene: Scene);
  42258. /**
  42259. * Returns the string "DirectionalLight".
  42260. * @return The class name
  42261. */
  42262. getClassName(): string;
  42263. /**
  42264. * Returns the integer 1.
  42265. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42266. */
  42267. getTypeID(): number;
  42268. /**
  42269. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42270. * Returns the DirectionalLight Shadow projection matrix.
  42271. */
  42272. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42273. /**
  42274. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42275. * Returns the DirectionalLight Shadow projection matrix.
  42276. */
  42277. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42278. /**
  42279. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42280. * Returns the DirectionalLight Shadow projection matrix.
  42281. */
  42282. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42283. protected _buildUniformLayout(): void;
  42284. /**
  42285. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42286. * @param effect The effect to update
  42287. * @param lightIndex The index of the light in the effect to update
  42288. * @returns The directional light
  42289. */
  42290. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42291. /**
  42292. * Gets the minZ used for shadow according to both the scene and the light.
  42293. *
  42294. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42295. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42296. * @param activeCamera The camera we are returning the min for
  42297. * @returns the depth min z
  42298. */
  42299. getDepthMinZ(activeCamera: Camera): number;
  42300. /**
  42301. * Gets the maxZ used for shadow according to both the scene and the light.
  42302. *
  42303. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42304. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42305. * @param activeCamera The camera we are returning the max for
  42306. * @returns the depth max z
  42307. */
  42308. getDepthMaxZ(activeCamera: Camera): number;
  42309. /**
  42310. * Prepares the list of defines specific to the light type.
  42311. * @param defines the list of defines
  42312. * @param lightIndex defines the index of the light for the effect
  42313. */
  42314. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42315. }
  42316. }
  42317. declare module BABYLON {
  42318. /**
  42319. * Class containing static functions to help procedurally build meshes
  42320. */
  42321. export class HemisphereBuilder {
  42322. /**
  42323. * Creates a hemisphere mesh
  42324. * @param name defines the name of the mesh
  42325. * @param options defines the options used to create the mesh
  42326. * @param scene defines the hosting scene
  42327. * @returns the hemisphere mesh
  42328. */
  42329. static CreateHemisphere(name: string, options: {
  42330. segments?: number;
  42331. diameter?: number;
  42332. sideOrientation?: number;
  42333. }, scene: any): Mesh;
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42339. * These values define a cone of light starting from the position, emitting toward the direction.
  42340. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42341. * and the exponent defines the speed of the decay of the light with distance (reach).
  42342. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42343. */
  42344. export class SpotLight extends ShadowLight {
  42345. private _angle;
  42346. private _innerAngle;
  42347. private _cosHalfAngle;
  42348. private _lightAngleScale;
  42349. private _lightAngleOffset;
  42350. /**
  42351. * Gets the cone angle of the spot light in Radians.
  42352. */
  42353. /**
  42354. * Sets the cone angle of the spot light in Radians.
  42355. */
  42356. angle: number;
  42357. /**
  42358. * Only used in gltf falloff mode, this defines the angle where
  42359. * the directional falloff will start before cutting at angle which could be seen
  42360. * as outer angle.
  42361. */
  42362. /**
  42363. * Only used in gltf falloff mode, this defines the angle where
  42364. * the directional falloff will start before cutting at angle which could be seen
  42365. * as outer angle.
  42366. */
  42367. innerAngle: number;
  42368. private _shadowAngleScale;
  42369. /**
  42370. * Allows scaling the angle of the light for shadow generation only.
  42371. */
  42372. /**
  42373. * Allows scaling the angle of the light for shadow generation only.
  42374. */
  42375. shadowAngleScale: number;
  42376. /**
  42377. * The light decay speed with the distance from the emission spot.
  42378. */
  42379. exponent: number;
  42380. private _projectionTextureMatrix;
  42381. /**
  42382. * Allows reading the projecton texture
  42383. */
  42384. readonly projectionTextureMatrix: Matrix;
  42385. protected _projectionTextureLightNear: number;
  42386. /**
  42387. * Gets the near clip of the Spotlight for texture projection.
  42388. */
  42389. /**
  42390. * Sets the near clip of the Spotlight for texture projection.
  42391. */
  42392. projectionTextureLightNear: number;
  42393. protected _projectionTextureLightFar: number;
  42394. /**
  42395. * Gets the far clip of the Spotlight for texture projection.
  42396. */
  42397. /**
  42398. * Sets the far clip of the Spotlight for texture projection.
  42399. */
  42400. projectionTextureLightFar: number;
  42401. protected _projectionTextureUpDirection: Vector3;
  42402. /**
  42403. * Gets the Up vector of the Spotlight for texture projection.
  42404. */
  42405. /**
  42406. * Sets the Up vector of the Spotlight for texture projection.
  42407. */
  42408. projectionTextureUpDirection: Vector3;
  42409. private _projectionTexture;
  42410. /**
  42411. * Gets the projection texture of the light.
  42412. */
  42413. /**
  42414. * Sets the projection texture of the light.
  42415. */
  42416. projectionTexture: Nullable<BaseTexture>;
  42417. private _projectionTextureViewLightDirty;
  42418. private _projectionTextureProjectionLightDirty;
  42419. private _projectionTextureDirty;
  42420. private _projectionTextureViewTargetVector;
  42421. private _projectionTextureViewLightMatrix;
  42422. private _projectionTextureProjectionLightMatrix;
  42423. private _projectionTextureScalingMatrix;
  42424. /**
  42425. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42426. * It can cast shadows.
  42427. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42428. * @param name The light friendly name
  42429. * @param position The position of the spot light in the scene
  42430. * @param direction The direction of the light in the scene
  42431. * @param angle The cone angle of the light in Radians
  42432. * @param exponent The light decay speed with the distance from the emission spot
  42433. * @param scene The scene the lights belongs to
  42434. */
  42435. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42436. /**
  42437. * Returns the string "SpotLight".
  42438. * @returns the class name
  42439. */
  42440. getClassName(): string;
  42441. /**
  42442. * Returns the integer 2.
  42443. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42444. */
  42445. getTypeID(): number;
  42446. /**
  42447. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42448. */
  42449. protected _setDirection(value: Vector3): void;
  42450. /**
  42451. * Overrides the position setter to recompute the projection texture view light Matrix.
  42452. */
  42453. protected _setPosition(value: Vector3): void;
  42454. /**
  42455. * 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.
  42456. * Returns the SpotLight.
  42457. */
  42458. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42459. protected _computeProjectionTextureViewLightMatrix(): void;
  42460. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42461. /**
  42462. * Main function for light texture projection matrix computing.
  42463. */
  42464. protected _computeProjectionTextureMatrix(): void;
  42465. protected _buildUniformLayout(): void;
  42466. private _computeAngleValues;
  42467. /**
  42468. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42469. * @param effect The effect to update
  42470. * @param lightIndex The index of the light in the effect to update
  42471. * @returns The spot light
  42472. */
  42473. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42474. /**
  42475. * Disposes the light and the associated resources.
  42476. */
  42477. dispose(): void;
  42478. /**
  42479. * Prepares the list of defines specific to the light type.
  42480. * @param defines the list of defines
  42481. * @param lightIndex defines the index of the light for the effect
  42482. */
  42483. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42484. }
  42485. }
  42486. declare module BABYLON {
  42487. /**
  42488. * Gizmo that enables viewing a light
  42489. */
  42490. export class LightGizmo extends Gizmo {
  42491. private _lightMesh;
  42492. private _material;
  42493. /**
  42494. * Creates a LightGizmo
  42495. * @param gizmoLayer The utility layer the gizmo will be added to
  42496. */
  42497. constructor(gizmoLayer?: UtilityLayerRenderer);
  42498. private _light;
  42499. /**
  42500. * The light that the gizmo is attached to
  42501. */
  42502. light: Nullable<Light>;
  42503. /**
  42504. * @hidden
  42505. * Updates the gizmo to match the attached mesh's position/rotation
  42506. */
  42507. protected _update(): void;
  42508. private static _Scale;
  42509. /**
  42510. * Creates the lines for a light mesh
  42511. */
  42512. private static _createLightLines;
  42513. private static _CreateHemisphericLightMesh;
  42514. private static _CreatePointLightMesh;
  42515. private static _CreateSpotLightMesh;
  42516. private static _CreateDirectionalLightMesh;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /** @hidden */
  42521. export var backgroundFragmentDeclaration: {
  42522. name: string;
  42523. shader: string;
  42524. };
  42525. }
  42526. declare module BABYLON {
  42527. /** @hidden */
  42528. export var backgroundUboDeclaration: {
  42529. name: string;
  42530. shader: string;
  42531. };
  42532. }
  42533. declare module BABYLON {
  42534. /** @hidden */
  42535. export var backgroundPixelShader: {
  42536. name: string;
  42537. shader: string;
  42538. };
  42539. }
  42540. declare module BABYLON {
  42541. /** @hidden */
  42542. export var backgroundVertexDeclaration: {
  42543. name: string;
  42544. shader: string;
  42545. };
  42546. }
  42547. declare module BABYLON {
  42548. /** @hidden */
  42549. export var backgroundVertexShader: {
  42550. name: string;
  42551. shader: string;
  42552. };
  42553. }
  42554. declare module BABYLON {
  42555. /**
  42556. * Background material used to create an efficient environement around your scene.
  42557. */
  42558. export class BackgroundMaterial extends PushMaterial {
  42559. /**
  42560. * Standard reflectance value at parallel view angle.
  42561. */
  42562. static StandardReflectance0: number;
  42563. /**
  42564. * Standard reflectance value at grazing angle.
  42565. */
  42566. static StandardReflectance90: number;
  42567. protected _primaryColor: Color3;
  42568. /**
  42569. * Key light Color (multiply against the environement texture)
  42570. */
  42571. primaryColor: Color3;
  42572. protected __perceptualColor: Nullable<Color3>;
  42573. /**
  42574. * Experimental Internal Use Only.
  42575. *
  42576. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42577. * This acts as a helper to set the primary color to a more "human friendly" value.
  42578. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42579. * output color as close as possible from the chosen value.
  42580. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42581. * part of lighting setup.)
  42582. */ perceptualColor: Nullable<Color3>;
  42583. protected _primaryColorShadowLevel: float;
  42584. /**
  42585. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42586. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42587. */
  42588. primaryColorShadowLevel: float;
  42589. protected _primaryColorHighlightLevel: float;
  42590. /**
  42591. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42592. * The primary color is used at the level chosen to define what the white area would look.
  42593. */
  42594. primaryColorHighlightLevel: float;
  42595. protected _reflectionTexture: Nullable<BaseTexture>;
  42596. /**
  42597. * Reflection Texture used in the material.
  42598. * Should be author in a specific way for the best result (refer to the documentation).
  42599. */
  42600. reflectionTexture: Nullable<BaseTexture>;
  42601. protected _reflectionBlur: float;
  42602. /**
  42603. * Reflection Texture level of blur.
  42604. *
  42605. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42606. * texture twice.
  42607. */
  42608. reflectionBlur: float;
  42609. protected _diffuseTexture: Nullable<BaseTexture>;
  42610. /**
  42611. * Diffuse Texture used in the material.
  42612. * Should be author in a specific way for the best result (refer to the documentation).
  42613. */
  42614. diffuseTexture: Nullable<BaseTexture>;
  42615. protected _shadowLights: Nullable<IShadowLight[]>;
  42616. /**
  42617. * Specify the list of lights casting shadow on the material.
  42618. * All scene shadow lights will be included if null.
  42619. */
  42620. shadowLights: Nullable<IShadowLight[]>;
  42621. protected _shadowLevel: float;
  42622. /**
  42623. * Helps adjusting the shadow to a softer level if required.
  42624. * 0 means black shadows and 1 means no shadows.
  42625. */
  42626. shadowLevel: float;
  42627. protected _sceneCenter: Vector3;
  42628. /**
  42629. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42630. * It is usually zero but might be interesting to modify according to your setup.
  42631. */
  42632. sceneCenter: Vector3;
  42633. protected _opacityFresnel: boolean;
  42634. /**
  42635. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42636. * This helps ensuring a nice transition when the camera goes under the ground.
  42637. */
  42638. opacityFresnel: boolean;
  42639. protected _reflectionFresnel: boolean;
  42640. /**
  42641. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42642. * This helps adding a mirror texture on the ground.
  42643. */
  42644. reflectionFresnel: boolean;
  42645. protected _reflectionFalloffDistance: number;
  42646. /**
  42647. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42648. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42649. */
  42650. reflectionFalloffDistance: number;
  42651. protected _reflectionAmount: number;
  42652. /**
  42653. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42654. */
  42655. reflectionAmount: number;
  42656. protected _reflectionReflectance0: number;
  42657. /**
  42658. * This specifies the weight of the reflection at grazing angle.
  42659. */
  42660. reflectionReflectance0: number;
  42661. protected _reflectionReflectance90: number;
  42662. /**
  42663. * This specifies the weight of the reflection at a perpendicular point of view.
  42664. */
  42665. reflectionReflectance90: number;
  42666. /**
  42667. * Sets the reflection reflectance fresnel values according to the default standard
  42668. * empirically know to work well :-)
  42669. */
  42670. reflectionStandardFresnelWeight: number;
  42671. protected _useRGBColor: boolean;
  42672. /**
  42673. * Helps to directly use the maps channels instead of their level.
  42674. */
  42675. useRGBColor: boolean;
  42676. protected _enableNoise: boolean;
  42677. /**
  42678. * This helps reducing the banding effect that could occur on the background.
  42679. */
  42680. enableNoise: boolean;
  42681. /**
  42682. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42683. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42684. * Recommended to be keep at 1.0 except for special cases.
  42685. */
  42686. fovMultiplier: number;
  42687. private _fovMultiplier;
  42688. /**
  42689. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42690. */
  42691. useEquirectangularFOV: boolean;
  42692. private _maxSimultaneousLights;
  42693. /**
  42694. * Number of Simultaneous lights allowed on the material.
  42695. */
  42696. maxSimultaneousLights: int;
  42697. /**
  42698. * Default configuration related to image processing available in the Background Material.
  42699. */
  42700. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42701. /**
  42702. * Keep track of the image processing observer to allow dispose and replace.
  42703. */
  42704. private _imageProcessingObserver;
  42705. /**
  42706. * Attaches a new image processing configuration to the PBR Material.
  42707. * @param configuration (if null the scene configuration will be use)
  42708. */
  42709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42710. /**
  42711. * Gets the image processing configuration used either in this material.
  42712. */
  42713. /**
  42714. * Sets the Default image processing configuration used either in the this material.
  42715. *
  42716. * If sets to null, the scene one is in use.
  42717. */
  42718. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42719. /**
  42720. * Gets wether the color curves effect is enabled.
  42721. */
  42722. /**
  42723. * Sets wether the color curves effect is enabled.
  42724. */
  42725. cameraColorCurvesEnabled: boolean;
  42726. /**
  42727. * Gets wether the color grading effect is enabled.
  42728. */
  42729. /**
  42730. * Gets wether the color grading effect is enabled.
  42731. */
  42732. cameraColorGradingEnabled: boolean;
  42733. /**
  42734. * Gets wether tonemapping is enabled or not.
  42735. */
  42736. /**
  42737. * Sets wether tonemapping is enabled or not
  42738. */
  42739. cameraToneMappingEnabled: boolean;
  42740. /**
  42741. * The camera exposure used on this material.
  42742. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42743. * This corresponds to a photographic exposure.
  42744. */
  42745. /**
  42746. * The camera exposure used on this material.
  42747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42748. * This corresponds to a photographic exposure.
  42749. */
  42750. cameraExposure: float;
  42751. /**
  42752. * Gets The camera contrast used on this material.
  42753. */
  42754. /**
  42755. * Sets The camera contrast used on this material.
  42756. */
  42757. cameraContrast: float;
  42758. /**
  42759. * Gets the Color Grading 2D Lookup Texture.
  42760. */
  42761. /**
  42762. * Sets the Color Grading 2D Lookup Texture.
  42763. */
  42764. cameraColorGradingTexture: Nullable<BaseTexture>;
  42765. /**
  42766. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42767. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42768. * 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;
  42769. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42770. */
  42771. /**
  42772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42774. * 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;
  42775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42776. */
  42777. cameraColorCurves: Nullable<ColorCurves>;
  42778. /**
  42779. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42780. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42781. */
  42782. switchToBGR: boolean;
  42783. private _renderTargets;
  42784. private _reflectionControls;
  42785. private _white;
  42786. private _primaryShadowColor;
  42787. private _primaryHighlightColor;
  42788. /**
  42789. * Instantiates a Background Material in the given scene
  42790. * @param name The friendly name of the material
  42791. * @param scene The scene to add the material to
  42792. */
  42793. constructor(name: string, scene: Scene);
  42794. /**
  42795. * Gets a boolean indicating that current material needs to register RTT
  42796. */
  42797. readonly hasRenderTargetTextures: boolean;
  42798. /**
  42799. * The entire material has been created in order to prevent overdraw.
  42800. * @returns false
  42801. */
  42802. needAlphaTesting(): boolean;
  42803. /**
  42804. * The entire material has been created in order to prevent overdraw.
  42805. * @returns true if blending is enable
  42806. */
  42807. needAlphaBlending(): boolean;
  42808. /**
  42809. * Checks wether the material is ready to be rendered for a given mesh.
  42810. * @param mesh The mesh to render
  42811. * @param subMesh The submesh to check against
  42812. * @param useInstances Specify wether or not the material is used with instances
  42813. * @returns true if all the dependencies are ready (Textures, Effects...)
  42814. */
  42815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42816. /**
  42817. * Compute the primary color according to the chosen perceptual color.
  42818. */
  42819. private _computePrimaryColorFromPerceptualColor;
  42820. /**
  42821. * Compute the highlights and shadow colors according to their chosen levels.
  42822. */
  42823. private _computePrimaryColors;
  42824. /**
  42825. * Build the uniform buffer used in the material.
  42826. */
  42827. buildUniformLayout(): void;
  42828. /**
  42829. * Unbind the material.
  42830. */
  42831. unbind(): void;
  42832. /**
  42833. * Bind only the world matrix to the material.
  42834. * @param world The world matrix to bind.
  42835. */
  42836. bindOnlyWorldMatrix(world: Matrix): void;
  42837. /**
  42838. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42839. * @param world The world matrix to bind.
  42840. * @param subMesh The submesh to bind for.
  42841. */
  42842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42843. /**
  42844. * Dispose the material.
  42845. * @param forceDisposeEffect Force disposal of the associated effect.
  42846. * @param forceDisposeTextures Force disposal of the associated textures.
  42847. */
  42848. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42849. /**
  42850. * Clones the material.
  42851. * @param name The cloned name.
  42852. * @returns The cloned material.
  42853. */
  42854. clone(name: string): BackgroundMaterial;
  42855. /**
  42856. * Serializes the current material to its JSON representation.
  42857. * @returns The JSON representation.
  42858. */
  42859. serialize(): any;
  42860. /**
  42861. * Gets the class name of the material
  42862. * @returns "BackgroundMaterial"
  42863. */
  42864. getClassName(): string;
  42865. /**
  42866. * Parse a JSON input to create back a background material.
  42867. * @param source The JSON data to parse
  42868. * @param scene The scene to create the parsed material in
  42869. * @param rootUrl The root url of the assets the material depends upon
  42870. * @returns the instantiated BackgroundMaterial.
  42871. */
  42872. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42873. }
  42874. }
  42875. declare module BABYLON {
  42876. /**
  42877. * Represents the different options available during the creation of
  42878. * a Environment helper.
  42879. *
  42880. * This can control the default ground, skybox and image processing setup of your scene.
  42881. */
  42882. export interface IEnvironmentHelperOptions {
  42883. /**
  42884. * Specifies wether or not to create a ground.
  42885. * True by default.
  42886. */
  42887. createGround: boolean;
  42888. /**
  42889. * Specifies the ground size.
  42890. * 15 by default.
  42891. */
  42892. groundSize: number;
  42893. /**
  42894. * The texture used on the ground for the main color.
  42895. * Comes from the BabylonJS CDN by default.
  42896. *
  42897. * Remarks: Can be either a texture or a url.
  42898. */
  42899. groundTexture: string | BaseTexture;
  42900. /**
  42901. * The color mixed in the ground texture by default.
  42902. * BabylonJS clearColor by default.
  42903. */
  42904. groundColor: Color3;
  42905. /**
  42906. * Specifies the ground opacity.
  42907. * 1 by default.
  42908. */
  42909. groundOpacity: number;
  42910. /**
  42911. * Enables the ground to receive shadows.
  42912. * True by default.
  42913. */
  42914. enableGroundShadow: boolean;
  42915. /**
  42916. * Helps preventing the shadow to be fully black on the ground.
  42917. * 0.5 by default.
  42918. */
  42919. groundShadowLevel: number;
  42920. /**
  42921. * Creates a mirror texture attach to the ground.
  42922. * false by default.
  42923. */
  42924. enableGroundMirror: boolean;
  42925. /**
  42926. * Specifies the ground mirror size ratio.
  42927. * 0.3 by default as the default kernel is 64.
  42928. */
  42929. groundMirrorSizeRatio: number;
  42930. /**
  42931. * Specifies the ground mirror blur kernel size.
  42932. * 64 by default.
  42933. */
  42934. groundMirrorBlurKernel: number;
  42935. /**
  42936. * Specifies the ground mirror visibility amount.
  42937. * 1 by default
  42938. */
  42939. groundMirrorAmount: number;
  42940. /**
  42941. * Specifies the ground mirror reflectance weight.
  42942. * This uses the standard weight of the background material to setup the fresnel effect
  42943. * of the mirror.
  42944. * 1 by default.
  42945. */
  42946. groundMirrorFresnelWeight: number;
  42947. /**
  42948. * Specifies the ground mirror Falloff distance.
  42949. * This can helps reducing the size of the reflection.
  42950. * 0 by Default.
  42951. */
  42952. groundMirrorFallOffDistance: number;
  42953. /**
  42954. * Specifies the ground mirror texture type.
  42955. * Unsigned Int by Default.
  42956. */
  42957. groundMirrorTextureType: number;
  42958. /**
  42959. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42960. * the shown objects.
  42961. */
  42962. groundYBias: number;
  42963. /**
  42964. * Specifies wether or not to create a skybox.
  42965. * True by default.
  42966. */
  42967. createSkybox: boolean;
  42968. /**
  42969. * Specifies the skybox size.
  42970. * 20 by default.
  42971. */
  42972. skyboxSize: number;
  42973. /**
  42974. * The texture used on the skybox for the main color.
  42975. * Comes from the BabylonJS CDN by default.
  42976. *
  42977. * Remarks: Can be either a texture or a url.
  42978. */
  42979. skyboxTexture: string | BaseTexture;
  42980. /**
  42981. * The color mixed in the skybox texture by default.
  42982. * BabylonJS clearColor by default.
  42983. */
  42984. skyboxColor: Color3;
  42985. /**
  42986. * The background rotation around the Y axis of the scene.
  42987. * This helps aligning the key lights of your scene with the background.
  42988. * 0 by default.
  42989. */
  42990. backgroundYRotation: number;
  42991. /**
  42992. * Compute automatically the size of the elements to best fit with the scene.
  42993. */
  42994. sizeAuto: boolean;
  42995. /**
  42996. * Default position of the rootMesh if autoSize is not true.
  42997. */
  42998. rootPosition: Vector3;
  42999. /**
  43000. * Sets up the image processing in the scene.
  43001. * true by default.
  43002. */
  43003. setupImageProcessing: boolean;
  43004. /**
  43005. * The texture used as your environment texture in the scene.
  43006. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43007. *
  43008. * Remarks: Can be either a texture or a url.
  43009. */
  43010. environmentTexture: string | BaseTexture;
  43011. /**
  43012. * The value of the exposure to apply to the scene.
  43013. * 0.6 by default if setupImageProcessing is true.
  43014. */
  43015. cameraExposure: number;
  43016. /**
  43017. * The value of the contrast to apply to the scene.
  43018. * 1.6 by default if setupImageProcessing is true.
  43019. */
  43020. cameraContrast: number;
  43021. /**
  43022. * Specifies wether or not tonemapping should be enabled in the scene.
  43023. * true by default if setupImageProcessing is true.
  43024. */
  43025. toneMappingEnabled: boolean;
  43026. }
  43027. /**
  43028. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43029. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43030. * It also helps with the default setup of your imageProcessing configuration.
  43031. */
  43032. export class EnvironmentHelper {
  43033. /**
  43034. * Default ground texture URL.
  43035. */
  43036. private static _groundTextureCDNUrl;
  43037. /**
  43038. * Default skybox texture URL.
  43039. */
  43040. private static _skyboxTextureCDNUrl;
  43041. /**
  43042. * Default environment texture URL.
  43043. */
  43044. private static _environmentTextureCDNUrl;
  43045. /**
  43046. * Creates the default options for the helper.
  43047. */
  43048. private static _getDefaultOptions;
  43049. private _rootMesh;
  43050. /**
  43051. * Gets the root mesh created by the helper.
  43052. */
  43053. readonly rootMesh: Mesh;
  43054. private _skybox;
  43055. /**
  43056. * Gets the skybox created by the helper.
  43057. */
  43058. readonly skybox: Nullable<Mesh>;
  43059. private _skyboxTexture;
  43060. /**
  43061. * Gets the skybox texture created by the helper.
  43062. */
  43063. readonly skyboxTexture: Nullable<BaseTexture>;
  43064. private _skyboxMaterial;
  43065. /**
  43066. * Gets the skybox material created by the helper.
  43067. */
  43068. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43069. private _ground;
  43070. /**
  43071. * Gets the ground mesh created by the helper.
  43072. */
  43073. readonly ground: Nullable<Mesh>;
  43074. private _groundTexture;
  43075. /**
  43076. * Gets the ground texture created by the helper.
  43077. */
  43078. readonly groundTexture: Nullable<BaseTexture>;
  43079. private _groundMirror;
  43080. /**
  43081. * Gets the ground mirror created by the helper.
  43082. */
  43083. readonly groundMirror: Nullable<MirrorTexture>;
  43084. /**
  43085. * Gets the ground mirror render list to helps pushing the meshes
  43086. * you wish in the ground reflection.
  43087. */
  43088. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43089. private _groundMaterial;
  43090. /**
  43091. * Gets the ground material created by the helper.
  43092. */
  43093. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43094. /**
  43095. * Stores the creation options.
  43096. */
  43097. private readonly _scene;
  43098. private _options;
  43099. /**
  43100. * This observable will be notified with any error during the creation of the environment,
  43101. * mainly texture creation errors.
  43102. */
  43103. onErrorObservable: Observable<{
  43104. message?: string;
  43105. exception?: any;
  43106. }>;
  43107. /**
  43108. * constructor
  43109. * @param options Defines the options we want to customize the helper
  43110. * @param scene The scene to add the material to
  43111. */
  43112. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43113. /**
  43114. * Updates the background according to the new options
  43115. * @param options
  43116. */
  43117. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43118. /**
  43119. * Sets the primary color of all the available elements.
  43120. * @param color the main color to affect to the ground and the background
  43121. */
  43122. setMainColor(color: Color3): void;
  43123. /**
  43124. * Setup the image processing according to the specified options.
  43125. */
  43126. private _setupImageProcessing;
  43127. /**
  43128. * Setup the environment texture according to the specified options.
  43129. */
  43130. private _setupEnvironmentTexture;
  43131. /**
  43132. * Setup the background according to the specified options.
  43133. */
  43134. private _setupBackground;
  43135. /**
  43136. * Get the scene sizes according to the setup.
  43137. */
  43138. private _getSceneSize;
  43139. /**
  43140. * Setup the ground according to the specified options.
  43141. */
  43142. private _setupGround;
  43143. /**
  43144. * Setup the ground material according to the specified options.
  43145. */
  43146. private _setupGroundMaterial;
  43147. /**
  43148. * Setup the ground diffuse texture according to the specified options.
  43149. */
  43150. private _setupGroundDiffuseTexture;
  43151. /**
  43152. * Setup the ground mirror texture according to the specified options.
  43153. */
  43154. private _setupGroundMirrorTexture;
  43155. /**
  43156. * Setup the ground to receive the mirror texture.
  43157. */
  43158. private _setupMirrorInGroundMaterial;
  43159. /**
  43160. * Setup the skybox according to the specified options.
  43161. */
  43162. private _setupSkybox;
  43163. /**
  43164. * Setup the skybox material according to the specified options.
  43165. */
  43166. private _setupSkyboxMaterial;
  43167. /**
  43168. * Setup the skybox reflection texture according to the specified options.
  43169. */
  43170. private _setupSkyboxReflectionTexture;
  43171. private _errorHandler;
  43172. /**
  43173. * Dispose all the elements created by the Helper.
  43174. */
  43175. dispose(): void;
  43176. }
  43177. }
  43178. declare module BABYLON {
  43179. /**
  43180. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43181. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43182. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43183. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43184. */
  43185. export class PhotoDome extends TransformNode {
  43186. private _useDirectMapping;
  43187. /**
  43188. * The texture being displayed on the sphere
  43189. */
  43190. protected _photoTexture: Texture;
  43191. /**
  43192. * Gets or sets the texture being displayed on the sphere
  43193. */
  43194. photoTexture: Texture;
  43195. /**
  43196. * Observable raised when an error occured while loading the 360 image
  43197. */
  43198. onLoadErrorObservable: Observable<string>;
  43199. /**
  43200. * The skybox material
  43201. */
  43202. protected _material: BackgroundMaterial;
  43203. /**
  43204. * The surface used for the skybox
  43205. */
  43206. protected _mesh: Mesh;
  43207. /**
  43208. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43209. * Also see the options.resolution property.
  43210. */
  43211. fovMultiplier: number;
  43212. /**
  43213. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43214. * @param name Element's name, child elements will append suffixes for their own names.
  43215. * @param urlsOfPhoto defines the url of the photo to display
  43216. * @param options defines an object containing optional or exposed sub element properties
  43217. * @param onError defines a callback called when an error occured while loading the texture
  43218. */
  43219. constructor(name: string, urlOfPhoto: string, options: {
  43220. resolution?: number;
  43221. size?: number;
  43222. useDirectMapping?: boolean;
  43223. faceForward?: boolean;
  43224. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43225. /**
  43226. * Releases resources associated with this node.
  43227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43229. */
  43230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43231. }
  43232. }
  43233. declare module BABYLON {
  43234. /** @hidden */
  43235. export var rgbdDecodePixelShader: {
  43236. name: string;
  43237. shader: string;
  43238. };
  43239. }
  43240. declare module BABYLON {
  43241. /**
  43242. * Class used to host texture specific utilities
  43243. */
  43244. export class BRDFTextureTools {
  43245. /**
  43246. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43247. * @param texture the texture to expand.
  43248. */
  43249. private static _ExpandDefaultBRDFTexture;
  43250. /**
  43251. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43252. * @param scene defines the hosting scene
  43253. * @returns the environment BRDF texture
  43254. */
  43255. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43256. private static _environmentBRDFBase64Texture;
  43257. }
  43258. }
  43259. declare module BABYLON {
  43260. /**
  43261. * @hidden
  43262. */
  43263. export interface IMaterialClearCoatDefines {
  43264. CLEARCOAT: boolean;
  43265. CLEARCOAT_DEFAULTIOR: boolean;
  43266. CLEARCOAT_TEXTURE: boolean;
  43267. CLEARCOAT_TEXTUREDIRECTUV: number;
  43268. CLEARCOAT_BUMP: boolean;
  43269. CLEARCOAT_BUMPDIRECTUV: number;
  43270. CLEARCOAT_TINT: boolean;
  43271. CLEARCOAT_TINT_TEXTURE: boolean;
  43272. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43273. /** @hidden */ areTexturesDirty: boolean;
  43274. }
  43275. /**
  43276. * Define the code related to the clear coat parameters of the pbr material.
  43277. */
  43278. export class PBRClearCoatConfiguration {
  43279. /**
  43280. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43281. * The default fits with a polyurethane material.
  43282. */
  43283. private static readonly _DefaultIndiceOfRefraction;
  43284. private _isEnabled;
  43285. /**
  43286. * Defines if the clear coat is enabled in the material.
  43287. */
  43288. isEnabled: boolean;
  43289. /**
  43290. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43291. */
  43292. intensity: number;
  43293. /**
  43294. * Defines the clear coat layer roughness.
  43295. */
  43296. roughness: number;
  43297. private _indiceOfRefraction;
  43298. /**
  43299. * Defines the indice of refraction of the clear coat.
  43300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43301. * The default fits with a polyurethane material.
  43302. * Changing the default value is more performance intensive.
  43303. */
  43304. indiceOfRefraction: number;
  43305. private _texture;
  43306. /**
  43307. * Stores the clear coat values in a texture.
  43308. */
  43309. texture: Nullable<BaseTexture>;
  43310. private _bumpTexture;
  43311. /**
  43312. * Define the clear coat specific bump texture.
  43313. */
  43314. bumpTexture: Nullable<BaseTexture>;
  43315. private _isTintEnabled;
  43316. /**
  43317. * Defines if the clear coat tint is enabled in the material.
  43318. */
  43319. isTintEnabled: boolean;
  43320. /**
  43321. * Defines the clear coat tint of the material.
  43322. * This is only use if tint is enabled
  43323. */
  43324. tintColor: Color3;
  43325. /**
  43326. * Defines the distance at which the tint color should be found in the
  43327. * clear coat media.
  43328. * This is only use if tint is enabled
  43329. */
  43330. tintColorAtDistance: number;
  43331. /**
  43332. * Defines the clear coat layer thickness.
  43333. * This is only use if tint is enabled
  43334. */
  43335. tintThickness: number;
  43336. private _tintTexture;
  43337. /**
  43338. * Stores the clear tint values in a texture.
  43339. * rgb is tint
  43340. * a is a thickness factor
  43341. */
  43342. tintTexture: Nullable<BaseTexture>;
  43343. /** @hidden */
  43344. private _internalMarkAllSubMeshesAsTexturesDirty;
  43345. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43346. /**
  43347. * Instantiate a new istance of clear coat configuration.
  43348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43349. */
  43350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43351. /**
  43352. * Gets wehter the submesh is ready to be used or not.
  43353. * @param defines the list of "defines" to update.
  43354. * @param scene defines the scene the material belongs to.
  43355. * @param engine defines the engine the material belongs to.
  43356. * @param disableBumpMap defines wether the material disables bump or not.
  43357. * @returns - boolean indicating that the submesh is ready or not.
  43358. */
  43359. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43360. /**
  43361. * Checks to see if a texture is used in the material.
  43362. * @param defines the list of "defines" to update.
  43363. * @param scene defines the scene to the material belongs to.
  43364. */
  43365. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43366. /**
  43367. * Binds the material data.
  43368. * @param uniformBuffer defines the Uniform buffer to fill in.
  43369. * @param scene defines the scene the material belongs to.
  43370. * @param engine defines the engine the material belongs to.
  43371. * @param disableBumpMap defines wether the material disables bump or not.
  43372. * @param isFrozen defines wether the material is frozen or not.
  43373. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43374. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43375. */
  43376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43377. /**
  43378. * Checks to see if a texture is used in the material.
  43379. * @param texture - Base texture to use.
  43380. * @returns - Boolean specifying if a texture is used in the material.
  43381. */
  43382. hasTexture(texture: BaseTexture): boolean;
  43383. /**
  43384. * Returns an array of the actively used textures.
  43385. * @param activeTextures Array of BaseTextures
  43386. */
  43387. getActiveTextures(activeTextures: BaseTexture[]): void;
  43388. /**
  43389. * Returns the animatable textures.
  43390. * @param animatables Array of animatable textures.
  43391. */
  43392. getAnimatables(animatables: IAnimatable[]): void;
  43393. /**
  43394. * Disposes the resources of the material.
  43395. * @param forceDisposeTextures - Forces the disposal of all textures.
  43396. */
  43397. dispose(forceDisposeTextures?: boolean): void;
  43398. /**
  43399. * Get the current class name of the texture useful for serialization or dynamic coding.
  43400. * @returns "PBRClearCoatConfiguration"
  43401. */
  43402. getClassName(): string;
  43403. /**
  43404. * Add fallbacks to the effect fallbacks list.
  43405. * @param defines defines the Base texture to use.
  43406. * @param fallbacks defines the current fallback list.
  43407. * @param currentRank defines the current fallback rank.
  43408. * @returns the new fallback rank.
  43409. */
  43410. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43411. /**
  43412. * Add the required uniforms to the current list.
  43413. * @param uniforms defines the current uniform list.
  43414. */
  43415. static AddUniforms(uniforms: string[]): void;
  43416. /**
  43417. * Add the required samplers to the current list.
  43418. * @param samplers defines the current sampler list.
  43419. */
  43420. static AddSamplers(samplers: string[]): void;
  43421. /**
  43422. * Add the required uniforms to the current buffer.
  43423. * @param uniformBuffer defines the current uniform buffer.
  43424. */
  43425. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43426. /**
  43427. * Makes a duplicate of the current configuration into another one.
  43428. * @param clearCoatConfiguration define the config where to copy the info
  43429. */
  43430. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43431. /**
  43432. * Serializes this clear coat configuration.
  43433. * @returns - An object with the serialized config.
  43434. */
  43435. serialize(): any;
  43436. /**
  43437. * Parses a Clear Coat Configuration from a serialized object.
  43438. * @param source - Serialized object.
  43439. */
  43440. parse(source: any): void;
  43441. }
  43442. }
  43443. declare module BABYLON {
  43444. /**
  43445. * @hidden
  43446. */
  43447. export interface IMaterialAnisotropicDefines {
  43448. ANISOTROPIC: boolean;
  43449. ANISOTROPIC_TEXTURE: boolean;
  43450. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43451. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43452. }
  43453. /**
  43454. * Define the code related to the anisotropic parameters of the pbr material.
  43455. */
  43456. export class PBRAnisotropicConfiguration {
  43457. private _isEnabled;
  43458. /**
  43459. * Defines if the anisotropy is enabled in the material.
  43460. */
  43461. isEnabled: boolean;
  43462. /**
  43463. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43464. */
  43465. intensity: number;
  43466. /**
  43467. * Defines if the effect is along the tangents, bitangents or in between.
  43468. * By default, the effect is "strectching" the highlights along the tangents.
  43469. */
  43470. direction: Vector2;
  43471. private _texture;
  43472. /**
  43473. * Stores the anisotropy values in a texture.
  43474. * rg is direction (like normal from -1 to 1)
  43475. * b is a intensity
  43476. */
  43477. texture: Nullable<BaseTexture>;
  43478. /** @hidden */
  43479. private _internalMarkAllSubMeshesAsTexturesDirty;
  43480. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43481. /**
  43482. * Instantiate a new istance of anisotropy configuration.
  43483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43484. */
  43485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43486. /**
  43487. * Specifies that the submesh is ready to be used.
  43488. * @param defines the list of "defines" to update.
  43489. * @param scene defines the scene the material belongs to.
  43490. * @returns - boolean indicating that the submesh is ready or not.
  43491. */
  43492. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43493. /**
  43494. * Checks to see if a texture is used in the material.
  43495. * @param defines the list of "defines" to update.
  43496. * @param mesh the mesh we are preparing the defines for.
  43497. * @param scene defines the scene the material belongs to.
  43498. */
  43499. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43500. /**
  43501. * Binds the material data.
  43502. * @param uniformBuffer defines the Uniform buffer to fill in.
  43503. * @param scene defines the scene the material belongs to.
  43504. * @param isFrozen defines wether the material is frozen or not.
  43505. */
  43506. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43507. /**
  43508. * Checks to see if a texture is used in the material.
  43509. * @param texture - Base texture to use.
  43510. * @returns - Boolean specifying if a texture is used in the material.
  43511. */
  43512. hasTexture(texture: BaseTexture): boolean;
  43513. /**
  43514. * Returns an array of the actively used textures.
  43515. * @param activeTextures Array of BaseTextures
  43516. */
  43517. getActiveTextures(activeTextures: BaseTexture[]): void;
  43518. /**
  43519. * Returns the animatable textures.
  43520. * @param animatables Array of animatable textures.
  43521. */
  43522. getAnimatables(animatables: IAnimatable[]): void;
  43523. /**
  43524. * Disposes the resources of the material.
  43525. * @param forceDisposeTextures - Forces the disposal of all textures.
  43526. */
  43527. dispose(forceDisposeTextures?: boolean): void;
  43528. /**
  43529. * Get the current class name of the texture useful for serialization or dynamic coding.
  43530. * @returns "PBRAnisotropicConfiguration"
  43531. */
  43532. getClassName(): string;
  43533. /**
  43534. * Add fallbacks to the effect fallbacks list.
  43535. * @param defines defines the Base texture to use.
  43536. * @param fallbacks defines the current fallback list.
  43537. * @param currentRank defines the current fallback rank.
  43538. * @returns the new fallback rank.
  43539. */
  43540. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43541. /**
  43542. * Add the required uniforms to the current list.
  43543. * @param uniforms defines the current uniform list.
  43544. */
  43545. static AddUniforms(uniforms: string[]): void;
  43546. /**
  43547. * Add the required uniforms to the current buffer.
  43548. * @param uniformBuffer defines the current uniform buffer.
  43549. */
  43550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43551. /**
  43552. * Add the required samplers to the current list.
  43553. * @param samplers defines the current sampler list.
  43554. */
  43555. static AddSamplers(samplers: string[]): void;
  43556. /**
  43557. * Makes a duplicate of the current configuration into another one.
  43558. * @param anisotropicConfiguration define the config where to copy the info
  43559. */
  43560. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43561. /**
  43562. * Serializes this anisotropy configuration.
  43563. * @returns - An object with the serialized config.
  43564. */
  43565. serialize(): any;
  43566. /**
  43567. * Parses a anisotropy Configuration from a serialized object.
  43568. * @param source - Serialized object.
  43569. */
  43570. parse(source: any): void;
  43571. }
  43572. }
  43573. declare module BABYLON {
  43574. /**
  43575. * @hidden
  43576. */
  43577. export interface IMaterialBRDFDefines {
  43578. BRDF_V_HEIGHT_CORRELATED: boolean;
  43579. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43580. /** @hidden */ areMiscDirty: boolean;
  43581. }
  43582. /**
  43583. * Define the code related to the BRDF parameters of the pbr material.
  43584. */
  43585. export class PBRBRDFConfiguration {
  43586. /**
  43587. * Default value used for the energy conservation.
  43588. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43589. */
  43590. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43591. /**
  43592. * Default value used for the Smith Visibility Height Correlated mode.
  43593. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43594. */
  43595. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43596. private _useEnergyConservation;
  43597. /**
  43598. * Defines if the material uses energy conservation.
  43599. */
  43600. useEnergyConservation: boolean;
  43601. private _useSmithVisibilityHeightCorrelated;
  43602. /**
  43603. * LEGACY Mode set to false
  43604. * Defines if the material uses height smith correlated visibility term.
  43605. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43606. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43607. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43608. * Not relying on height correlated will also disable energy conservation.
  43609. */
  43610. useSmithVisibilityHeightCorrelated: boolean;
  43611. /** @hidden */
  43612. private _internalMarkAllSubMeshesAsMiscDirty;
  43613. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43614. /**
  43615. * Instantiate a new istance of clear coat configuration.
  43616. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43617. */
  43618. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43619. /**
  43620. * Checks to see if a texture is used in the material.
  43621. * @param defines the list of "defines" to update.
  43622. */
  43623. prepareDefines(defines: IMaterialBRDFDefines): void;
  43624. /**
  43625. * Get the current class name of the texture useful for serialization or dynamic coding.
  43626. * @returns "PBRClearCoatConfiguration"
  43627. */
  43628. getClassName(): string;
  43629. /**
  43630. * Makes a duplicate of the current configuration into another one.
  43631. * @param brdfConfiguration define the config where to copy the info
  43632. */
  43633. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43634. /**
  43635. * Serializes this BRDF configuration.
  43636. * @returns - An object with the serialized config.
  43637. */
  43638. serialize(): any;
  43639. /**
  43640. * Parses a BRDF Configuration from a serialized object.
  43641. * @param source - Serialized object.
  43642. */
  43643. parse(source: any): void;
  43644. }
  43645. }
  43646. declare module BABYLON {
  43647. /**
  43648. * @hidden
  43649. */
  43650. export interface IMaterialSheenDefines {
  43651. SHEEN: boolean;
  43652. SHEEN_TEXTURE: boolean;
  43653. SHEEN_TEXTUREDIRECTUV: number;
  43654. SHEEN_LINKWITHALBEDO: boolean;
  43655. /** @hidden */ areTexturesDirty: boolean;
  43656. }
  43657. /**
  43658. * Define the code related to the Sheen parameters of the pbr material.
  43659. */
  43660. export class PBRSheenConfiguration {
  43661. private _isEnabled;
  43662. /**
  43663. * Defines if the material uses sheen.
  43664. */
  43665. isEnabled: boolean;
  43666. private _linkSheenWithAlbedo;
  43667. /**
  43668. * Defines if the sheen is linked to the sheen color.
  43669. */
  43670. linkSheenWithAlbedo: boolean;
  43671. /**
  43672. * Defines the sheen intensity.
  43673. */
  43674. intensity: number;
  43675. /**
  43676. * Defines the sheen color.
  43677. */
  43678. color: Color3;
  43679. private _texture;
  43680. /**
  43681. * Stores the sheen tint values in a texture.
  43682. * rgb is tint
  43683. * a is a intensity
  43684. */
  43685. texture: Nullable<BaseTexture>;
  43686. /** @hidden */
  43687. private _internalMarkAllSubMeshesAsTexturesDirty;
  43688. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43689. /**
  43690. * Instantiate a new istance of clear coat configuration.
  43691. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43692. */
  43693. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43694. /**
  43695. * Specifies that the submesh is ready to be used.
  43696. * @param defines the list of "defines" to update.
  43697. * @param scene defines the scene the material belongs to.
  43698. * @returns - boolean indicating that the submesh is ready or not.
  43699. */
  43700. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43701. /**
  43702. * Checks to see if a texture is used in the material.
  43703. * @param defines the list of "defines" to update.
  43704. * @param scene defines the scene the material belongs to.
  43705. */
  43706. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43707. /**
  43708. * Binds the material data.
  43709. * @param uniformBuffer defines the Uniform buffer to fill in.
  43710. * @param scene defines the scene the material belongs to.
  43711. * @param isFrozen defines wether the material is frozen or not.
  43712. */
  43713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43714. /**
  43715. * Checks to see if a texture is used in the material.
  43716. * @param texture - Base texture to use.
  43717. * @returns - Boolean specifying if a texture is used in the material.
  43718. */
  43719. hasTexture(texture: BaseTexture): boolean;
  43720. /**
  43721. * Returns an array of the actively used textures.
  43722. * @param activeTextures Array of BaseTextures
  43723. */
  43724. getActiveTextures(activeTextures: BaseTexture[]): void;
  43725. /**
  43726. * Returns the animatable textures.
  43727. * @param animatables Array of animatable textures.
  43728. */
  43729. getAnimatables(animatables: IAnimatable[]): void;
  43730. /**
  43731. * Disposes the resources of the material.
  43732. * @param forceDisposeTextures - Forces the disposal of all textures.
  43733. */
  43734. dispose(forceDisposeTextures?: boolean): void;
  43735. /**
  43736. * Get the current class name of the texture useful for serialization or dynamic coding.
  43737. * @returns "PBRSheenConfiguration"
  43738. */
  43739. getClassName(): string;
  43740. /**
  43741. * Add fallbacks to the effect fallbacks list.
  43742. * @param defines defines the Base texture to use.
  43743. * @param fallbacks defines the current fallback list.
  43744. * @param currentRank defines the current fallback rank.
  43745. * @returns the new fallback rank.
  43746. */
  43747. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43748. /**
  43749. * Add the required uniforms to the current list.
  43750. * @param uniforms defines the current uniform list.
  43751. */
  43752. static AddUniforms(uniforms: string[]): void;
  43753. /**
  43754. * Add the required uniforms to the current buffer.
  43755. * @param uniformBuffer defines the current uniform buffer.
  43756. */
  43757. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43758. /**
  43759. * Add the required samplers to the current list.
  43760. * @param samplers defines the current sampler list.
  43761. */
  43762. static AddSamplers(samplers: string[]): void;
  43763. /**
  43764. * Makes a duplicate of the current configuration into another one.
  43765. * @param sheenConfiguration define the config where to copy the info
  43766. */
  43767. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43768. /**
  43769. * Serializes this BRDF configuration.
  43770. * @returns - An object with the serialized config.
  43771. */
  43772. serialize(): any;
  43773. /**
  43774. * Parses a Sheen Configuration from a serialized object.
  43775. * @param source - Serialized object.
  43776. */
  43777. parse(source: any): void;
  43778. }
  43779. }
  43780. declare module BABYLON {
  43781. /**
  43782. * @hidden
  43783. */
  43784. export interface IMaterialSubSurfaceDefines {
  43785. SUBSURFACE: boolean;
  43786. SS_REFRACTION: boolean;
  43787. SS_TRANSLUCENCY: boolean;
  43788. SS_SCATERRING: boolean;
  43789. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43790. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43791. SS_REFRACTIONMAP_3D: boolean;
  43792. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43793. SS_LODINREFRACTIONALPHA: boolean;
  43794. SS_GAMMAREFRACTION: boolean;
  43795. SS_RGBDREFRACTION: boolean;
  43796. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43797. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43798. /** @hidden */ areTexturesDirty: boolean;
  43799. }
  43800. /**
  43801. * Define the code related to the sub surface parameters of the pbr material.
  43802. */
  43803. export class PBRSubSurfaceConfiguration {
  43804. private _isRefractionEnabled;
  43805. /**
  43806. * Defines if the refraction is enabled in the material.
  43807. */
  43808. isRefractionEnabled: boolean;
  43809. private _isTranslucencyEnabled;
  43810. /**
  43811. * Defines if the translucency is enabled in the material.
  43812. */
  43813. isTranslucencyEnabled: boolean;
  43814. private _isScatteringEnabled;
  43815. /**
  43816. * Defines the refraction intensity of the material.
  43817. * The refraction when enabled replaces the Diffuse part of the material.
  43818. * The intensity helps transitionning between diffuse and refraction.
  43819. */
  43820. refractionIntensity: number;
  43821. /**
  43822. * Defines the translucency intensity of the material.
  43823. * When translucency has been enabled, this defines how much of the "translucency"
  43824. * is addded to the diffuse part of the material.
  43825. */
  43826. translucencyIntensity: number;
  43827. /**
  43828. * Defines the scattering intensity of the material.
  43829. * When scattering has been enabled, this defines how much of the "scattered light"
  43830. * is addded to the diffuse part of the material.
  43831. */
  43832. scatteringIntensity: number;
  43833. private _thicknessTexture;
  43834. /**
  43835. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43836. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43837. * 0 would mean minimumThickness
  43838. * 1 would mean maximumThickness
  43839. * The other channels might be use as a mask to vary the different effects intensity.
  43840. */
  43841. thicknessTexture: Nullable<BaseTexture>;
  43842. private _refractionTexture;
  43843. /**
  43844. * Defines the texture to use for refraction.
  43845. */
  43846. refractionTexture: Nullable<BaseTexture>;
  43847. private _indexOfRefraction;
  43848. /**
  43849. * Defines the indice of refraction used in the material.
  43850. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43851. */
  43852. indexOfRefraction: number;
  43853. private _invertRefractionY;
  43854. /**
  43855. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43856. */
  43857. invertRefractionY: boolean;
  43858. private _linkRefractionWithTransparency;
  43859. /**
  43860. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43861. * Materials half opaque for instance using refraction could benefit from this control.
  43862. */
  43863. linkRefractionWithTransparency: boolean;
  43864. /**
  43865. * Defines the minimum thickness stored in the thickness map.
  43866. * If no thickness map is defined, this value will be used to simulate thickness.
  43867. */
  43868. minimumThickness: number;
  43869. /**
  43870. * Defines the maximum thickness stored in the thickness map.
  43871. */
  43872. maximumThickness: number;
  43873. /**
  43874. * Defines the volume tint of the material.
  43875. * This is used for both translucency and scattering.
  43876. */
  43877. tintColor: Color3;
  43878. /**
  43879. * Defines the distance at which the tint color should be found in the media.
  43880. * This is used for refraction only.
  43881. */
  43882. tintColorAtDistance: number;
  43883. /**
  43884. * Defines how far each channel transmit through the media.
  43885. * It is defined as a color to simplify it selection.
  43886. */
  43887. diffusionDistance: Color3;
  43888. private _useMaskFromThicknessTexture;
  43889. /**
  43890. * Stores the intensity of the different subsurface effects in the thickness texture.
  43891. * * the green channel is the translucency intensity.
  43892. * * the blue channel is the scattering intensity.
  43893. * * the alpha channel is the refraction intensity.
  43894. */
  43895. useMaskFromThicknessTexture: boolean;
  43896. /** @hidden */
  43897. private _internalMarkAllSubMeshesAsTexturesDirty;
  43898. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43899. /**
  43900. * Instantiate a new istance of sub surface configuration.
  43901. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43902. */
  43903. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43904. /**
  43905. * Gets wehter the submesh is ready to be used or not.
  43906. * @param defines the list of "defines" to update.
  43907. * @param scene defines the scene the material belongs to.
  43908. * @returns - boolean indicating that the submesh is ready or not.
  43909. */
  43910. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43911. /**
  43912. * Checks to see if a texture is used in the material.
  43913. * @param defines the list of "defines" to update.
  43914. * @param scene defines the scene to the material belongs to.
  43915. */
  43916. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43917. /**
  43918. * Binds the material data.
  43919. * @param uniformBuffer defines the Uniform buffer to fill in.
  43920. * @param scene defines the scene the material belongs to.
  43921. * @param engine defines the engine the material belongs to.
  43922. * @param isFrozen defines wether the material is frozen or not.
  43923. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43924. */
  43925. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43926. /**
  43927. * Unbinds the material from the mesh.
  43928. * @param activeEffect defines the effect that should be unbound from.
  43929. * @returns true if unbound, otherwise false
  43930. */
  43931. unbind(activeEffect: Effect): boolean;
  43932. /**
  43933. * Returns the texture used for refraction or null if none is used.
  43934. * @param scene defines the scene the material belongs to.
  43935. * @returns - Refraction texture if present. If no refraction texture and refraction
  43936. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43937. */
  43938. private _getRefractionTexture;
  43939. /**
  43940. * Returns true if alpha blending should be disabled.
  43941. */
  43942. readonly disableAlphaBlending: boolean;
  43943. /**
  43944. * Fills the list of render target textures.
  43945. * @param renderTargets the list of render targets to update
  43946. */
  43947. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43948. /**
  43949. * Checks to see if a texture is used in the material.
  43950. * @param texture - Base texture to use.
  43951. * @returns - Boolean specifying if a texture is used in the material.
  43952. */
  43953. hasTexture(texture: BaseTexture): boolean;
  43954. /**
  43955. * Gets a boolean indicating that current material needs to register RTT
  43956. * @returns true if this uses a render target otherwise false.
  43957. */
  43958. hasRenderTargetTextures(): boolean;
  43959. /**
  43960. * Returns an array of the actively used textures.
  43961. * @param activeTextures Array of BaseTextures
  43962. */
  43963. getActiveTextures(activeTextures: BaseTexture[]): void;
  43964. /**
  43965. * Returns the animatable textures.
  43966. * @param animatables Array of animatable textures.
  43967. */
  43968. getAnimatables(animatables: IAnimatable[]): void;
  43969. /**
  43970. * Disposes the resources of the material.
  43971. * @param forceDisposeTextures - Forces the disposal of all textures.
  43972. */
  43973. dispose(forceDisposeTextures?: boolean): void;
  43974. /**
  43975. * Get the current class name of the texture useful for serialization or dynamic coding.
  43976. * @returns "PBRSubSurfaceConfiguration"
  43977. */
  43978. getClassName(): string;
  43979. /**
  43980. * Add fallbacks to the effect fallbacks list.
  43981. * @param defines defines the Base texture to use.
  43982. * @param fallbacks defines the current fallback list.
  43983. * @param currentRank defines the current fallback rank.
  43984. * @returns the new fallback rank.
  43985. */
  43986. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43987. /**
  43988. * Add the required uniforms to the current list.
  43989. * @param uniforms defines the current uniform list.
  43990. */
  43991. static AddUniforms(uniforms: string[]): void;
  43992. /**
  43993. * Add the required samplers to the current list.
  43994. * @param samplers defines the current sampler list.
  43995. */
  43996. static AddSamplers(samplers: string[]): void;
  43997. /**
  43998. * Add the required uniforms to the current buffer.
  43999. * @param uniformBuffer defines the current uniform buffer.
  44000. */
  44001. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44002. /**
  44003. * Makes a duplicate of the current configuration into another one.
  44004. * @param configuration define the config where to copy the info
  44005. */
  44006. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44007. /**
  44008. * Serializes this Sub Surface configuration.
  44009. * @returns - An object with the serialized config.
  44010. */
  44011. serialize(): any;
  44012. /**
  44013. * Parses a Sub Surface Configuration from a serialized object.
  44014. * @param source - Serialized object.
  44015. */
  44016. parse(source: any): void;
  44017. }
  44018. }
  44019. declare module BABYLON {
  44020. /** @hidden */
  44021. export var pbrFragmentDeclaration: {
  44022. name: string;
  44023. shader: string;
  44024. };
  44025. }
  44026. declare module BABYLON {
  44027. /** @hidden */
  44028. export var pbrUboDeclaration: {
  44029. name: string;
  44030. shader: string;
  44031. };
  44032. }
  44033. declare module BABYLON {
  44034. /** @hidden */
  44035. export var pbrFragmentExtraDeclaration: {
  44036. name: string;
  44037. shader: string;
  44038. };
  44039. }
  44040. declare module BABYLON {
  44041. /** @hidden */
  44042. export var pbrFragmentSamplersDeclaration: {
  44043. name: string;
  44044. shader: string;
  44045. };
  44046. }
  44047. declare module BABYLON {
  44048. /** @hidden */
  44049. export var pbrHelperFunctions: {
  44050. name: string;
  44051. shader: string;
  44052. };
  44053. }
  44054. declare module BABYLON {
  44055. /** @hidden */
  44056. export var harmonicsFunctions: {
  44057. name: string;
  44058. shader: string;
  44059. };
  44060. }
  44061. declare module BABYLON {
  44062. /** @hidden */
  44063. export var pbrDirectLightingSetupFunctions: {
  44064. name: string;
  44065. shader: string;
  44066. };
  44067. }
  44068. declare module BABYLON {
  44069. /** @hidden */
  44070. export var pbrDirectLightingFalloffFunctions: {
  44071. name: string;
  44072. shader: string;
  44073. };
  44074. }
  44075. declare module BABYLON {
  44076. /** @hidden */
  44077. export var pbrBRDFFunctions: {
  44078. name: string;
  44079. shader: string;
  44080. };
  44081. }
  44082. declare module BABYLON {
  44083. /** @hidden */
  44084. export var pbrDirectLightingFunctions: {
  44085. name: string;
  44086. shader: string;
  44087. };
  44088. }
  44089. declare module BABYLON {
  44090. /** @hidden */
  44091. export var pbrIBLFunctions: {
  44092. name: string;
  44093. shader: string;
  44094. };
  44095. }
  44096. declare module BABYLON {
  44097. /** @hidden */
  44098. export var pbrDebug: {
  44099. name: string;
  44100. shader: string;
  44101. };
  44102. }
  44103. declare module BABYLON {
  44104. /** @hidden */
  44105. export var pbrPixelShader: {
  44106. name: string;
  44107. shader: string;
  44108. };
  44109. }
  44110. declare module BABYLON {
  44111. /** @hidden */
  44112. export var pbrVertexDeclaration: {
  44113. name: string;
  44114. shader: string;
  44115. };
  44116. }
  44117. declare module BABYLON {
  44118. /** @hidden */
  44119. export var pbrVertexShader: {
  44120. name: string;
  44121. shader: string;
  44122. };
  44123. }
  44124. declare module BABYLON {
  44125. /**
  44126. * Manages the defines for the PBR Material.
  44127. * @hidden
  44128. */
  44129. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44130. PBR: boolean;
  44131. MAINUV1: boolean;
  44132. MAINUV2: boolean;
  44133. UV1: boolean;
  44134. UV2: boolean;
  44135. ALBEDO: boolean;
  44136. ALBEDODIRECTUV: number;
  44137. VERTEXCOLOR: boolean;
  44138. AMBIENT: boolean;
  44139. AMBIENTDIRECTUV: number;
  44140. AMBIENTINGRAYSCALE: boolean;
  44141. OPACITY: boolean;
  44142. VERTEXALPHA: boolean;
  44143. OPACITYDIRECTUV: number;
  44144. OPACITYRGB: boolean;
  44145. ALPHATEST: boolean;
  44146. DEPTHPREPASS: boolean;
  44147. ALPHABLEND: boolean;
  44148. ALPHAFROMALBEDO: boolean;
  44149. ALPHATESTVALUE: string;
  44150. SPECULAROVERALPHA: boolean;
  44151. RADIANCEOVERALPHA: boolean;
  44152. ALPHAFRESNEL: boolean;
  44153. LINEARALPHAFRESNEL: boolean;
  44154. PREMULTIPLYALPHA: boolean;
  44155. EMISSIVE: boolean;
  44156. EMISSIVEDIRECTUV: number;
  44157. REFLECTIVITY: boolean;
  44158. REFLECTIVITYDIRECTUV: number;
  44159. SPECULARTERM: boolean;
  44160. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44161. MICROSURFACEAUTOMATIC: boolean;
  44162. LODBASEDMICROSFURACE: boolean;
  44163. MICROSURFACEMAP: boolean;
  44164. MICROSURFACEMAPDIRECTUV: number;
  44165. METALLICWORKFLOW: boolean;
  44166. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44167. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44168. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44169. AOSTOREINMETALMAPRED: boolean;
  44170. ENVIRONMENTBRDF: boolean;
  44171. ENVIRONMENTBRDF_RGBD: boolean;
  44172. NORMAL: boolean;
  44173. TANGENT: boolean;
  44174. BUMP: boolean;
  44175. BUMPDIRECTUV: number;
  44176. OBJECTSPACE_NORMALMAP: boolean;
  44177. PARALLAX: boolean;
  44178. PARALLAXOCCLUSION: boolean;
  44179. NORMALXYSCALE: boolean;
  44180. LIGHTMAP: boolean;
  44181. LIGHTMAPDIRECTUV: number;
  44182. USELIGHTMAPASSHADOWMAP: boolean;
  44183. GAMMALIGHTMAP: boolean;
  44184. REFLECTION: boolean;
  44185. REFLECTIONMAP_3D: boolean;
  44186. REFLECTIONMAP_SPHERICAL: boolean;
  44187. REFLECTIONMAP_PLANAR: boolean;
  44188. REFLECTIONMAP_CUBIC: boolean;
  44189. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44190. REFLECTIONMAP_PROJECTION: boolean;
  44191. REFLECTIONMAP_SKYBOX: boolean;
  44192. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44193. REFLECTIONMAP_EXPLICIT: boolean;
  44194. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44195. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44196. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44197. INVERTCUBICMAP: boolean;
  44198. USESPHERICALFROMREFLECTIONMAP: boolean;
  44199. USESPHERICALINVERTEX: boolean;
  44200. REFLECTIONMAP_OPPOSITEZ: boolean;
  44201. LODINREFLECTIONALPHA: boolean;
  44202. GAMMAREFLECTION: boolean;
  44203. RGBDREFLECTION: boolean;
  44204. RADIANCEOCCLUSION: boolean;
  44205. HORIZONOCCLUSION: boolean;
  44206. INSTANCES: boolean;
  44207. NUM_BONE_INFLUENCERS: number;
  44208. BonesPerMesh: number;
  44209. BONETEXTURE: boolean;
  44210. NONUNIFORMSCALING: boolean;
  44211. MORPHTARGETS: boolean;
  44212. MORPHTARGETS_NORMAL: boolean;
  44213. MORPHTARGETS_TANGENT: boolean;
  44214. NUM_MORPH_INFLUENCERS: number;
  44215. IMAGEPROCESSING: boolean;
  44216. VIGNETTE: boolean;
  44217. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44218. VIGNETTEBLENDMODEOPAQUE: boolean;
  44219. TONEMAPPING: boolean;
  44220. TONEMAPPING_ACES: boolean;
  44221. CONTRAST: boolean;
  44222. COLORCURVES: boolean;
  44223. COLORGRADING: boolean;
  44224. COLORGRADING3D: boolean;
  44225. SAMPLER3DGREENDEPTH: boolean;
  44226. SAMPLER3DBGRMAP: boolean;
  44227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44228. EXPOSURE: boolean;
  44229. MULTIVIEW: boolean;
  44230. USEPHYSICALLIGHTFALLOFF: boolean;
  44231. USEGLTFLIGHTFALLOFF: boolean;
  44232. TWOSIDEDLIGHTING: boolean;
  44233. SHADOWFLOAT: boolean;
  44234. CLIPPLANE: boolean;
  44235. CLIPPLANE2: boolean;
  44236. CLIPPLANE3: boolean;
  44237. CLIPPLANE4: boolean;
  44238. POINTSIZE: boolean;
  44239. FOG: boolean;
  44240. LOGARITHMICDEPTH: boolean;
  44241. FORCENORMALFORWARD: boolean;
  44242. SPECULARAA: boolean;
  44243. CLEARCOAT: boolean;
  44244. CLEARCOAT_DEFAULTIOR: boolean;
  44245. CLEARCOAT_TEXTURE: boolean;
  44246. CLEARCOAT_TEXTUREDIRECTUV: number;
  44247. CLEARCOAT_BUMP: boolean;
  44248. CLEARCOAT_BUMPDIRECTUV: number;
  44249. CLEARCOAT_TINT: boolean;
  44250. CLEARCOAT_TINT_TEXTURE: boolean;
  44251. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44252. ANISOTROPIC: boolean;
  44253. ANISOTROPIC_TEXTURE: boolean;
  44254. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44255. BRDF_V_HEIGHT_CORRELATED: boolean;
  44256. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44257. SHEEN: boolean;
  44258. SHEEN_TEXTURE: boolean;
  44259. SHEEN_TEXTUREDIRECTUV: number;
  44260. SHEEN_LINKWITHALBEDO: boolean;
  44261. SUBSURFACE: boolean;
  44262. SS_REFRACTION: boolean;
  44263. SS_TRANSLUCENCY: boolean;
  44264. SS_SCATERRING: boolean;
  44265. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44266. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44267. SS_REFRACTIONMAP_3D: boolean;
  44268. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44269. SS_LODINREFRACTIONALPHA: boolean;
  44270. SS_GAMMAREFRACTION: boolean;
  44271. SS_RGBDREFRACTION: boolean;
  44272. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44273. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44274. UNLIT: boolean;
  44275. DEBUGMODE: number;
  44276. /**
  44277. * Initializes the PBR Material defines.
  44278. */
  44279. constructor();
  44280. /**
  44281. * Resets the PBR Material defines.
  44282. */
  44283. reset(): void;
  44284. }
  44285. /**
  44286. * The Physically based material base class of BJS.
  44287. *
  44288. * This offers the main features of a standard PBR material.
  44289. * For more information, please refer to the documentation :
  44290. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44291. */
  44292. export abstract class PBRBaseMaterial extends PushMaterial {
  44293. /**
  44294. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44295. */
  44296. static readonly PBRMATERIAL_OPAQUE: number;
  44297. /**
  44298. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44299. */
  44300. static readonly PBRMATERIAL_ALPHATEST: number;
  44301. /**
  44302. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44303. */
  44304. static readonly PBRMATERIAL_ALPHABLEND: number;
  44305. /**
  44306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44307. * They are also discarded below the alpha cutoff threshold to improve performances.
  44308. */
  44309. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44310. /**
  44311. * Defines the default value of how much AO map is occluding the analytical lights
  44312. * (point spot...).
  44313. */
  44314. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44315. /**
  44316. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44317. */
  44318. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44319. /**
  44320. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44321. * to enhance interoperability with other engines.
  44322. */
  44323. static readonly LIGHTFALLOFF_GLTF: number;
  44324. /**
  44325. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44326. * to enhance interoperability with other materials.
  44327. */
  44328. static readonly LIGHTFALLOFF_STANDARD: number;
  44329. /**
  44330. * Intensity of the direct lights e.g. the four lights available in your scene.
  44331. * This impacts both the direct diffuse and specular highlights.
  44332. */
  44333. protected _directIntensity: number;
  44334. /**
  44335. * Intensity of the emissive part of the material.
  44336. * This helps controlling the emissive effect without modifying the emissive color.
  44337. */
  44338. protected _emissiveIntensity: number;
  44339. /**
  44340. * Intensity of the environment e.g. how much the environment will light the object
  44341. * either through harmonics for rough material or through the refelction for shiny ones.
  44342. */
  44343. protected _environmentIntensity: number;
  44344. /**
  44345. * This is a special control allowing the reduction of the specular highlights coming from the
  44346. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44347. */
  44348. protected _specularIntensity: number;
  44349. /**
  44350. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44351. */
  44352. private _lightingInfos;
  44353. /**
  44354. * Debug Control allowing disabling the bump map on this material.
  44355. */
  44356. protected _disableBumpMap: boolean;
  44357. /**
  44358. * AKA Diffuse Texture in standard nomenclature.
  44359. */
  44360. protected _albedoTexture: Nullable<BaseTexture>;
  44361. /**
  44362. * AKA Occlusion Texture in other nomenclature.
  44363. */
  44364. protected _ambientTexture: Nullable<BaseTexture>;
  44365. /**
  44366. * AKA Occlusion Texture Intensity in other nomenclature.
  44367. */
  44368. protected _ambientTextureStrength: number;
  44369. /**
  44370. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44371. * 1 means it completely occludes it
  44372. * 0 mean it has no impact
  44373. */
  44374. protected _ambientTextureImpactOnAnalyticalLights: number;
  44375. /**
  44376. * Stores the alpha values in a texture.
  44377. */
  44378. protected _opacityTexture: Nullable<BaseTexture>;
  44379. /**
  44380. * Stores the reflection values in a texture.
  44381. */
  44382. protected _reflectionTexture: Nullable<BaseTexture>;
  44383. /**
  44384. * Stores the emissive values in a texture.
  44385. */
  44386. protected _emissiveTexture: Nullable<BaseTexture>;
  44387. /**
  44388. * AKA Specular texture in other nomenclature.
  44389. */
  44390. protected _reflectivityTexture: Nullable<BaseTexture>;
  44391. /**
  44392. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44393. */
  44394. protected _metallicTexture: Nullable<BaseTexture>;
  44395. /**
  44396. * Specifies the metallic scalar of the metallic/roughness workflow.
  44397. * Can also be used to scale the metalness values of the metallic texture.
  44398. */
  44399. protected _metallic: Nullable<number>;
  44400. /**
  44401. * Specifies the roughness scalar of the metallic/roughness workflow.
  44402. * Can also be used to scale the roughness values of the metallic texture.
  44403. */
  44404. protected _roughness: Nullable<number>;
  44405. /**
  44406. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44407. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44408. */
  44409. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44410. /**
  44411. * Stores surface normal data used to displace a mesh in a texture.
  44412. */
  44413. protected _bumpTexture: Nullable<BaseTexture>;
  44414. /**
  44415. * Stores the pre-calculated light information of a mesh in a texture.
  44416. */
  44417. protected _lightmapTexture: Nullable<BaseTexture>;
  44418. /**
  44419. * The color of a material in ambient lighting.
  44420. */
  44421. protected _ambientColor: Color3;
  44422. /**
  44423. * AKA Diffuse Color in other nomenclature.
  44424. */
  44425. protected _albedoColor: Color3;
  44426. /**
  44427. * AKA Specular Color in other nomenclature.
  44428. */
  44429. protected _reflectivityColor: Color3;
  44430. /**
  44431. * The color applied when light is reflected from a material.
  44432. */
  44433. protected _reflectionColor: Color3;
  44434. /**
  44435. * The color applied when light is emitted from a material.
  44436. */
  44437. protected _emissiveColor: Color3;
  44438. /**
  44439. * AKA Glossiness in other nomenclature.
  44440. */
  44441. protected _microSurface: number;
  44442. /**
  44443. * Specifies that the material will use the light map as a show map.
  44444. */
  44445. protected _useLightmapAsShadowmap: boolean;
  44446. /**
  44447. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44448. * makes the reflect vector face the model (under horizon).
  44449. */
  44450. protected _useHorizonOcclusion: boolean;
  44451. /**
  44452. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44453. * too much the area relying on ambient texture to define their ambient occlusion.
  44454. */
  44455. protected _useRadianceOcclusion: boolean;
  44456. /**
  44457. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44458. */
  44459. protected _useAlphaFromAlbedoTexture: boolean;
  44460. /**
  44461. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44462. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44463. */
  44464. protected _useSpecularOverAlpha: boolean;
  44465. /**
  44466. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44467. */
  44468. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44469. /**
  44470. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44471. */
  44472. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44473. /**
  44474. * Specifies if the metallic texture contains the roughness information in its green channel.
  44475. */
  44476. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44477. /**
  44478. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44479. */
  44480. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44481. /**
  44482. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44483. */
  44484. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44485. /**
  44486. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44487. */
  44488. protected _useAmbientInGrayScale: boolean;
  44489. /**
  44490. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44491. * The material will try to infer what glossiness each pixel should be.
  44492. */
  44493. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44494. /**
  44495. * Defines the falloff type used in this material.
  44496. * It by default is Physical.
  44497. */
  44498. protected _lightFalloff: number;
  44499. /**
  44500. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44501. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44502. */
  44503. protected _useRadianceOverAlpha: boolean;
  44504. /**
  44505. * Allows using an object space normal map (instead of tangent space).
  44506. */
  44507. protected _useObjectSpaceNormalMap: boolean;
  44508. /**
  44509. * Allows using the bump map in parallax mode.
  44510. */
  44511. protected _useParallax: boolean;
  44512. /**
  44513. * Allows using the bump map in parallax occlusion mode.
  44514. */
  44515. protected _useParallaxOcclusion: boolean;
  44516. /**
  44517. * Controls the scale bias of the parallax mode.
  44518. */
  44519. protected _parallaxScaleBias: number;
  44520. /**
  44521. * If sets to true, disables all the lights affecting the material.
  44522. */
  44523. protected _disableLighting: boolean;
  44524. /**
  44525. * Number of Simultaneous lights allowed on the material.
  44526. */
  44527. protected _maxSimultaneousLights: number;
  44528. /**
  44529. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44530. */
  44531. protected _invertNormalMapX: boolean;
  44532. /**
  44533. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44534. */
  44535. protected _invertNormalMapY: boolean;
  44536. /**
  44537. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44538. */
  44539. protected _twoSidedLighting: boolean;
  44540. /**
  44541. * Defines the alpha limits in alpha test mode.
  44542. */
  44543. protected _alphaCutOff: number;
  44544. /**
  44545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44546. */
  44547. protected _forceAlphaTest: boolean;
  44548. /**
  44549. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44550. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44551. */
  44552. protected _useAlphaFresnel: boolean;
  44553. /**
  44554. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44555. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44556. */
  44557. protected _useLinearAlphaFresnel: boolean;
  44558. /**
  44559. * The transparency mode of the material.
  44560. */
  44561. protected _transparencyMode: Nullable<number>;
  44562. /**
  44563. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44564. * from cos thetav and roughness:
  44565. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44566. */
  44567. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44568. /**
  44569. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44570. */
  44571. protected _forceIrradianceInFragment: boolean;
  44572. /**
  44573. * Force normal to face away from face.
  44574. */
  44575. protected _forceNormalForward: boolean;
  44576. /**
  44577. * Enables specular anti aliasing in the PBR shader.
  44578. * It will both interacts on the Geometry for analytical and IBL lighting.
  44579. * It also prefilter the roughness map based on the bump values.
  44580. */
  44581. protected _enableSpecularAntiAliasing: boolean;
  44582. /**
  44583. * Default configuration related to image processing available in the PBR Material.
  44584. */
  44585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44586. /**
  44587. * Keep track of the image processing observer to allow dispose and replace.
  44588. */
  44589. private _imageProcessingObserver;
  44590. /**
  44591. * Attaches a new image processing configuration to the PBR Material.
  44592. * @param configuration
  44593. */
  44594. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44595. /**
  44596. * Stores the available render targets.
  44597. */
  44598. private _renderTargets;
  44599. /**
  44600. * Sets the global ambient color for the material used in lighting calculations.
  44601. */
  44602. private _globalAmbientColor;
  44603. /**
  44604. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44605. */
  44606. private _useLogarithmicDepth;
  44607. /**
  44608. * If set to true, no lighting calculations will be applied.
  44609. */
  44610. private _unlit;
  44611. private _debugMode;
  44612. /**
  44613. * @hidden
  44614. * This is reserved for the inspector.
  44615. * Defines the material debug mode.
  44616. * It helps seeing only some components of the material while troubleshooting.
  44617. */
  44618. debugMode: number;
  44619. /**
  44620. * @hidden
  44621. * This is reserved for the inspector.
  44622. * Specify from where on screen the debug mode should start.
  44623. * The value goes from -1 (full screen) to 1 (not visible)
  44624. * It helps with side by side comparison against the final render
  44625. * This defaults to -1
  44626. */
  44627. private debugLimit;
  44628. /**
  44629. * @hidden
  44630. * This is reserved for the inspector.
  44631. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44632. * You can use the factor to better multiply the final value.
  44633. */
  44634. private debugFactor;
  44635. /**
  44636. * Defines the clear coat layer parameters for the material.
  44637. */
  44638. readonly clearCoat: PBRClearCoatConfiguration;
  44639. /**
  44640. * Defines the anisotropic parameters for the material.
  44641. */
  44642. readonly anisotropy: PBRAnisotropicConfiguration;
  44643. /**
  44644. * Defines the BRDF parameters for the material.
  44645. */
  44646. readonly brdf: PBRBRDFConfiguration;
  44647. /**
  44648. * Defines the Sheen parameters for the material.
  44649. */
  44650. readonly sheen: PBRSheenConfiguration;
  44651. /**
  44652. * Defines the SubSurface parameters for the material.
  44653. */
  44654. readonly subSurface: PBRSubSurfaceConfiguration;
  44655. /**
  44656. * Custom callback helping to override the default shader used in the material.
  44657. */
  44658. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44659. /**
  44660. * Instantiates a new PBRMaterial instance.
  44661. *
  44662. * @param name The material name
  44663. * @param scene The scene the material will be use in.
  44664. */
  44665. constructor(name: string, scene: Scene);
  44666. /**
  44667. * Gets a boolean indicating that current material needs to register RTT
  44668. */
  44669. readonly hasRenderTargetTextures: boolean;
  44670. /**
  44671. * Gets the name of the material class.
  44672. */
  44673. getClassName(): string;
  44674. /**
  44675. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44676. */
  44677. /**
  44678. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44679. */
  44680. useLogarithmicDepth: boolean;
  44681. /**
  44682. * Gets the current transparency mode.
  44683. */
  44684. /**
  44685. * Sets the transparency mode of the material.
  44686. *
  44687. * | Value | Type | Description |
  44688. * | ----- | ----------------------------------- | ----------- |
  44689. * | 0 | OPAQUE | |
  44690. * | 1 | ALPHATEST | |
  44691. * | 2 | ALPHABLEND | |
  44692. * | 3 | ALPHATESTANDBLEND | |
  44693. *
  44694. */
  44695. transparencyMode: Nullable<number>;
  44696. /**
  44697. * Returns true if alpha blending should be disabled.
  44698. */
  44699. private readonly _disableAlphaBlending;
  44700. /**
  44701. * Specifies whether or not this material should be rendered in alpha blend mode.
  44702. */
  44703. needAlphaBlending(): boolean;
  44704. /**
  44705. * Specifies if the mesh will require alpha blending.
  44706. * @param mesh - BJS mesh.
  44707. */
  44708. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44709. /**
  44710. * Specifies whether or not this material should be rendered in alpha test mode.
  44711. */
  44712. needAlphaTesting(): boolean;
  44713. /**
  44714. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44715. */
  44716. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44717. /**
  44718. * Gets the texture used for the alpha test.
  44719. */
  44720. getAlphaTestTexture(): Nullable<BaseTexture>;
  44721. /**
  44722. * Specifies that the submesh is ready to be used.
  44723. * @param mesh - BJS mesh.
  44724. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44725. * @param useInstances - Specifies that instances should be used.
  44726. * @returns - boolean indicating that the submesh is ready or not.
  44727. */
  44728. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44729. /**
  44730. * Specifies if the material uses metallic roughness workflow.
  44731. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44732. */
  44733. isMetallicWorkflow(): boolean;
  44734. private _prepareEffect;
  44735. private _prepareDefines;
  44736. /**
  44737. * Force shader compilation
  44738. */
  44739. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44740. clipPlane: boolean;
  44741. }>): void;
  44742. /**
  44743. * Initializes the uniform buffer layout for the shader.
  44744. */
  44745. buildUniformLayout(): void;
  44746. /**
  44747. * Unbinds the material from the mesh
  44748. */
  44749. unbind(): void;
  44750. /**
  44751. * Binds the submesh data.
  44752. * @param world - The world matrix.
  44753. * @param mesh - The BJS mesh.
  44754. * @param subMesh - A submesh of the BJS mesh.
  44755. */
  44756. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44757. /**
  44758. * Returns the animatable textures.
  44759. * @returns - Array of animatable textures.
  44760. */
  44761. getAnimatables(): IAnimatable[];
  44762. /**
  44763. * Returns the texture used for reflections.
  44764. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44765. */
  44766. private _getReflectionTexture;
  44767. /**
  44768. * Returns an array of the actively used textures.
  44769. * @returns - Array of BaseTextures
  44770. */
  44771. getActiveTextures(): BaseTexture[];
  44772. /**
  44773. * Checks to see if a texture is used in the material.
  44774. * @param texture - Base texture to use.
  44775. * @returns - Boolean specifying if a texture is used in the material.
  44776. */
  44777. hasTexture(texture: BaseTexture): boolean;
  44778. /**
  44779. * Disposes the resources of the material.
  44780. * @param forceDisposeEffect - Forces the disposal of effects.
  44781. * @param forceDisposeTextures - Forces the disposal of all textures.
  44782. */
  44783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44784. }
  44785. }
  44786. declare module BABYLON {
  44787. /**
  44788. * The Physically based material of BJS.
  44789. *
  44790. * This offers the main features of a standard PBR material.
  44791. * For more information, please refer to the documentation :
  44792. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44793. */
  44794. export class PBRMaterial extends PBRBaseMaterial {
  44795. /**
  44796. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44797. */
  44798. static readonly PBRMATERIAL_OPAQUE: number;
  44799. /**
  44800. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44801. */
  44802. static readonly PBRMATERIAL_ALPHATEST: number;
  44803. /**
  44804. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44805. */
  44806. static readonly PBRMATERIAL_ALPHABLEND: number;
  44807. /**
  44808. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44809. * They are also discarded below the alpha cutoff threshold to improve performances.
  44810. */
  44811. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44812. /**
  44813. * Defines the default value of how much AO map is occluding the analytical lights
  44814. * (point spot...).
  44815. */
  44816. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44817. /**
  44818. * Intensity of the direct lights e.g. the four lights available in your scene.
  44819. * This impacts both the direct diffuse and specular highlights.
  44820. */
  44821. directIntensity: number;
  44822. /**
  44823. * Intensity of the emissive part of the material.
  44824. * This helps controlling the emissive effect without modifying the emissive color.
  44825. */
  44826. emissiveIntensity: number;
  44827. /**
  44828. * Intensity of the environment e.g. how much the environment will light the object
  44829. * either through harmonics for rough material or through the refelction for shiny ones.
  44830. */
  44831. environmentIntensity: number;
  44832. /**
  44833. * This is a special control allowing the reduction of the specular highlights coming from the
  44834. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44835. */
  44836. specularIntensity: number;
  44837. /**
  44838. * Debug Control allowing disabling the bump map on this material.
  44839. */
  44840. disableBumpMap: boolean;
  44841. /**
  44842. * AKA Diffuse Texture in standard nomenclature.
  44843. */
  44844. albedoTexture: BaseTexture;
  44845. /**
  44846. * AKA Occlusion Texture in other nomenclature.
  44847. */
  44848. ambientTexture: BaseTexture;
  44849. /**
  44850. * AKA Occlusion Texture Intensity in other nomenclature.
  44851. */
  44852. ambientTextureStrength: number;
  44853. /**
  44854. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44855. * 1 means it completely occludes it
  44856. * 0 mean it has no impact
  44857. */
  44858. ambientTextureImpactOnAnalyticalLights: number;
  44859. /**
  44860. * Stores the alpha values in a texture.
  44861. */
  44862. opacityTexture: BaseTexture;
  44863. /**
  44864. * Stores the reflection values in a texture.
  44865. */
  44866. reflectionTexture: Nullable<BaseTexture>;
  44867. /**
  44868. * Stores the emissive values in a texture.
  44869. */
  44870. emissiveTexture: BaseTexture;
  44871. /**
  44872. * AKA Specular texture in other nomenclature.
  44873. */
  44874. reflectivityTexture: BaseTexture;
  44875. /**
  44876. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44877. */
  44878. metallicTexture: BaseTexture;
  44879. /**
  44880. * Specifies the metallic scalar of the metallic/roughness workflow.
  44881. * Can also be used to scale the metalness values of the metallic texture.
  44882. */
  44883. metallic: Nullable<number>;
  44884. /**
  44885. * Specifies the roughness scalar of the metallic/roughness workflow.
  44886. * Can also be used to scale the roughness values of the metallic texture.
  44887. */
  44888. roughness: Nullable<number>;
  44889. /**
  44890. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44891. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44892. */
  44893. microSurfaceTexture: BaseTexture;
  44894. /**
  44895. * Stores surface normal data used to displace a mesh in a texture.
  44896. */
  44897. bumpTexture: BaseTexture;
  44898. /**
  44899. * Stores the pre-calculated light information of a mesh in a texture.
  44900. */
  44901. lightmapTexture: BaseTexture;
  44902. /**
  44903. * Stores the refracted light information in a texture.
  44904. */
  44905. refractionTexture: Nullable<BaseTexture>;
  44906. /**
  44907. * The color of a material in ambient lighting.
  44908. */
  44909. ambientColor: Color3;
  44910. /**
  44911. * AKA Diffuse Color in other nomenclature.
  44912. */
  44913. albedoColor: Color3;
  44914. /**
  44915. * AKA Specular Color in other nomenclature.
  44916. */
  44917. reflectivityColor: Color3;
  44918. /**
  44919. * The color reflected from the material.
  44920. */
  44921. reflectionColor: Color3;
  44922. /**
  44923. * The color emitted from the material.
  44924. */
  44925. emissiveColor: Color3;
  44926. /**
  44927. * AKA Glossiness in other nomenclature.
  44928. */
  44929. microSurface: number;
  44930. /**
  44931. * source material index of refraction (IOR)' / 'destination material IOR.
  44932. */
  44933. indexOfRefraction: number;
  44934. /**
  44935. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44936. */
  44937. invertRefractionY: boolean;
  44938. /**
  44939. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44940. * Materials half opaque for instance using refraction could benefit from this control.
  44941. */
  44942. linkRefractionWithTransparency: boolean;
  44943. /**
  44944. * If true, the light map contains occlusion information instead of lighting info.
  44945. */
  44946. useLightmapAsShadowmap: boolean;
  44947. /**
  44948. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44949. */
  44950. useAlphaFromAlbedoTexture: boolean;
  44951. /**
  44952. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44953. */
  44954. forceAlphaTest: boolean;
  44955. /**
  44956. * Defines the alpha limits in alpha test mode.
  44957. */
  44958. alphaCutOff: number;
  44959. /**
  44960. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44961. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44962. */
  44963. useSpecularOverAlpha: boolean;
  44964. /**
  44965. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44966. */
  44967. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44968. /**
  44969. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44970. */
  44971. useRoughnessFromMetallicTextureAlpha: boolean;
  44972. /**
  44973. * Specifies if the metallic texture contains the roughness information in its green channel.
  44974. */
  44975. useRoughnessFromMetallicTextureGreen: boolean;
  44976. /**
  44977. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44978. */
  44979. useMetallnessFromMetallicTextureBlue: boolean;
  44980. /**
  44981. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44982. */
  44983. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44984. /**
  44985. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44986. */
  44987. useAmbientInGrayScale: boolean;
  44988. /**
  44989. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44990. * The material will try to infer what glossiness each pixel should be.
  44991. */
  44992. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44993. /**
  44994. * BJS is using an harcoded light falloff based on a manually sets up range.
  44995. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44996. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44997. */
  44998. /**
  44999. * BJS is using an harcoded light falloff based on a manually sets up range.
  45000. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45001. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45002. */
  45003. usePhysicalLightFalloff: boolean;
  45004. /**
  45005. * In order to support the falloff compatibility with gltf, a special mode has been added
  45006. * to reproduce the gltf light falloff.
  45007. */
  45008. /**
  45009. * In order to support the falloff compatibility with gltf, a special mode has been added
  45010. * to reproduce the gltf light falloff.
  45011. */
  45012. useGLTFLightFalloff: boolean;
  45013. /**
  45014. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45015. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45016. */
  45017. useRadianceOverAlpha: boolean;
  45018. /**
  45019. * Allows using an object space normal map (instead of tangent space).
  45020. */
  45021. useObjectSpaceNormalMap: boolean;
  45022. /**
  45023. * Allows using the bump map in parallax mode.
  45024. */
  45025. useParallax: boolean;
  45026. /**
  45027. * Allows using the bump map in parallax occlusion mode.
  45028. */
  45029. useParallaxOcclusion: boolean;
  45030. /**
  45031. * Controls the scale bias of the parallax mode.
  45032. */
  45033. parallaxScaleBias: number;
  45034. /**
  45035. * If sets to true, disables all the lights affecting the material.
  45036. */
  45037. disableLighting: boolean;
  45038. /**
  45039. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45040. */
  45041. forceIrradianceInFragment: boolean;
  45042. /**
  45043. * Number of Simultaneous lights allowed on the material.
  45044. */
  45045. maxSimultaneousLights: number;
  45046. /**
  45047. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45048. */
  45049. invertNormalMapX: boolean;
  45050. /**
  45051. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45052. */
  45053. invertNormalMapY: boolean;
  45054. /**
  45055. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45056. */
  45057. twoSidedLighting: boolean;
  45058. /**
  45059. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45060. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45061. */
  45062. useAlphaFresnel: boolean;
  45063. /**
  45064. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45065. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45066. */
  45067. useLinearAlphaFresnel: boolean;
  45068. /**
  45069. * Let user defines the brdf lookup texture used for IBL.
  45070. * A default 8bit version is embedded but you could point at :
  45071. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45072. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45073. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45074. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45075. */
  45076. environmentBRDFTexture: Nullable<BaseTexture>;
  45077. /**
  45078. * Force normal to face away from face.
  45079. */
  45080. forceNormalForward: boolean;
  45081. /**
  45082. * Enables specular anti aliasing in the PBR shader.
  45083. * It will both interacts on the Geometry for analytical and IBL lighting.
  45084. * It also prefilter the roughness map based on the bump values.
  45085. */
  45086. enableSpecularAntiAliasing: boolean;
  45087. /**
  45088. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45089. * makes the reflect vector face the model (under horizon).
  45090. */
  45091. useHorizonOcclusion: boolean;
  45092. /**
  45093. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45094. * too much the area relying on ambient texture to define their ambient occlusion.
  45095. */
  45096. useRadianceOcclusion: boolean;
  45097. /**
  45098. * If set to true, no lighting calculations will be applied.
  45099. */
  45100. unlit: boolean;
  45101. /**
  45102. * Gets the image processing configuration used either in this material.
  45103. */
  45104. /**
  45105. * Sets the Default image processing configuration used either in the this material.
  45106. *
  45107. * If sets to null, the scene one is in use.
  45108. */
  45109. imageProcessingConfiguration: ImageProcessingConfiguration;
  45110. /**
  45111. * Gets wether the color curves effect is enabled.
  45112. */
  45113. /**
  45114. * Sets wether the color curves effect is enabled.
  45115. */
  45116. cameraColorCurvesEnabled: boolean;
  45117. /**
  45118. * Gets wether the color grading effect is enabled.
  45119. */
  45120. /**
  45121. * Gets wether the color grading effect is enabled.
  45122. */
  45123. cameraColorGradingEnabled: boolean;
  45124. /**
  45125. * Gets wether tonemapping is enabled or not.
  45126. */
  45127. /**
  45128. * Sets wether tonemapping is enabled or not
  45129. */
  45130. cameraToneMappingEnabled: boolean;
  45131. /**
  45132. * The camera exposure used on this material.
  45133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45134. * This corresponds to a photographic exposure.
  45135. */
  45136. /**
  45137. * The camera exposure used on this material.
  45138. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45139. * This corresponds to a photographic exposure.
  45140. */
  45141. cameraExposure: number;
  45142. /**
  45143. * Gets The camera contrast used on this material.
  45144. */
  45145. /**
  45146. * Sets The camera contrast used on this material.
  45147. */
  45148. cameraContrast: number;
  45149. /**
  45150. * Gets the Color Grading 2D Lookup Texture.
  45151. */
  45152. /**
  45153. * Sets the Color Grading 2D Lookup Texture.
  45154. */
  45155. cameraColorGradingTexture: Nullable<BaseTexture>;
  45156. /**
  45157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45159. * 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;
  45160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45161. */
  45162. /**
  45163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45165. * 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;
  45166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45167. */
  45168. cameraColorCurves: Nullable<ColorCurves>;
  45169. /**
  45170. * Instantiates a new PBRMaterial instance.
  45171. *
  45172. * @param name The material name
  45173. * @param scene The scene the material will be use in.
  45174. */
  45175. constructor(name: string, scene: Scene);
  45176. /**
  45177. * Returns the name of this material class.
  45178. */
  45179. getClassName(): string;
  45180. /**
  45181. * Makes a duplicate of the current material.
  45182. * @param name - name to use for the new material.
  45183. */
  45184. clone(name: string): PBRMaterial;
  45185. /**
  45186. * Serializes this PBR Material.
  45187. * @returns - An object with the serialized material.
  45188. */
  45189. serialize(): any;
  45190. /**
  45191. * Parses a PBR Material from a serialized object.
  45192. * @param source - Serialized object.
  45193. * @param scene - BJS scene instance.
  45194. * @param rootUrl - url for the scene object
  45195. * @returns - PBRMaterial
  45196. */
  45197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45198. }
  45199. }
  45200. declare module BABYLON {
  45201. /**
  45202. * Direct draw surface info
  45203. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45204. */
  45205. export interface DDSInfo {
  45206. /**
  45207. * Width of the texture
  45208. */
  45209. width: number;
  45210. /**
  45211. * Width of the texture
  45212. */
  45213. height: number;
  45214. /**
  45215. * Number of Mipmaps for the texture
  45216. * @see https://en.wikipedia.org/wiki/Mipmap
  45217. */
  45218. mipmapCount: number;
  45219. /**
  45220. * If the textures format is a known fourCC format
  45221. * @see https://www.fourcc.org/
  45222. */
  45223. isFourCC: boolean;
  45224. /**
  45225. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45226. */
  45227. isRGB: boolean;
  45228. /**
  45229. * If the texture is a lumincance format
  45230. */
  45231. isLuminance: boolean;
  45232. /**
  45233. * If this is a cube texture
  45234. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45235. */
  45236. isCube: boolean;
  45237. /**
  45238. * If the texture is a compressed format eg. FOURCC_DXT1
  45239. */
  45240. isCompressed: boolean;
  45241. /**
  45242. * The dxgiFormat of the texture
  45243. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45244. */
  45245. dxgiFormat: number;
  45246. /**
  45247. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45248. */
  45249. textureType: number;
  45250. /**
  45251. * Sphericle polynomial created for the dds texture
  45252. */
  45253. sphericalPolynomial?: SphericalPolynomial;
  45254. }
  45255. /**
  45256. * Class used to provide DDS decompression tools
  45257. */
  45258. export class DDSTools {
  45259. /**
  45260. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45261. */
  45262. static StoreLODInAlphaChannel: boolean;
  45263. /**
  45264. * Gets DDS information from an array buffer
  45265. * @param arrayBuffer defines the array buffer to read data from
  45266. * @returns the DDS information
  45267. */
  45268. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45269. private static _FloatView;
  45270. private static _Int32View;
  45271. private static _ToHalfFloat;
  45272. private static _FromHalfFloat;
  45273. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45274. private static _GetHalfFloatRGBAArrayBuffer;
  45275. private static _GetFloatRGBAArrayBuffer;
  45276. private static _GetFloatAsUIntRGBAArrayBuffer;
  45277. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45278. private static _GetRGBAArrayBuffer;
  45279. private static _ExtractLongWordOrder;
  45280. private static _GetRGBArrayBuffer;
  45281. private static _GetLuminanceArrayBuffer;
  45282. /**
  45283. * Uploads DDS Levels to a Babylon Texture
  45284. * @hidden
  45285. */
  45286. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45287. }
  45288. interface Engine {
  45289. /**
  45290. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45291. * @param rootUrl defines the url where the file to load is located
  45292. * @param scene defines the current scene
  45293. * @param lodScale defines scale to apply to the mip map selection
  45294. * @param lodOffset defines offset to apply to the mip map selection
  45295. * @param onLoad defines an optional callback raised when the texture is loaded
  45296. * @param onError defines an optional callback raised if there is an issue to load the texture
  45297. * @param format defines the format of the data
  45298. * @param forcedExtension defines the extension to use to pick the right loader
  45299. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45300. * @returns the cube texture as an InternalTexture
  45301. */
  45302. 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;
  45303. }
  45304. }
  45305. declare module BABYLON {
  45306. /**
  45307. * Implementation of the DDS Texture Loader.
  45308. * @hidden
  45309. */
  45310. export class _DDSTextureLoader implements IInternalTextureLoader {
  45311. /**
  45312. * Defines wether the loader supports cascade loading the different faces.
  45313. */
  45314. readonly supportCascades: boolean;
  45315. /**
  45316. * This returns if the loader support the current file information.
  45317. * @param extension defines the file extension of the file being loaded
  45318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45319. * @param fallback defines the fallback internal texture if any
  45320. * @param isBase64 defines whether the texture is encoded as a base64
  45321. * @param isBuffer defines whether the texture data are stored as a buffer
  45322. * @returns true if the loader can load the specified file
  45323. */
  45324. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45325. /**
  45326. * Transform the url before loading if required.
  45327. * @param rootUrl the url of the texture
  45328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45329. * @returns the transformed texture
  45330. */
  45331. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45332. /**
  45333. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45334. * @param rootUrl the url of the texture
  45335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45336. * @returns the fallback texture
  45337. */
  45338. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45339. /**
  45340. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45341. * @param data contains the texture data
  45342. * @param texture defines the BabylonJS internal texture
  45343. * @param createPolynomials will be true if polynomials have been requested
  45344. * @param onLoad defines the callback to trigger once the texture is ready
  45345. * @param onError defines the callback to trigger in case of error
  45346. */
  45347. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45348. /**
  45349. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45350. * @param data contains the texture data
  45351. * @param texture defines the BabylonJS internal texture
  45352. * @param callback defines the method to call once ready to upload
  45353. */
  45354. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45355. }
  45356. }
  45357. declare module BABYLON {
  45358. /** @hidden */
  45359. export var rgbdEncodePixelShader: {
  45360. name: string;
  45361. shader: string;
  45362. };
  45363. }
  45364. declare module BABYLON {
  45365. /**
  45366. * Raw texture data and descriptor sufficient for WebGL texture upload
  45367. */
  45368. export interface EnvironmentTextureInfo {
  45369. /**
  45370. * Version of the environment map
  45371. */
  45372. version: number;
  45373. /**
  45374. * Width of image
  45375. */
  45376. width: number;
  45377. /**
  45378. * Irradiance information stored in the file.
  45379. */
  45380. irradiance: any;
  45381. /**
  45382. * Specular information stored in the file.
  45383. */
  45384. specular: any;
  45385. }
  45386. /**
  45387. * Sets of helpers addressing the serialization and deserialization of environment texture
  45388. * stored in a BabylonJS env file.
  45389. * Those files are usually stored as .env files.
  45390. */
  45391. export class EnvironmentTextureTools {
  45392. /**
  45393. * Magic number identifying the env file.
  45394. */
  45395. private static _MagicBytes;
  45396. /**
  45397. * Gets the environment info from an env file.
  45398. * @param data The array buffer containing the .env bytes.
  45399. * @returns the environment file info (the json header) if successfully parsed.
  45400. */
  45401. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45402. /**
  45403. * Creates an environment texture from a loaded cube texture.
  45404. * @param texture defines the cube texture to convert in env file
  45405. * @return a promise containing the environment data if succesfull.
  45406. */
  45407. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45408. /**
  45409. * Creates a JSON representation of the spherical data.
  45410. * @param texture defines the texture containing the polynomials
  45411. * @return the JSON representation of the spherical info
  45412. */
  45413. private static _CreateEnvTextureIrradiance;
  45414. /**
  45415. * Uploads the texture info contained in the env file to the GPU.
  45416. * @param texture defines the internal texture to upload to
  45417. * @param arrayBuffer defines the buffer cotaining the data to load
  45418. * @param info defines the texture info retrieved through the GetEnvInfo method
  45419. * @returns a promise
  45420. */
  45421. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45422. /**
  45423. * Uploads the levels of image data to the GPU.
  45424. * @param texture defines the internal texture to upload to
  45425. * @param imageData defines the array buffer views of image data [mipmap][face]
  45426. * @returns a promise
  45427. */
  45428. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45429. /**
  45430. * Uploads spherical polynomials information to the texture.
  45431. * @param texture defines the texture we are trying to upload the information to
  45432. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45433. */
  45434. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45435. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45436. }
  45437. }
  45438. declare module BABYLON {
  45439. /**
  45440. * Implementation of the ENV Texture Loader.
  45441. * @hidden
  45442. */
  45443. export class _ENVTextureLoader implements IInternalTextureLoader {
  45444. /**
  45445. * Defines wether the loader supports cascade loading the different faces.
  45446. */
  45447. readonly supportCascades: boolean;
  45448. /**
  45449. * This returns if the loader support the current file information.
  45450. * @param extension defines the file extension of the file being loaded
  45451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45452. * @param fallback defines the fallback internal texture if any
  45453. * @param isBase64 defines whether the texture is encoded as a base64
  45454. * @param isBuffer defines whether the texture data are stored as a buffer
  45455. * @returns true if the loader can load the specified file
  45456. */
  45457. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45458. /**
  45459. * Transform the url before loading if required.
  45460. * @param rootUrl the url of the texture
  45461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45462. * @returns the transformed texture
  45463. */
  45464. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45465. /**
  45466. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45467. * @param rootUrl the url of the texture
  45468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45469. * @returns the fallback texture
  45470. */
  45471. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45472. /**
  45473. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45474. * @param data contains the texture data
  45475. * @param texture defines the BabylonJS internal texture
  45476. * @param createPolynomials will be true if polynomials have been requested
  45477. * @param onLoad defines the callback to trigger once the texture is ready
  45478. * @param onError defines the callback to trigger in case of error
  45479. */
  45480. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45481. /**
  45482. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45483. * @param data contains the texture data
  45484. * @param texture defines the BabylonJS internal texture
  45485. * @param callback defines the method to call once ready to upload
  45486. */
  45487. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45488. }
  45489. }
  45490. declare module BABYLON {
  45491. /**
  45492. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45493. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45494. */
  45495. export class KhronosTextureContainer {
  45496. /** contents of the KTX container file */
  45497. arrayBuffer: any;
  45498. private static HEADER_LEN;
  45499. private static COMPRESSED_2D;
  45500. private static COMPRESSED_3D;
  45501. private static TEX_2D;
  45502. private static TEX_3D;
  45503. /**
  45504. * Gets the openGL type
  45505. */
  45506. glType: number;
  45507. /**
  45508. * Gets the openGL type size
  45509. */
  45510. glTypeSize: number;
  45511. /**
  45512. * Gets the openGL format
  45513. */
  45514. glFormat: number;
  45515. /**
  45516. * Gets the openGL internal format
  45517. */
  45518. glInternalFormat: number;
  45519. /**
  45520. * Gets the base internal format
  45521. */
  45522. glBaseInternalFormat: number;
  45523. /**
  45524. * Gets image width in pixel
  45525. */
  45526. pixelWidth: number;
  45527. /**
  45528. * Gets image height in pixel
  45529. */
  45530. pixelHeight: number;
  45531. /**
  45532. * Gets image depth in pixels
  45533. */
  45534. pixelDepth: number;
  45535. /**
  45536. * Gets the number of array elements
  45537. */
  45538. numberOfArrayElements: number;
  45539. /**
  45540. * Gets the number of faces
  45541. */
  45542. numberOfFaces: number;
  45543. /**
  45544. * Gets the number of mipmap levels
  45545. */
  45546. numberOfMipmapLevels: number;
  45547. /**
  45548. * Gets the bytes of key value data
  45549. */
  45550. bytesOfKeyValueData: number;
  45551. /**
  45552. * Gets the load type
  45553. */
  45554. loadType: number;
  45555. /**
  45556. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45557. */
  45558. isInvalid: boolean;
  45559. /**
  45560. * Creates a new KhronosTextureContainer
  45561. * @param arrayBuffer contents of the KTX container file
  45562. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45563. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45564. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45565. */
  45566. constructor(
  45567. /** contents of the KTX container file */
  45568. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45569. /**
  45570. * Uploads KTX content to a Babylon Texture.
  45571. * It is assumed that the texture has already been created & is currently bound
  45572. * @hidden
  45573. */
  45574. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45575. private _upload2DCompressedLevels;
  45576. }
  45577. }
  45578. declare module BABYLON {
  45579. /**
  45580. * Implementation of the KTX Texture Loader.
  45581. * @hidden
  45582. */
  45583. export class _KTXTextureLoader implements IInternalTextureLoader {
  45584. /**
  45585. * Defines wether the loader supports cascade loading the different faces.
  45586. */
  45587. readonly supportCascades: boolean;
  45588. /**
  45589. * This returns if the loader support the current file information.
  45590. * @param extension defines the file extension of the file being loaded
  45591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45592. * @param fallback defines the fallback internal texture if any
  45593. * @param isBase64 defines whether the texture is encoded as a base64
  45594. * @param isBuffer defines whether the texture data are stored as a buffer
  45595. * @returns true if the loader can load the specified file
  45596. */
  45597. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45598. /**
  45599. * Transform the url before loading if required.
  45600. * @param rootUrl the url of the texture
  45601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45602. * @returns the transformed texture
  45603. */
  45604. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45605. /**
  45606. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45607. * @param rootUrl the url of the texture
  45608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45609. * @returns the fallback texture
  45610. */
  45611. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45612. /**
  45613. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45614. * @param data contains the texture data
  45615. * @param texture defines the BabylonJS internal texture
  45616. * @param createPolynomials will be true if polynomials have been requested
  45617. * @param onLoad defines the callback to trigger once the texture is ready
  45618. * @param onError defines the callback to trigger in case of error
  45619. */
  45620. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45621. /**
  45622. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45623. * @param data contains the texture data
  45624. * @param texture defines the BabylonJS internal texture
  45625. * @param callback defines the method to call once ready to upload
  45626. */
  45627. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. /** @hidden */
  45632. export var _forceSceneHelpersToBundle: boolean;
  45633. interface Scene {
  45634. /**
  45635. * Creates a default light for the scene.
  45636. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45637. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45638. */
  45639. createDefaultLight(replace?: boolean): void;
  45640. /**
  45641. * Creates a default camera for the scene.
  45642. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45643. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45644. * @param replace has default false, when true replaces the active camera in the scene
  45645. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45646. */
  45647. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45648. /**
  45649. * Creates a default camera and a default light.
  45650. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45651. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45652. * @param replace has the default false, when true replaces the active camera/light in the scene
  45653. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45654. */
  45655. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45656. /**
  45657. * Creates a new sky box
  45658. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45659. * @param environmentTexture defines the texture to use as environment texture
  45660. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45661. * @param scale defines the overall scale of the skybox
  45662. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45663. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45664. * @returns a new mesh holding the sky box
  45665. */
  45666. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45667. /**
  45668. * Creates a new environment
  45669. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45670. * @param options defines the options you can use to configure the environment
  45671. * @returns the new EnvironmentHelper
  45672. */
  45673. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45674. /**
  45675. * Creates a new VREXperienceHelper
  45676. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45677. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45678. * @returns a new VREXperienceHelper
  45679. */
  45680. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45681. /**
  45682. * Creates a new XREXperienceHelper
  45683. * @see http://doc.babylonjs.com/how_to/webxr
  45684. * @returns a promise for a new XREXperienceHelper
  45685. */
  45686. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45687. }
  45688. }
  45689. declare module BABYLON {
  45690. /**
  45691. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45692. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45693. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45695. */
  45696. export class VideoDome extends TransformNode {
  45697. /**
  45698. * Define the video source as a Monoscopic panoramic 360 video.
  45699. */
  45700. static readonly MODE_MONOSCOPIC: number;
  45701. /**
  45702. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45703. */
  45704. static readonly MODE_TOPBOTTOM: number;
  45705. /**
  45706. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45707. */
  45708. static readonly MODE_SIDEBYSIDE: number;
  45709. private _useDirectMapping;
  45710. /**
  45711. * The video texture being displayed on the sphere
  45712. */
  45713. protected _videoTexture: VideoTexture;
  45714. /**
  45715. * Gets the video texture being displayed on the sphere
  45716. */
  45717. readonly videoTexture: VideoTexture;
  45718. /**
  45719. * The skybox material
  45720. */
  45721. protected _material: BackgroundMaterial;
  45722. /**
  45723. * The surface used for the skybox
  45724. */
  45725. protected _mesh: Mesh;
  45726. /**
  45727. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45728. * Also see the options.resolution property.
  45729. */
  45730. fovMultiplier: number;
  45731. private _videoMode;
  45732. /**
  45733. * Gets or set the current video mode for the video. It can be:
  45734. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45735. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45736. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45737. */
  45738. videoMode: number;
  45739. /**
  45740. * Oberserver used in Stereoscopic VR Mode.
  45741. */
  45742. private _onBeforeCameraRenderObserver;
  45743. /**
  45744. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45745. * @param name Element's name, child elements will append suffixes for their own names.
  45746. * @param urlsOrVideo defines the url(s) or the video element to use
  45747. * @param options An object containing optional or exposed sub element properties
  45748. */
  45749. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45750. resolution?: number;
  45751. clickToPlay?: boolean;
  45752. autoPlay?: boolean;
  45753. loop?: boolean;
  45754. size?: number;
  45755. poster?: string;
  45756. faceForward?: boolean;
  45757. useDirectMapping?: boolean;
  45758. }, scene: Scene);
  45759. private _changeVideoMode;
  45760. /**
  45761. * Releases resources associated with this node.
  45762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45764. */
  45765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /**
  45770. * This class can be used to get instrumentation data from a Babylon engine
  45771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45772. */
  45773. export class EngineInstrumentation implements IDisposable {
  45774. /**
  45775. * Define the instrumented engine.
  45776. */
  45777. engine: Engine;
  45778. private _captureGPUFrameTime;
  45779. private _gpuFrameTimeToken;
  45780. private _gpuFrameTime;
  45781. private _captureShaderCompilationTime;
  45782. private _shaderCompilationTime;
  45783. private _onBeginFrameObserver;
  45784. private _onEndFrameObserver;
  45785. private _onBeforeShaderCompilationObserver;
  45786. private _onAfterShaderCompilationObserver;
  45787. /**
  45788. * Gets the perf counter used for GPU frame time
  45789. */
  45790. readonly gpuFrameTimeCounter: PerfCounter;
  45791. /**
  45792. * Gets the GPU frame time capture status
  45793. */
  45794. /**
  45795. * Enable or disable the GPU frame time capture
  45796. */
  45797. captureGPUFrameTime: boolean;
  45798. /**
  45799. * Gets the perf counter used for shader compilation time
  45800. */
  45801. readonly shaderCompilationTimeCounter: PerfCounter;
  45802. /**
  45803. * Gets the shader compilation time capture status
  45804. */
  45805. /**
  45806. * Enable or disable the shader compilation time capture
  45807. */
  45808. captureShaderCompilationTime: boolean;
  45809. /**
  45810. * Instantiates a new engine instrumentation.
  45811. * This class can be used to get instrumentation data from a Babylon engine
  45812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45813. * @param engine Defines the engine to instrument
  45814. */
  45815. constructor(
  45816. /**
  45817. * Define the instrumented engine.
  45818. */
  45819. engine: Engine);
  45820. /**
  45821. * Dispose and release associated resources.
  45822. */
  45823. dispose(): void;
  45824. }
  45825. }
  45826. declare module BABYLON {
  45827. /**
  45828. * This class can be used to get instrumentation data from a Babylon engine
  45829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45830. */
  45831. export class SceneInstrumentation implements IDisposable {
  45832. /**
  45833. * Defines the scene to instrument
  45834. */
  45835. scene: Scene;
  45836. private _captureActiveMeshesEvaluationTime;
  45837. private _activeMeshesEvaluationTime;
  45838. private _captureRenderTargetsRenderTime;
  45839. private _renderTargetsRenderTime;
  45840. private _captureFrameTime;
  45841. private _frameTime;
  45842. private _captureRenderTime;
  45843. private _renderTime;
  45844. private _captureInterFrameTime;
  45845. private _interFrameTime;
  45846. private _captureParticlesRenderTime;
  45847. private _particlesRenderTime;
  45848. private _captureSpritesRenderTime;
  45849. private _spritesRenderTime;
  45850. private _capturePhysicsTime;
  45851. private _physicsTime;
  45852. private _captureAnimationsTime;
  45853. private _animationsTime;
  45854. private _captureCameraRenderTime;
  45855. private _cameraRenderTime;
  45856. private _onBeforeActiveMeshesEvaluationObserver;
  45857. private _onAfterActiveMeshesEvaluationObserver;
  45858. private _onBeforeRenderTargetsRenderObserver;
  45859. private _onAfterRenderTargetsRenderObserver;
  45860. private _onAfterRenderObserver;
  45861. private _onBeforeDrawPhaseObserver;
  45862. private _onAfterDrawPhaseObserver;
  45863. private _onBeforeAnimationsObserver;
  45864. private _onBeforeParticlesRenderingObserver;
  45865. private _onAfterParticlesRenderingObserver;
  45866. private _onBeforeSpritesRenderingObserver;
  45867. private _onAfterSpritesRenderingObserver;
  45868. private _onBeforePhysicsObserver;
  45869. private _onAfterPhysicsObserver;
  45870. private _onAfterAnimationsObserver;
  45871. private _onBeforeCameraRenderObserver;
  45872. private _onAfterCameraRenderObserver;
  45873. /**
  45874. * Gets the perf counter used for active meshes evaluation time
  45875. */
  45876. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45877. /**
  45878. * Gets the active meshes evaluation time capture status
  45879. */
  45880. /**
  45881. * Enable or disable the active meshes evaluation time capture
  45882. */
  45883. captureActiveMeshesEvaluationTime: boolean;
  45884. /**
  45885. * Gets the perf counter used for render targets render time
  45886. */
  45887. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45888. /**
  45889. * Gets the render targets render time capture status
  45890. */
  45891. /**
  45892. * Enable or disable the render targets render time capture
  45893. */
  45894. captureRenderTargetsRenderTime: boolean;
  45895. /**
  45896. * Gets the perf counter used for particles render time
  45897. */
  45898. readonly particlesRenderTimeCounter: PerfCounter;
  45899. /**
  45900. * Gets the particles render time capture status
  45901. */
  45902. /**
  45903. * Enable or disable the particles render time capture
  45904. */
  45905. captureParticlesRenderTime: boolean;
  45906. /**
  45907. * Gets the perf counter used for sprites render time
  45908. */
  45909. readonly spritesRenderTimeCounter: PerfCounter;
  45910. /**
  45911. * Gets the sprites render time capture status
  45912. */
  45913. /**
  45914. * Enable or disable the sprites render time capture
  45915. */
  45916. captureSpritesRenderTime: boolean;
  45917. /**
  45918. * Gets the perf counter used for physics time
  45919. */
  45920. readonly physicsTimeCounter: PerfCounter;
  45921. /**
  45922. * Gets the physics time capture status
  45923. */
  45924. /**
  45925. * Enable or disable the physics time capture
  45926. */
  45927. capturePhysicsTime: boolean;
  45928. /**
  45929. * Gets the perf counter used for animations time
  45930. */
  45931. readonly animationsTimeCounter: PerfCounter;
  45932. /**
  45933. * Gets the animations time capture status
  45934. */
  45935. /**
  45936. * Enable or disable the animations time capture
  45937. */
  45938. captureAnimationsTime: boolean;
  45939. /**
  45940. * Gets the perf counter used for frame time capture
  45941. */
  45942. readonly frameTimeCounter: PerfCounter;
  45943. /**
  45944. * Gets the frame time capture status
  45945. */
  45946. /**
  45947. * Enable or disable the frame time capture
  45948. */
  45949. captureFrameTime: boolean;
  45950. /**
  45951. * Gets the perf counter used for inter-frames time capture
  45952. */
  45953. readonly interFrameTimeCounter: PerfCounter;
  45954. /**
  45955. * Gets the inter-frames time capture status
  45956. */
  45957. /**
  45958. * Enable or disable the inter-frames time capture
  45959. */
  45960. captureInterFrameTime: boolean;
  45961. /**
  45962. * Gets the perf counter used for render time capture
  45963. */
  45964. readonly renderTimeCounter: PerfCounter;
  45965. /**
  45966. * Gets the render time capture status
  45967. */
  45968. /**
  45969. * Enable or disable the render time capture
  45970. */
  45971. captureRenderTime: boolean;
  45972. /**
  45973. * Gets the perf counter used for camera render time capture
  45974. */
  45975. readonly cameraRenderTimeCounter: PerfCounter;
  45976. /**
  45977. * Gets the camera render time capture status
  45978. */
  45979. /**
  45980. * Enable or disable the camera render time capture
  45981. */
  45982. captureCameraRenderTime: boolean;
  45983. /**
  45984. * Gets the perf counter used for draw calls
  45985. */
  45986. readonly drawCallsCounter: PerfCounter;
  45987. /**
  45988. * Instantiates a new scene instrumentation.
  45989. * This class can be used to get instrumentation data from a Babylon engine
  45990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45991. * @param scene Defines the scene to instrument
  45992. */
  45993. constructor(
  45994. /**
  45995. * Defines the scene to instrument
  45996. */
  45997. scene: Scene);
  45998. /**
  45999. * Dispose and release associated resources.
  46000. */
  46001. dispose(): void;
  46002. }
  46003. }
  46004. declare module BABYLON {
  46005. /** @hidden */
  46006. export var glowMapGenerationPixelShader: {
  46007. name: string;
  46008. shader: string;
  46009. };
  46010. }
  46011. declare module BABYLON {
  46012. /** @hidden */
  46013. export var glowMapGenerationVertexShader: {
  46014. name: string;
  46015. shader: string;
  46016. };
  46017. }
  46018. declare module BABYLON {
  46019. /**
  46020. * Effect layer options. This helps customizing the behaviour
  46021. * of the effect layer.
  46022. */
  46023. export interface IEffectLayerOptions {
  46024. /**
  46025. * Multiplication factor apply to the canvas size to compute the render target size
  46026. * used to generated the objects (the smaller the faster).
  46027. */
  46028. mainTextureRatio: number;
  46029. /**
  46030. * Enforces a fixed size texture to ensure effect stability across devices.
  46031. */
  46032. mainTextureFixedSize?: number;
  46033. /**
  46034. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46035. */
  46036. alphaBlendingMode: number;
  46037. /**
  46038. * The camera attached to the layer.
  46039. */
  46040. camera: Nullable<Camera>;
  46041. /**
  46042. * The rendering group to draw the layer in.
  46043. */
  46044. renderingGroupId: number;
  46045. }
  46046. /**
  46047. * The effect layer Helps adding post process effect blended with the main pass.
  46048. *
  46049. * This can be for instance use to generate glow or higlight effects on the scene.
  46050. *
  46051. * The effect layer class can not be used directly and is intented to inherited from to be
  46052. * customized per effects.
  46053. */
  46054. export abstract class EffectLayer {
  46055. private _vertexBuffers;
  46056. private _indexBuffer;
  46057. private _cachedDefines;
  46058. private _effectLayerMapGenerationEffect;
  46059. private _effectLayerOptions;
  46060. private _mergeEffect;
  46061. protected _scene: Scene;
  46062. protected _engine: Engine;
  46063. protected _maxSize: number;
  46064. protected _mainTextureDesiredSize: ISize;
  46065. protected _mainTexture: RenderTargetTexture;
  46066. protected _shouldRender: boolean;
  46067. protected _postProcesses: PostProcess[];
  46068. protected _textures: BaseTexture[];
  46069. protected _emissiveTextureAndColor: {
  46070. texture: Nullable<BaseTexture>;
  46071. color: Color4;
  46072. };
  46073. /**
  46074. * The name of the layer
  46075. */
  46076. name: string;
  46077. /**
  46078. * The clear color of the texture used to generate the glow map.
  46079. */
  46080. neutralColor: Color4;
  46081. /**
  46082. * Specifies wether the highlight layer is enabled or not.
  46083. */
  46084. isEnabled: boolean;
  46085. /**
  46086. * Gets the camera attached to the layer.
  46087. */
  46088. readonly camera: Nullable<Camera>;
  46089. /**
  46090. * Gets the rendering group id the layer should render in.
  46091. */
  46092. readonly renderingGroupId: number;
  46093. /**
  46094. * An event triggered when the effect layer has been disposed.
  46095. */
  46096. onDisposeObservable: Observable<EffectLayer>;
  46097. /**
  46098. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46099. */
  46100. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46101. /**
  46102. * An event triggered when the generated texture is being merged in the scene.
  46103. */
  46104. onBeforeComposeObservable: Observable<EffectLayer>;
  46105. /**
  46106. * An event triggered when the generated texture has been merged in the scene.
  46107. */
  46108. onAfterComposeObservable: Observable<EffectLayer>;
  46109. /**
  46110. * An event triggered when the efffect layer changes its size.
  46111. */
  46112. onSizeChangedObservable: Observable<EffectLayer>;
  46113. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46114. /**
  46115. * Instantiates a new effect Layer and references it in the scene.
  46116. * @param name The name of the layer
  46117. * @param scene The scene to use the layer in
  46118. */
  46119. constructor(
  46120. /** The Friendly of the effect in the scene */
  46121. name: string, scene: Scene);
  46122. /**
  46123. * Get the effect name of the layer.
  46124. * @return The effect name
  46125. */
  46126. abstract getEffectName(): string;
  46127. /**
  46128. * Checks for the readiness of the element composing the layer.
  46129. * @param subMesh the mesh to check for
  46130. * @param useInstances specify wether or not to use instances to render the mesh
  46131. * @return true if ready otherwise, false
  46132. */
  46133. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46134. /**
  46135. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46136. * @returns true if the effect requires stencil during the main canvas render pass.
  46137. */
  46138. abstract needStencil(): boolean;
  46139. /**
  46140. * Create the merge effect. This is the shader use to blit the information back
  46141. * to the main canvas at the end of the scene rendering.
  46142. * @returns The effect containing the shader used to merge the effect on the main canvas
  46143. */
  46144. protected abstract _createMergeEffect(): Effect;
  46145. /**
  46146. * Creates the render target textures and post processes used in the effect layer.
  46147. */
  46148. protected abstract _createTextureAndPostProcesses(): void;
  46149. /**
  46150. * Implementation specific of rendering the generating effect on the main canvas.
  46151. * @param effect The effect used to render through
  46152. */
  46153. protected abstract _internalRender(effect: Effect): void;
  46154. /**
  46155. * Sets the required values for both the emissive texture and and the main color.
  46156. */
  46157. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46158. /**
  46159. * Free any resources and references associated to a mesh.
  46160. * Internal use
  46161. * @param mesh The mesh to free.
  46162. */
  46163. abstract _disposeMesh(mesh: Mesh): void;
  46164. /**
  46165. * Serializes this layer (Glow or Highlight for example)
  46166. * @returns a serialized layer object
  46167. */
  46168. abstract serialize?(): any;
  46169. /**
  46170. * Initializes the effect layer with the required options.
  46171. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46172. */
  46173. protected _init(options: Partial<IEffectLayerOptions>): void;
  46174. /**
  46175. * Generates the index buffer of the full screen quad blending to the main canvas.
  46176. */
  46177. private _generateIndexBuffer;
  46178. /**
  46179. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46180. */
  46181. private _genrateVertexBuffer;
  46182. /**
  46183. * Sets the main texture desired size which is the closest power of two
  46184. * of the engine canvas size.
  46185. */
  46186. private _setMainTextureSize;
  46187. /**
  46188. * Creates the main texture for the effect layer.
  46189. */
  46190. protected _createMainTexture(): void;
  46191. /**
  46192. * Adds specific effects defines.
  46193. * @param defines The defines to add specifics to.
  46194. */
  46195. protected _addCustomEffectDefines(defines: string[]): void;
  46196. /**
  46197. * Checks for the readiness of the element composing the layer.
  46198. * @param subMesh the mesh to check for
  46199. * @param useInstances specify wether or not to use instances to render the mesh
  46200. * @param emissiveTexture the associated emissive texture used to generate the glow
  46201. * @return true if ready otherwise, false
  46202. */
  46203. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46204. /**
  46205. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46206. */
  46207. render(): void;
  46208. /**
  46209. * Determine if a given mesh will be used in the current effect.
  46210. * @param mesh mesh to test
  46211. * @returns true if the mesh will be used
  46212. */
  46213. hasMesh(mesh: AbstractMesh): boolean;
  46214. /**
  46215. * Returns true if the layer contains information to display, otherwise false.
  46216. * @returns true if the glow layer should be rendered
  46217. */
  46218. shouldRender(): boolean;
  46219. /**
  46220. * Returns true if the mesh should render, otherwise false.
  46221. * @param mesh The mesh to render
  46222. * @returns true if it should render otherwise false
  46223. */
  46224. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46225. /**
  46226. * Returns true if the mesh can be rendered, otherwise false.
  46227. * @param mesh The mesh to render
  46228. * @param material The material used on the mesh
  46229. * @returns true if it can be rendered otherwise false
  46230. */
  46231. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46232. /**
  46233. * Returns true if the mesh should render, otherwise false.
  46234. * @param mesh The mesh to render
  46235. * @returns true if it should render otherwise false
  46236. */
  46237. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46238. /**
  46239. * Renders the submesh passed in parameter to the generation map.
  46240. */
  46241. protected _renderSubMesh(subMesh: SubMesh): void;
  46242. /**
  46243. * Rebuild the required buffers.
  46244. * @hidden Internal use only.
  46245. */ rebuild(): void;
  46246. /**
  46247. * Dispose only the render target textures and post process.
  46248. */
  46249. private _disposeTextureAndPostProcesses;
  46250. /**
  46251. * Dispose the highlight layer and free resources.
  46252. */
  46253. dispose(): void;
  46254. /**
  46255. * Gets the class name of the effect layer
  46256. * @returns the string with the class name of the effect layer
  46257. */
  46258. getClassName(): string;
  46259. /**
  46260. * Creates an effect layer from parsed effect layer data
  46261. * @param parsedEffectLayer defines effect layer data
  46262. * @param scene defines the current scene
  46263. * @param rootUrl defines the root URL containing the effect layer information
  46264. * @returns a parsed effect Layer
  46265. */
  46266. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. interface AbstractScene {
  46271. /**
  46272. * The list of effect layers (highlights/glow) added to the scene
  46273. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46274. * @see http://doc.babylonjs.com/how_to/glow_layer
  46275. */
  46276. effectLayers: Array<EffectLayer>;
  46277. /**
  46278. * Removes the given effect layer from this scene.
  46279. * @param toRemove defines the effect layer to remove
  46280. * @returns the index of the removed effect layer
  46281. */
  46282. removeEffectLayer(toRemove: EffectLayer): number;
  46283. /**
  46284. * Adds the given effect layer to this scene
  46285. * @param newEffectLayer defines the effect layer to add
  46286. */
  46287. addEffectLayer(newEffectLayer: EffectLayer): void;
  46288. }
  46289. /**
  46290. * Defines the layer scene component responsible to manage any effect layers
  46291. * in a given scene.
  46292. */
  46293. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46294. /**
  46295. * The component name helpfull to identify the component in the list of scene components.
  46296. */
  46297. readonly name: string;
  46298. /**
  46299. * The scene the component belongs to.
  46300. */
  46301. scene: Scene;
  46302. private _engine;
  46303. private _renderEffects;
  46304. private _needStencil;
  46305. private _previousStencilState;
  46306. /**
  46307. * Creates a new instance of the component for the given scene
  46308. * @param scene Defines the scene to register the component in
  46309. */
  46310. constructor(scene: Scene);
  46311. /**
  46312. * Registers the component in a given scene
  46313. */
  46314. register(): void;
  46315. /**
  46316. * Rebuilds the elements related to this component in case of
  46317. * context lost for instance.
  46318. */
  46319. rebuild(): void;
  46320. /**
  46321. * Serializes the component data to the specified json object
  46322. * @param serializationObject The object to serialize to
  46323. */
  46324. serialize(serializationObject: any): void;
  46325. /**
  46326. * Adds all the element from the container to the scene
  46327. * @param container the container holding the elements
  46328. */
  46329. addFromContainer(container: AbstractScene): void;
  46330. /**
  46331. * Removes all the elements in the container from the scene
  46332. * @param container contains the elements to remove
  46333. * @param dispose if the removed element should be disposed (default: false)
  46334. */
  46335. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46336. /**
  46337. * Disposes the component and the associated ressources.
  46338. */
  46339. dispose(): void;
  46340. private _isReadyForMesh;
  46341. private _renderMainTexture;
  46342. private _setStencil;
  46343. private _setStencilBack;
  46344. private _draw;
  46345. private _drawCamera;
  46346. private _drawRenderingGroup;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /** @hidden */
  46351. export var glowMapMergePixelShader: {
  46352. name: string;
  46353. shader: string;
  46354. };
  46355. }
  46356. declare module BABYLON {
  46357. /** @hidden */
  46358. export var glowMapMergeVertexShader: {
  46359. name: string;
  46360. shader: string;
  46361. };
  46362. }
  46363. declare module BABYLON {
  46364. interface AbstractScene {
  46365. /**
  46366. * Return a the first highlight layer of the scene with a given name.
  46367. * @param name The name of the highlight layer to look for.
  46368. * @return The highlight layer if found otherwise null.
  46369. */
  46370. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46371. }
  46372. /**
  46373. * Glow layer options. This helps customizing the behaviour
  46374. * of the glow layer.
  46375. */
  46376. export interface IGlowLayerOptions {
  46377. /**
  46378. * Multiplication factor apply to the canvas size to compute the render target size
  46379. * used to generated the glowing objects (the smaller the faster).
  46380. */
  46381. mainTextureRatio: number;
  46382. /**
  46383. * Enforces a fixed size texture to ensure resize independant blur.
  46384. */
  46385. mainTextureFixedSize?: number;
  46386. /**
  46387. * How big is the kernel of the blur texture.
  46388. */
  46389. blurKernelSize: number;
  46390. /**
  46391. * The camera attached to the layer.
  46392. */
  46393. camera: Nullable<Camera>;
  46394. /**
  46395. * Enable MSAA by chosing the number of samples.
  46396. */
  46397. mainTextureSamples?: number;
  46398. /**
  46399. * The rendering group to draw the layer in.
  46400. */
  46401. renderingGroupId: number;
  46402. }
  46403. /**
  46404. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46405. *
  46406. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46407. * glowy meshes to your scene.
  46408. *
  46409. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46410. */
  46411. export class GlowLayer extends EffectLayer {
  46412. /**
  46413. * Effect Name of the layer.
  46414. */
  46415. static readonly EffectName: string;
  46416. /**
  46417. * The default blur kernel size used for the glow.
  46418. */
  46419. static DefaultBlurKernelSize: number;
  46420. /**
  46421. * The default texture size ratio used for the glow.
  46422. */
  46423. static DefaultTextureRatio: number;
  46424. /**
  46425. * Sets the kernel size of the blur.
  46426. */
  46427. /**
  46428. * Gets the kernel size of the blur.
  46429. */
  46430. blurKernelSize: number;
  46431. /**
  46432. * Sets the glow intensity.
  46433. */
  46434. /**
  46435. * Gets the glow intensity.
  46436. */
  46437. intensity: number;
  46438. private _options;
  46439. private _intensity;
  46440. private _horizontalBlurPostprocess1;
  46441. private _verticalBlurPostprocess1;
  46442. private _horizontalBlurPostprocess2;
  46443. private _verticalBlurPostprocess2;
  46444. private _blurTexture1;
  46445. private _blurTexture2;
  46446. private _postProcesses1;
  46447. private _postProcesses2;
  46448. private _includedOnlyMeshes;
  46449. private _excludedMeshes;
  46450. /**
  46451. * Callback used to let the user override the color selection on a per mesh basis
  46452. */
  46453. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46454. /**
  46455. * Callback used to let the user override the texture selection on a per mesh basis
  46456. */
  46457. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46458. /**
  46459. * Instantiates a new glow Layer and references it to the scene.
  46460. * @param name The name of the layer
  46461. * @param scene The scene to use the layer in
  46462. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46463. */
  46464. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46465. /**
  46466. * Get the effect name of the layer.
  46467. * @return The effect name
  46468. */
  46469. getEffectName(): string;
  46470. /**
  46471. * Create the merge effect. This is the shader use to blit the information back
  46472. * to the main canvas at the end of the scene rendering.
  46473. */
  46474. protected _createMergeEffect(): Effect;
  46475. /**
  46476. * Creates the render target textures and post processes used in the glow layer.
  46477. */
  46478. protected _createTextureAndPostProcesses(): void;
  46479. /**
  46480. * Checks for the readiness of the element composing the layer.
  46481. * @param subMesh the mesh to check for
  46482. * @param useInstances specify wether or not to use instances to render the mesh
  46483. * @param emissiveTexture the associated emissive texture used to generate the glow
  46484. * @return true if ready otherwise, false
  46485. */
  46486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46487. /**
  46488. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46489. */
  46490. needStencil(): boolean;
  46491. /**
  46492. * Returns true if the mesh can be rendered, otherwise false.
  46493. * @param mesh The mesh to render
  46494. * @param material The material used on the mesh
  46495. * @returns true if it can be rendered otherwise false
  46496. */
  46497. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46498. /**
  46499. * Implementation specific of rendering the generating effect on the main canvas.
  46500. * @param effect The effect used to render through
  46501. */
  46502. protected _internalRender(effect: Effect): void;
  46503. /**
  46504. * Sets the required values for both the emissive texture and and the main color.
  46505. */
  46506. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46507. /**
  46508. * Returns true if the mesh should render, otherwise false.
  46509. * @param mesh The mesh to render
  46510. * @returns true if it should render otherwise false
  46511. */
  46512. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46513. /**
  46514. * Adds specific effects defines.
  46515. * @param defines The defines to add specifics to.
  46516. */
  46517. protected _addCustomEffectDefines(defines: string[]): void;
  46518. /**
  46519. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46520. * @param mesh The mesh to exclude from the glow layer
  46521. */
  46522. addExcludedMesh(mesh: Mesh): void;
  46523. /**
  46524. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46525. * @param mesh The mesh to remove
  46526. */
  46527. removeExcludedMesh(mesh: Mesh): void;
  46528. /**
  46529. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46530. * @param mesh The mesh to include in the glow layer
  46531. */
  46532. addIncludedOnlyMesh(mesh: Mesh): void;
  46533. /**
  46534. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46535. * @param mesh The mesh to remove
  46536. */
  46537. removeIncludedOnlyMesh(mesh: Mesh): void;
  46538. /**
  46539. * Determine if a given mesh will be used in the glow layer
  46540. * @param mesh The mesh to test
  46541. * @returns true if the mesh will be highlighted by the current glow layer
  46542. */
  46543. hasMesh(mesh: AbstractMesh): boolean;
  46544. /**
  46545. * Free any resources and references associated to a mesh.
  46546. * Internal use
  46547. * @param mesh The mesh to free.
  46548. * @hidden
  46549. */ disposeMesh(mesh: Mesh): void;
  46550. /**
  46551. * Gets the class name of the effect layer
  46552. * @returns the string with the class name of the effect layer
  46553. */
  46554. getClassName(): string;
  46555. /**
  46556. * Serializes this glow layer
  46557. * @returns a serialized glow layer object
  46558. */
  46559. serialize(): any;
  46560. /**
  46561. * Creates a Glow Layer from parsed glow layer data
  46562. * @param parsedGlowLayer defines glow layer data
  46563. * @param scene defines the current scene
  46564. * @param rootUrl defines the root URL containing the glow layer information
  46565. * @returns a parsed Glow Layer
  46566. */
  46567. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46568. }
  46569. }
  46570. declare module BABYLON {
  46571. /** @hidden */
  46572. export var glowBlurPostProcessPixelShader: {
  46573. name: string;
  46574. shader: string;
  46575. };
  46576. }
  46577. declare module BABYLON {
  46578. interface AbstractScene {
  46579. /**
  46580. * Return a the first highlight layer of the scene with a given name.
  46581. * @param name The name of the highlight layer to look for.
  46582. * @return The highlight layer if found otherwise null.
  46583. */
  46584. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46585. }
  46586. /**
  46587. * Highlight layer options. This helps customizing the behaviour
  46588. * of the highlight layer.
  46589. */
  46590. export interface IHighlightLayerOptions {
  46591. /**
  46592. * Multiplication factor apply to the canvas size to compute the render target size
  46593. * used to generated the glowing objects (the smaller the faster).
  46594. */
  46595. mainTextureRatio: number;
  46596. /**
  46597. * Enforces a fixed size texture to ensure resize independant blur.
  46598. */
  46599. mainTextureFixedSize?: number;
  46600. /**
  46601. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46602. * of the picture to blur (the smaller the faster).
  46603. */
  46604. blurTextureSizeRatio: number;
  46605. /**
  46606. * How big in texel of the blur texture is the vertical blur.
  46607. */
  46608. blurVerticalSize: number;
  46609. /**
  46610. * How big in texel of the blur texture is the horizontal blur.
  46611. */
  46612. blurHorizontalSize: number;
  46613. /**
  46614. * Alpha blending mode used to apply the blur. Default is combine.
  46615. */
  46616. alphaBlendingMode: number;
  46617. /**
  46618. * The camera attached to the layer.
  46619. */
  46620. camera: Nullable<Camera>;
  46621. /**
  46622. * Should we display highlight as a solid stroke?
  46623. */
  46624. isStroke?: boolean;
  46625. /**
  46626. * The rendering group to draw the layer in.
  46627. */
  46628. renderingGroupId: number;
  46629. }
  46630. /**
  46631. * The highlight layer Helps adding a glow effect around a mesh.
  46632. *
  46633. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46634. * glowy meshes to your scene.
  46635. *
  46636. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46637. */
  46638. export class HighlightLayer extends EffectLayer {
  46639. name: string;
  46640. /**
  46641. * Effect Name of the highlight layer.
  46642. */
  46643. static readonly EffectName: string;
  46644. /**
  46645. * The neutral color used during the preparation of the glow effect.
  46646. * This is black by default as the blend operation is a blend operation.
  46647. */
  46648. static NeutralColor: Color4;
  46649. /**
  46650. * Stencil value used for glowing meshes.
  46651. */
  46652. static GlowingMeshStencilReference: number;
  46653. /**
  46654. * Stencil value used for the other meshes in the scene.
  46655. */
  46656. static NormalMeshStencilReference: number;
  46657. /**
  46658. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46659. */
  46660. innerGlow: boolean;
  46661. /**
  46662. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46663. */
  46664. outerGlow: boolean;
  46665. /**
  46666. * Specifies the horizontal size of the blur.
  46667. */
  46668. /**
  46669. * Gets the horizontal size of the blur.
  46670. */
  46671. blurHorizontalSize: number;
  46672. /**
  46673. * Specifies the vertical size of the blur.
  46674. */
  46675. /**
  46676. * Gets the vertical size of the blur.
  46677. */
  46678. blurVerticalSize: number;
  46679. /**
  46680. * An event triggered when the highlight layer is being blurred.
  46681. */
  46682. onBeforeBlurObservable: Observable<HighlightLayer>;
  46683. /**
  46684. * An event triggered when the highlight layer has been blurred.
  46685. */
  46686. onAfterBlurObservable: Observable<HighlightLayer>;
  46687. private _instanceGlowingMeshStencilReference;
  46688. private _options;
  46689. private _downSamplePostprocess;
  46690. private _horizontalBlurPostprocess;
  46691. private _verticalBlurPostprocess;
  46692. private _blurTexture;
  46693. private _meshes;
  46694. private _excludedMeshes;
  46695. /**
  46696. * Instantiates a new highlight Layer and references it to the scene..
  46697. * @param name The name of the layer
  46698. * @param scene The scene to use the layer in
  46699. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46700. */
  46701. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46702. /**
  46703. * Get the effect name of the layer.
  46704. * @return The effect name
  46705. */
  46706. getEffectName(): string;
  46707. /**
  46708. * Create the merge effect. This is the shader use to blit the information back
  46709. * to the main canvas at the end of the scene rendering.
  46710. */
  46711. protected _createMergeEffect(): Effect;
  46712. /**
  46713. * Creates the render target textures and post processes used in the highlight layer.
  46714. */
  46715. protected _createTextureAndPostProcesses(): void;
  46716. /**
  46717. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46718. */
  46719. needStencil(): boolean;
  46720. /**
  46721. * Checks for the readiness of the element composing the layer.
  46722. * @param subMesh the mesh to check for
  46723. * @param useInstances specify wether or not to use instances to render the mesh
  46724. * @param emissiveTexture the associated emissive texture used to generate the glow
  46725. * @return true if ready otherwise, false
  46726. */
  46727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46728. /**
  46729. * Implementation specific of rendering the generating effect on the main canvas.
  46730. * @param effect The effect used to render through
  46731. */
  46732. protected _internalRender(effect: Effect): void;
  46733. /**
  46734. * Returns true if the layer contains information to display, otherwise false.
  46735. */
  46736. shouldRender(): boolean;
  46737. /**
  46738. * Returns true if the mesh should render, otherwise false.
  46739. * @param mesh The mesh to render
  46740. * @returns true if it should render otherwise false
  46741. */
  46742. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46743. /**
  46744. * Sets the required values for both the emissive texture and and the main color.
  46745. */
  46746. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46747. /**
  46748. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46749. * @param mesh The mesh to exclude from the highlight layer
  46750. */
  46751. addExcludedMesh(mesh: Mesh): void;
  46752. /**
  46753. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46754. * @param mesh The mesh to highlight
  46755. */
  46756. removeExcludedMesh(mesh: Mesh): void;
  46757. /**
  46758. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46759. * @param mesh mesh to test
  46760. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46761. */
  46762. hasMesh(mesh: AbstractMesh): boolean;
  46763. /**
  46764. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46765. * @param mesh The mesh to highlight
  46766. * @param color The color of the highlight
  46767. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46768. */
  46769. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46770. /**
  46771. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46772. * @param mesh The mesh to highlight
  46773. */
  46774. removeMesh(mesh: Mesh): void;
  46775. /**
  46776. * Force the stencil to the normal expected value for none glowing parts
  46777. */
  46778. private _defaultStencilReference;
  46779. /**
  46780. * Free any resources and references associated to a mesh.
  46781. * Internal use
  46782. * @param mesh The mesh to free.
  46783. * @hidden
  46784. */ disposeMesh(mesh: Mesh): void;
  46785. /**
  46786. * Dispose the highlight layer and free resources.
  46787. */
  46788. dispose(): void;
  46789. /**
  46790. * Gets the class name of the effect layer
  46791. * @returns the string with the class name of the effect layer
  46792. */
  46793. getClassName(): string;
  46794. /**
  46795. * Serializes this Highlight layer
  46796. * @returns a serialized Highlight layer object
  46797. */
  46798. serialize(): any;
  46799. /**
  46800. * Creates a Highlight layer from parsed Highlight layer data
  46801. * @param parsedHightlightLayer defines the Highlight layer data
  46802. * @param scene defines the current scene
  46803. * @param rootUrl defines the root URL containing the Highlight layer information
  46804. * @returns a parsed Highlight layer
  46805. */
  46806. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46807. }
  46808. }
  46809. declare module BABYLON {
  46810. /** @hidden */
  46811. export var lensFlarePixelShader: {
  46812. name: string;
  46813. shader: string;
  46814. };
  46815. }
  46816. declare module BABYLON {
  46817. /** @hidden */
  46818. export var lensFlareVertexShader: {
  46819. name: string;
  46820. shader: string;
  46821. };
  46822. }
  46823. declare module BABYLON {
  46824. /**
  46825. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46826. * It is usually composed of several `lensFlare`.
  46827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46828. */
  46829. export class LensFlareSystem {
  46830. /**
  46831. * Define the name of the lens flare system
  46832. */
  46833. name: string;
  46834. /**
  46835. * List of lens flares used in this system.
  46836. */
  46837. lensFlares: LensFlare[];
  46838. /**
  46839. * Define a limit from the border the lens flare can be visible.
  46840. */
  46841. borderLimit: number;
  46842. /**
  46843. * Define a viewport border we do not want to see the lens flare in.
  46844. */
  46845. viewportBorder: number;
  46846. /**
  46847. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46848. */
  46849. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46850. /**
  46851. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46852. */
  46853. layerMask: number;
  46854. /**
  46855. * Define the id of the lens flare system in the scene.
  46856. * (equal to name by default)
  46857. */
  46858. id: string;
  46859. private _scene;
  46860. private _emitter;
  46861. private _vertexBuffers;
  46862. private _indexBuffer;
  46863. private _effect;
  46864. private _positionX;
  46865. private _positionY;
  46866. private _isEnabled;
  46867. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46868. /**
  46869. * Instantiates a lens flare system.
  46870. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46871. * It is usually composed of several `lensFlare`.
  46872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46873. * @param name Define the name of the lens flare system in the scene
  46874. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46875. * @param scene Define the scene the lens flare system belongs to
  46876. */
  46877. constructor(
  46878. /**
  46879. * Define the name of the lens flare system
  46880. */
  46881. name: string, emitter: any, scene: Scene);
  46882. /**
  46883. * Define if the lens flare system is enabled.
  46884. */
  46885. isEnabled: boolean;
  46886. /**
  46887. * Get the scene the effects belongs to.
  46888. * @returns the scene holding the lens flare system
  46889. */
  46890. getScene(): Scene;
  46891. /**
  46892. * Get the emitter of the lens flare system.
  46893. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46894. * @returns the emitter of the lens flare system
  46895. */
  46896. getEmitter(): any;
  46897. /**
  46898. * Set the emitter of the lens flare system.
  46899. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46900. * @param newEmitter Define the new emitter of the system
  46901. */
  46902. setEmitter(newEmitter: any): void;
  46903. /**
  46904. * Get the lens flare system emitter position.
  46905. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46906. * @returns the position
  46907. */
  46908. getEmitterPosition(): Vector3;
  46909. /**
  46910. * @hidden
  46911. */
  46912. computeEffectivePosition(globalViewport: Viewport): boolean;
  46913. /** @hidden */ isVisible(): boolean;
  46914. /**
  46915. * @hidden
  46916. */
  46917. render(): boolean;
  46918. /**
  46919. * Dispose and release the lens flare with its associated resources.
  46920. */
  46921. dispose(): void;
  46922. /**
  46923. * Parse a lens flare system from a JSON repressentation
  46924. * @param parsedLensFlareSystem Define the JSON to parse
  46925. * @param scene Define the scene the parsed system should be instantiated in
  46926. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46927. * @returns the parsed system
  46928. */
  46929. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46930. /**
  46931. * Serialize the current Lens Flare System into a JSON representation.
  46932. * @returns the serialized JSON
  46933. */
  46934. serialize(): any;
  46935. }
  46936. }
  46937. declare module BABYLON {
  46938. /**
  46939. * This represents one of the lens effect in a `lensFlareSystem`.
  46940. * It controls one of the indiviual texture used in the effect.
  46941. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46942. */
  46943. export class LensFlare {
  46944. /**
  46945. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46946. */
  46947. size: number;
  46948. /**
  46949. * 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.
  46950. */
  46951. position: number;
  46952. /**
  46953. * Define the lens color.
  46954. */
  46955. color: Color3;
  46956. /**
  46957. * Define the lens texture.
  46958. */
  46959. texture: Nullable<Texture>;
  46960. /**
  46961. * Define the alpha mode to render this particular lens.
  46962. */
  46963. alphaMode: number;
  46964. private _system;
  46965. /**
  46966. * Creates a new Lens Flare.
  46967. * This represents one of the lens effect in a `lensFlareSystem`.
  46968. * It controls one of the indiviual texture used in the effect.
  46969. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46970. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46971. * @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.
  46972. * @param color Define the lens color
  46973. * @param imgUrl Define the lens texture url
  46974. * @param system Define the `lensFlareSystem` this flare is part of
  46975. * @returns The newly created Lens Flare
  46976. */
  46977. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46978. /**
  46979. * Instantiates a new Lens Flare.
  46980. * This represents one of the lens effect in a `lensFlareSystem`.
  46981. * It controls one of the indiviual texture used in the effect.
  46982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46983. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46984. * @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.
  46985. * @param color Define the lens color
  46986. * @param imgUrl Define the lens texture url
  46987. * @param system Define the `lensFlareSystem` this flare is part of
  46988. */
  46989. constructor(
  46990. /**
  46991. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46992. */
  46993. size: number,
  46994. /**
  46995. * 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.
  46996. */
  46997. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46998. /**
  46999. * Dispose and release the lens flare with its associated resources.
  47000. */
  47001. dispose(): void;
  47002. }
  47003. }
  47004. declare module BABYLON {
  47005. interface AbstractScene {
  47006. /**
  47007. * The list of lens flare system added to the scene
  47008. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47009. */
  47010. lensFlareSystems: Array<LensFlareSystem>;
  47011. /**
  47012. * Removes the given lens flare system from this scene.
  47013. * @param toRemove The lens flare system to remove
  47014. * @returns The index of the removed lens flare system
  47015. */
  47016. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47017. /**
  47018. * Adds the given lens flare system to this scene
  47019. * @param newLensFlareSystem The lens flare system to add
  47020. */
  47021. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47022. /**
  47023. * Gets a lens flare system using its name
  47024. * @param name defines the name to look for
  47025. * @returns the lens flare system or null if not found
  47026. */
  47027. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47028. /**
  47029. * Gets a lens flare system using its id
  47030. * @param id defines the id to look for
  47031. * @returns the lens flare system or null if not found
  47032. */
  47033. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47034. }
  47035. /**
  47036. * Defines the lens flare scene component responsible to manage any lens flares
  47037. * in a given scene.
  47038. */
  47039. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47040. /**
  47041. * The component name helpfull to identify the component in the list of scene components.
  47042. */
  47043. readonly name: string;
  47044. /**
  47045. * The scene the component belongs to.
  47046. */
  47047. scene: Scene;
  47048. /**
  47049. * Creates a new instance of the component for the given scene
  47050. * @param scene Defines the scene to register the component in
  47051. */
  47052. constructor(scene: Scene);
  47053. /**
  47054. * Registers the component in a given scene
  47055. */
  47056. register(): void;
  47057. /**
  47058. * Rebuilds the elements related to this component in case of
  47059. * context lost for instance.
  47060. */
  47061. rebuild(): void;
  47062. /**
  47063. * Adds all the element from the container to the scene
  47064. * @param container the container holding the elements
  47065. */
  47066. addFromContainer(container: AbstractScene): void;
  47067. /**
  47068. * Removes all the elements in the container from the scene
  47069. * @param container contains the elements to remove
  47070. * @param dispose if the removed element should be disposed (default: false)
  47071. */
  47072. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47073. /**
  47074. * Serializes the component data to the specified json object
  47075. * @param serializationObject The object to serialize to
  47076. */
  47077. serialize(serializationObject: any): void;
  47078. /**
  47079. * Disposes the component and the associated ressources.
  47080. */
  47081. dispose(): void;
  47082. private _draw;
  47083. }
  47084. }
  47085. declare module BABYLON {
  47086. /**
  47087. * Defines the shadow generator component responsible to manage any shadow generators
  47088. * in a given scene.
  47089. */
  47090. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47091. /**
  47092. * The component name helpfull to identify the component in the list of scene components.
  47093. */
  47094. readonly name: string;
  47095. /**
  47096. * The scene the component belongs to.
  47097. */
  47098. scene: Scene;
  47099. /**
  47100. * Creates a new instance of the component for the given scene
  47101. * @param scene Defines the scene to register the component in
  47102. */
  47103. constructor(scene: Scene);
  47104. /**
  47105. * Registers the component in a given scene
  47106. */
  47107. register(): void;
  47108. /**
  47109. * Rebuilds the elements related to this component in case of
  47110. * context lost for instance.
  47111. */
  47112. rebuild(): void;
  47113. /**
  47114. * Serializes the component data to the specified json object
  47115. * @param serializationObject The object to serialize to
  47116. */
  47117. serialize(serializationObject: any): void;
  47118. /**
  47119. * Adds all the element from the container to the scene
  47120. * @param container the container holding the elements
  47121. */
  47122. addFromContainer(container: AbstractScene): void;
  47123. /**
  47124. * Removes all the elements in the container from the scene
  47125. * @param container contains the elements to remove
  47126. * @param dispose if the removed element should be disposed (default: false)
  47127. */
  47128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47129. /**
  47130. * Rebuilds the elements related to this component in case of
  47131. * context lost for instance.
  47132. */
  47133. dispose(): void;
  47134. private _gatherRenderTargets;
  47135. }
  47136. }
  47137. declare module BABYLON {
  47138. /**
  47139. * A point light is a light defined by an unique point in world space.
  47140. * The light is emitted in every direction from this point.
  47141. * A good example of a point light is a standard light bulb.
  47142. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47143. */
  47144. export class PointLight extends ShadowLight {
  47145. private _shadowAngle;
  47146. /**
  47147. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47148. * This specifies what angle the shadow will use to be created.
  47149. *
  47150. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47151. */
  47152. /**
  47153. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47154. * This specifies what angle the shadow will use to be created.
  47155. *
  47156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47157. */
  47158. shadowAngle: number;
  47159. /**
  47160. * Gets the direction if it has been set.
  47161. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47162. */
  47163. /**
  47164. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47165. */
  47166. direction: Vector3;
  47167. /**
  47168. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47169. * A PointLight emits the light in every direction.
  47170. * It can cast shadows.
  47171. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47172. * ```javascript
  47173. * var pointLight = new PointLight("pl", camera.position, scene);
  47174. * ```
  47175. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47176. * @param name The light friendly name
  47177. * @param position The position of the point light in the scene
  47178. * @param scene The scene the lights belongs to
  47179. */
  47180. constructor(name: string, position: Vector3, scene: Scene);
  47181. /**
  47182. * Returns the string "PointLight"
  47183. * @returns the class name
  47184. */
  47185. getClassName(): string;
  47186. /**
  47187. * Returns the integer 0.
  47188. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47189. */
  47190. getTypeID(): number;
  47191. /**
  47192. * Specifies wether or not the shadowmap should be a cube texture.
  47193. * @returns true if the shadowmap needs to be a cube texture.
  47194. */
  47195. needCube(): boolean;
  47196. /**
  47197. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47198. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47199. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47200. */
  47201. getShadowDirection(faceIndex?: number): Vector3;
  47202. /**
  47203. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47204. * - fov = PI / 2
  47205. * - aspect ratio : 1.0
  47206. * - z-near and far equal to the active camera minZ and maxZ.
  47207. * Returns the PointLight.
  47208. */
  47209. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47210. protected _buildUniformLayout(): void;
  47211. /**
  47212. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47213. * @param effect The effect to update
  47214. * @param lightIndex The index of the light in the effect to update
  47215. * @returns The point light
  47216. */
  47217. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47218. /**
  47219. * Prepares the list of defines specific to the light type.
  47220. * @param defines the list of defines
  47221. * @param lightIndex defines the index of the light for the effect
  47222. */
  47223. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47224. }
  47225. }
  47226. declare module BABYLON {
  47227. /**
  47228. * Header information of HDR texture files.
  47229. */
  47230. export interface HDRInfo {
  47231. /**
  47232. * The height of the texture in pixels.
  47233. */
  47234. height: number;
  47235. /**
  47236. * The width of the texture in pixels.
  47237. */
  47238. width: number;
  47239. /**
  47240. * The index of the beginning of the data in the binary file.
  47241. */
  47242. dataPosition: number;
  47243. }
  47244. /**
  47245. * This groups tools to convert HDR texture to native colors array.
  47246. */
  47247. export class HDRTools {
  47248. private static Ldexp;
  47249. private static Rgbe2float;
  47250. private static readStringLine;
  47251. /**
  47252. * Reads header information from an RGBE texture stored in a native array.
  47253. * More information on this format are available here:
  47254. * https://en.wikipedia.org/wiki/RGBE_image_format
  47255. *
  47256. * @param uint8array The binary file stored in native array.
  47257. * @return The header information.
  47258. */
  47259. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47260. /**
  47261. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47262. * This RGBE texture needs to store the information as a panorama.
  47263. *
  47264. * More information on this format are available here:
  47265. * https://en.wikipedia.org/wiki/RGBE_image_format
  47266. *
  47267. * @param buffer The binary file stored in an array buffer.
  47268. * @param size The expected size of the extracted cubemap.
  47269. * @return The Cube Map information.
  47270. */
  47271. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47272. /**
  47273. * Returns the pixels data extracted from an RGBE texture.
  47274. * This pixels will be stored left to right up to down in the R G B order in one array.
  47275. *
  47276. * More information on this format are available here:
  47277. * https://en.wikipedia.org/wiki/RGBE_image_format
  47278. *
  47279. * @param uint8array The binary file stored in an array buffer.
  47280. * @param hdrInfo The header information of the file.
  47281. * @return The pixels data in RGB right to left up to down order.
  47282. */
  47283. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47284. private static RGBE_ReadPixels_RLE;
  47285. }
  47286. }
  47287. declare module BABYLON {
  47288. /**
  47289. * This represents a texture coming from an HDR input.
  47290. *
  47291. * The only supported format is currently panorama picture stored in RGBE format.
  47292. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47293. */
  47294. export class HDRCubeTexture extends BaseTexture {
  47295. private static _facesMapping;
  47296. private _generateHarmonics;
  47297. private _noMipmap;
  47298. private _textureMatrix;
  47299. private _size;
  47300. private _onLoad;
  47301. private _onError;
  47302. /**
  47303. * The texture URL.
  47304. */
  47305. url: string;
  47306. /**
  47307. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47308. */
  47309. coordinatesMode: number;
  47310. protected _isBlocking: boolean;
  47311. /**
  47312. * Sets wether or not the texture is blocking during loading.
  47313. */
  47314. /**
  47315. * Gets wether or not the texture is blocking during loading.
  47316. */
  47317. isBlocking: boolean;
  47318. protected _rotationY: number;
  47319. /**
  47320. * Sets texture matrix rotation angle around Y axis in radians.
  47321. */
  47322. /**
  47323. * Gets texture matrix rotation angle around Y axis radians.
  47324. */
  47325. rotationY: number;
  47326. /**
  47327. * Gets or sets the center of the bounding box associated with the cube texture
  47328. * It must define where the camera used to render the texture was set
  47329. */
  47330. boundingBoxPosition: Vector3;
  47331. private _boundingBoxSize;
  47332. /**
  47333. * Gets or sets the size of the bounding box associated with the cube texture
  47334. * When defined, the cubemap will switch to local mode
  47335. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47336. * @example https://www.babylonjs-playground.com/#RNASML
  47337. */
  47338. boundingBoxSize: Vector3;
  47339. /**
  47340. * Instantiates an HDRTexture from the following parameters.
  47341. *
  47342. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47343. * @param scene The scene the texture will be used in
  47344. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47345. * @param noMipmap Forces to not generate the mipmap if true
  47346. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47347. * @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)
  47348. * @param reserved Reserved flag for internal use.
  47349. */
  47350. 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>);
  47351. /**
  47352. * Get the current class name of the texture useful for serialization or dynamic coding.
  47353. * @returns "HDRCubeTexture"
  47354. */
  47355. getClassName(): string;
  47356. /**
  47357. * Occurs when the file is raw .hdr file.
  47358. */
  47359. private loadTexture;
  47360. clone(): HDRCubeTexture;
  47361. delayLoad(): void;
  47362. /**
  47363. * Get the texture reflection matrix used to rotate/transform the reflection.
  47364. * @returns the reflection matrix
  47365. */
  47366. getReflectionTextureMatrix(): Matrix;
  47367. /**
  47368. * Set the texture reflection matrix used to rotate/transform the reflection.
  47369. * @param value Define the reflection matrix to set
  47370. */
  47371. setReflectionTextureMatrix(value: Matrix): void;
  47372. /**
  47373. * Parses a JSON representation of an HDR Texture in order to create the texture
  47374. * @param parsedTexture Define the JSON representation
  47375. * @param scene Define the scene the texture should be created in
  47376. * @param rootUrl Define the root url in case we need to load relative dependencies
  47377. * @returns the newly created texture after parsing
  47378. */
  47379. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47380. serialize(): any;
  47381. }
  47382. }
  47383. declare module BABYLON {
  47384. /**
  47385. * Class used to control physics engine
  47386. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47387. */
  47388. export class PhysicsEngine implements IPhysicsEngine {
  47389. private _physicsPlugin;
  47390. /**
  47391. * Global value used to control the smallest number supported by the simulation
  47392. */
  47393. static Epsilon: number;
  47394. private _impostors;
  47395. private _joints;
  47396. /**
  47397. * Gets the gravity vector used by the simulation
  47398. */
  47399. gravity: Vector3;
  47400. /**
  47401. * Factory used to create the default physics plugin.
  47402. * @returns The default physics plugin
  47403. */
  47404. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47405. /**
  47406. * Creates a new Physics Engine
  47407. * @param gravity defines the gravity vector used by the simulation
  47408. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47409. */
  47410. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47411. /**
  47412. * Sets the gravity vector used by the simulation
  47413. * @param gravity defines the gravity vector to use
  47414. */
  47415. setGravity(gravity: Vector3): void;
  47416. /**
  47417. * Set the time step of the physics engine.
  47418. * Default is 1/60.
  47419. * To slow it down, enter 1/600 for example.
  47420. * To speed it up, 1/30
  47421. * @param newTimeStep defines the new timestep to apply to this world.
  47422. */
  47423. setTimeStep(newTimeStep?: number): void;
  47424. /**
  47425. * Get the time step of the physics engine.
  47426. * @returns the current time step
  47427. */
  47428. getTimeStep(): number;
  47429. /**
  47430. * Release all resources
  47431. */
  47432. dispose(): void;
  47433. /**
  47434. * Gets the name of the current physics plugin
  47435. * @returns the name of the plugin
  47436. */
  47437. getPhysicsPluginName(): string;
  47438. /**
  47439. * Adding a new impostor for the impostor tracking.
  47440. * This will be done by the impostor itself.
  47441. * @param impostor the impostor to add
  47442. */
  47443. addImpostor(impostor: PhysicsImpostor): void;
  47444. /**
  47445. * Remove an impostor from the engine.
  47446. * This impostor and its mesh will not longer be updated by the physics engine.
  47447. * @param impostor the impostor to remove
  47448. */
  47449. removeImpostor(impostor: PhysicsImpostor): void;
  47450. /**
  47451. * Add a joint to the physics engine
  47452. * @param mainImpostor defines the main impostor to which the joint is added.
  47453. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47454. * @param joint defines the joint that will connect both impostors.
  47455. */
  47456. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47457. /**
  47458. * Removes a joint from the simulation
  47459. * @param mainImpostor defines the impostor used with the joint
  47460. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47461. * @param joint defines the joint to remove
  47462. */
  47463. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47464. /**
  47465. * Called by the scene. No need to call it.
  47466. * @param delta defines the timespam between frames
  47467. */ step(delta: number): void;
  47468. /**
  47469. * Gets the current plugin used to run the simulation
  47470. * @returns current plugin
  47471. */
  47472. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47473. /**
  47474. * Gets the list of physic impostors
  47475. * @returns an array of PhysicsImpostor
  47476. */
  47477. getImpostors(): Array<PhysicsImpostor>;
  47478. /**
  47479. * Gets the impostor for a physics enabled object
  47480. * @param object defines the object impersonated by the impostor
  47481. * @returns the PhysicsImpostor or null if not found
  47482. */
  47483. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47484. /**
  47485. * Gets the impostor for a physics body object
  47486. * @param body defines physics body used by the impostor
  47487. * @returns the PhysicsImpostor or null if not found
  47488. */
  47489. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47490. /**
  47491. * Does a raycast in the physics world
  47492. * @param from when should the ray start?
  47493. * @param to when should the ray end?
  47494. * @returns PhysicsRaycastResult
  47495. */
  47496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47497. }
  47498. }
  47499. declare module BABYLON {
  47500. /** @hidden */
  47501. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47502. private _useDeltaForWorldStep;
  47503. world: any;
  47504. name: string;
  47505. private _physicsMaterials;
  47506. private _fixedTimeStep;
  47507. private _cannonRaycastResult;
  47508. private _raycastResult;
  47509. private _removeAfterStep;
  47510. BJSCANNON: any;
  47511. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47512. setGravity(gravity: Vector3): void;
  47513. setTimeStep(timeStep: number): void;
  47514. getTimeStep(): number;
  47515. executeStep(delta: number): void;
  47516. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47517. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47518. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47519. private _processChildMeshes;
  47520. removePhysicsBody(impostor: PhysicsImpostor): void;
  47521. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47522. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47523. private _addMaterial;
  47524. private _checkWithEpsilon;
  47525. private _createShape;
  47526. private _createHeightmap;
  47527. private _minus90X;
  47528. private _plus90X;
  47529. private _tmpPosition;
  47530. private _tmpDeltaPosition;
  47531. private _tmpUnityRotation;
  47532. private _updatePhysicsBodyTransformation;
  47533. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47534. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47535. isSupported(): boolean;
  47536. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47537. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47538. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47539. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47540. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47541. getBodyMass(impostor: PhysicsImpostor): number;
  47542. getBodyFriction(impostor: PhysicsImpostor): number;
  47543. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47544. getBodyRestitution(impostor: PhysicsImpostor): number;
  47545. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47546. sleepBody(impostor: PhysicsImpostor): void;
  47547. wakeUpBody(impostor: PhysicsImpostor): void;
  47548. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47549. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47550. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47551. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47552. getRadius(impostor: PhysicsImpostor): number;
  47553. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47554. dispose(): void;
  47555. private _extendNamespace;
  47556. /**
  47557. * Does a raycast in the physics world
  47558. * @param from when should the ray start?
  47559. * @param to when should the ray end?
  47560. * @returns PhysicsRaycastResult
  47561. */
  47562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47563. }
  47564. }
  47565. declare module BABYLON {
  47566. /** @hidden */
  47567. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47568. world: any;
  47569. name: string;
  47570. BJSOIMO: any;
  47571. private _raycastResult;
  47572. constructor(iterations?: number, oimoInjection?: any);
  47573. setGravity(gravity: Vector3): void;
  47574. setTimeStep(timeStep: number): void;
  47575. getTimeStep(): number;
  47576. private _tmpImpostorsArray;
  47577. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47578. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47579. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47580. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47581. private _tmpPositionVector;
  47582. removePhysicsBody(impostor: PhysicsImpostor): void;
  47583. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47584. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47585. isSupported(): boolean;
  47586. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47587. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47588. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47589. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47590. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47591. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47592. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47593. getBodyMass(impostor: PhysicsImpostor): number;
  47594. getBodyFriction(impostor: PhysicsImpostor): number;
  47595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47596. getBodyRestitution(impostor: PhysicsImpostor): number;
  47597. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47598. sleepBody(impostor: PhysicsImpostor): void;
  47599. wakeUpBody(impostor: PhysicsImpostor): void;
  47600. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47601. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47604. getRadius(impostor: PhysicsImpostor): number;
  47605. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47606. dispose(): void;
  47607. /**
  47608. * Does a raycast in the physics world
  47609. * @param from when should the ray start?
  47610. * @param to when should the ray end?
  47611. * @returns PhysicsRaycastResult
  47612. */
  47613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47614. }
  47615. }
  47616. declare module BABYLON {
  47617. /**
  47618. * Class containing static functions to help procedurally build meshes
  47619. */
  47620. export class RibbonBuilder {
  47621. /**
  47622. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47623. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47624. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47625. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47626. * * 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
  47627. * * 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
  47628. * * 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
  47629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47630. * * 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
  47631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47632. * * 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
  47633. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47634. * * 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
  47635. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47637. * @param name defines the name of the mesh
  47638. * @param options defines the options used to create the mesh
  47639. * @param scene defines the hosting scene
  47640. * @returns the ribbon mesh
  47641. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47643. */
  47644. static CreateRibbon(name: string, options: {
  47645. pathArray: Vector3[][];
  47646. closeArray?: boolean;
  47647. closePath?: boolean;
  47648. offset?: number;
  47649. updatable?: boolean;
  47650. sideOrientation?: number;
  47651. frontUVs?: Vector4;
  47652. backUVs?: Vector4;
  47653. instance?: Mesh;
  47654. invertUV?: boolean;
  47655. uvs?: Vector2[];
  47656. colors?: Color4[];
  47657. }, scene?: Nullable<Scene>): Mesh;
  47658. }
  47659. }
  47660. declare module BABYLON {
  47661. /**
  47662. * Class containing static functions to help procedurally build meshes
  47663. */
  47664. export class ShapeBuilder {
  47665. /**
  47666. * 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.
  47667. * * 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.
  47668. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47669. * * 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.
  47670. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47671. * * 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
  47672. * * 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
  47673. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47675. * * 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
  47676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47678. * @param name defines the name of the mesh
  47679. * @param options defines the options used to create the mesh
  47680. * @param scene defines the hosting scene
  47681. * @returns the extruded shape mesh
  47682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47684. */
  47685. static ExtrudeShape(name: string, options: {
  47686. shape: Vector3[];
  47687. path: Vector3[];
  47688. scale?: number;
  47689. rotation?: number;
  47690. cap?: number;
  47691. updatable?: boolean;
  47692. sideOrientation?: number;
  47693. frontUVs?: Vector4;
  47694. backUVs?: Vector4;
  47695. instance?: Mesh;
  47696. invertUV?: boolean;
  47697. }, scene?: Nullable<Scene>): Mesh;
  47698. /**
  47699. * Creates an custom extruded shape mesh.
  47700. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47701. * * 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.
  47702. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47703. * * 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
  47704. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47705. * * 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
  47706. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47707. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47708. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47709. * * 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
  47710. * * 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
  47711. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47713. * * 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
  47714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47716. * @param name defines the name of the mesh
  47717. * @param options defines the options used to create the mesh
  47718. * @param scene defines the hosting scene
  47719. * @returns the custom extruded shape mesh
  47720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47721. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47723. */
  47724. static ExtrudeShapeCustom(name: string, options: {
  47725. shape: Vector3[];
  47726. path: Vector3[];
  47727. scaleFunction?: any;
  47728. rotationFunction?: any;
  47729. ribbonCloseArray?: boolean;
  47730. ribbonClosePath?: boolean;
  47731. cap?: number;
  47732. updatable?: boolean;
  47733. sideOrientation?: number;
  47734. frontUVs?: Vector4;
  47735. backUVs?: Vector4;
  47736. instance?: Mesh;
  47737. invertUV?: boolean;
  47738. }, scene?: Nullable<Scene>): Mesh;
  47739. private static _ExtrudeShapeGeneric;
  47740. }
  47741. }
  47742. declare module BABYLON {
  47743. /**
  47744. * AmmoJS Physics plugin
  47745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47746. * @see https://github.com/kripken/ammo.js/
  47747. */
  47748. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47749. private _useDeltaForWorldStep;
  47750. /**
  47751. * Reference to the Ammo library
  47752. */
  47753. bjsAMMO: any;
  47754. /**
  47755. * Created ammoJS world which physics bodies are added to
  47756. */
  47757. world: any;
  47758. /**
  47759. * Name of the plugin
  47760. */
  47761. name: string;
  47762. private _timeStep;
  47763. private _fixedTimeStep;
  47764. private _maxSteps;
  47765. private _tmpQuaternion;
  47766. private _tmpAmmoTransform;
  47767. private _tmpAmmoQuaternion;
  47768. private _tmpAmmoConcreteContactResultCallback;
  47769. private _collisionConfiguration;
  47770. private _dispatcher;
  47771. private _overlappingPairCache;
  47772. private _solver;
  47773. private _softBodySolver;
  47774. private _tmpAmmoVectorA;
  47775. private _tmpAmmoVectorB;
  47776. private _tmpAmmoVectorC;
  47777. private _tmpAmmoVectorD;
  47778. private _tmpContactCallbackResult;
  47779. private _tmpAmmoVectorRCA;
  47780. private _tmpAmmoVectorRCB;
  47781. private _raycastResult;
  47782. private static readonly DISABLE_COLLISION_FLAG;
  47783. private static readonly KINEMATIC_FLAG;
  47784. private static readonly DISABLE_DEACTIVATION_FLAG;
  47785. /**
  47786. * Initializes the ammoJS plugin
  47787. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47788. * @param ammoInjection can be used to inject your own ammo reference
  47789. */
  47790. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47791. /**
  47792. * Sets the gravity of the physics world (m/(s^2))
  47793. * @param gravity Gravity to set
  47794. */
  47795. setGravity(gravity: Vector3): void;
  47796. /**
  47797. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47798. * @param timeStep timestep to use in seconds
  47799. */
  47800. setTimeStep(timeStep: number): void;
  47801. /**
  47802. * 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)
  47803. * @param fixedTimeStep fixedTimeStep to use in seconds
  47804. */
  47805. setFixedTimeStep(fixedTimeStep: number): void;
  47806. /**
  47807. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47808. * @param maxSteps the maximum number of steps by the physics engine per frame
  47809. */
  47810. setMaxSteps(maxSteps: number): void;
  47811. /**
  47812. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47813. * @returns the current timestep in seconds
  47814. */
  47815. getTimeStep(): number;
  47816. private _isImpostorInContact;
  47817. private _isImpostorPairInContact;
  47818. private _stepSimulation;
  47819. /**
  47820. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47821. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47822. * After the step the babylon meshes are set to the position of the physics imposters
  47823. * @param delta amount of time to step forward
  47824. * @param impostors array of imposters to update before/after the step
  47825. */
  47826. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47827. /**
  47828. * Update babylon mesh to match physics world object
  47829. * @param impostor imposter to match
  47830. */
  47831. private _afterSoftStep;
  47832. /**
  47833. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47834. * @param impostor imposter to match
  47835. */
  47836. private _ropeStep;
  47837. /**
  47838. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47839. * @param impostor imposter to match
  47840. */
  47841. private _softbodyOrClothStep;
  47842. private _tmpVector;
  47843. private _tmpMatrix;
  47844. /**
  47845. * Applies an impulse on the imposter
  47846. * @param impostor imposter to apply impulse to
  47847. * @param force amount of force to be applied to the imposter
  47848. * @param contactPoint the location to apply the impulse on the imposter
  47849. */
  47850. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47851. /**
  47852. * Applies a force on the imposter
  47853. * @param impostor imposter to apply force
  47854. * @param force amount of force to be applied to the imposter
  47855. * @param contactPoint the location to apply the force on the imposter
  47856. */
  47857. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47858. /**
  47859. * Creates a physics body using the plugin
  47860. * @param impostor the imposter to create the physics body on
  47861. */
  47862. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47863. /**
  47864. * Removes the physics body from the imposter and disposes of the body's memory
  47865. * @param impostor imposter to remove the physics body from
  47866. */
  47867. removePhysicsBody(impostor: PhysicsImpostor): void;
  47868. /**
  47869. * Generates a joint
  47870. * @param impostorJoint the imposter joint to create the joint with
  47871. */
  47872. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47873. /**
  47874. * Removes a joint
  47875. * @param impostorJoint the imposter joint to remove the joint from
  47876. */
  47877. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47878. private _addMeshVerts;
  47879. /**
  47880. * Initialise the soft body vertices to match its object's (mesh) vertices
  47881. * Softbody vertices (nodes) are in world space and to match this
  47882. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47883. * @param impostor to create the softbody for
  47884. */
  47885. private _softVertexData;
  47886. /**
  47887. * Create an impostor's soft body
  47888. * @param impostor to create the softbody for
  47889. */
  47890. private _createSoftbody;
  47891. /**
  47892. * Create cloth for an impostor
  47893. * @param impostor to create the softbody for
  47894. */
  47895. private _createCloth;
  47896. /**
  47897. * Create rope for an impostor
  47898. * @param impostor to create the softbody for
  47899. */
  47900. private _createRope;
  47901. private _addHullVerts;
  47902. private _createShape;
  47903. /**
  47904. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47905. * @param impostor imposter containing the physics body and babylon object
  47906. */
  47907. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47908. /**
  47909. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47910. * @param impostor imposter containing the physics body and babylon object
  47911. * @param newPosition new position
  47912. * @param newRotation new rotation
  47913. */
  47914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47915. /**
  47916. * If this plugin is supported
  47917. * @returns true if its supported
  47918. */
  47919. isSupported(): boolean;
  47920. /**
  47921. * Sets the linear velocity of the physics body
  47922. * @param impostor imposter to set the velocity on
  47923. * @param velocity velocity to set
  47924. */
  47925. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47926. /**
  47927. * Sets the angular velocity of the physics body
  47928. * @param impostor imposter to set the velocity on
  47929. * @param velocity velocity to set
  47930. */
  47931. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47932. /**
  47933. * gets the linear velocity
  47934. * @param impostor imposter to get linear velocity from
  47935. * @returns linear velocity
  47936. */
  47937. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47938. /**
  47939. * gets the angular velocity
  47940. * @param impostor imposter to get angular velocity from
  47941. * @returns angular velocity
  47942. */
  47943. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47944. /**
  47945. * Sets the mass of physics body
  47946. * @param impostor imposter to set the mass on
  47947. * @param mass mass to set
  47948. */
  47949. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47950. /**
  47951. * Gets the mass of the physics body
  47952. * @param impostor imposter to get the mass from
  47953. * @returns mass
  47954. */
  47955. getBodyMass(impostor: PhysicsImpostor): number;
  47956. /**
  47957. * Gets friction of the impostor
  47958. * @param impostor impostor to get friction from
  47959. * @returns friction value
  47960. */
  47961. getBodyFriction(impostor: PhysicsImpostor): number;
  47962. /**
  47963. * Sets friction of the impostor
  47964. * @param impostor impostor to set friction on
  47965. * @param friction friction value
  47966. */
  47967. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47968. /**
  47969. * Gets restitution of the impostor
  47970. * @param impostor impostor to get restitution from
  47971. * @returns restitution value
  47972. */
  47973. getBodyRestitution(impostor: PhysicsImpostor): number;
  47974. /**
  47975. * Sets resitution of the impostor
  47976. * @param impostor impostor to set resitution on
  47977. * @param restitution resitution value
  47978. */
  47979. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47980. /**
  47981. * Gets pressure inside the impostor
  47982. * @param impostor impostor to get pressure from
  47983. * @returns pressure value
  47984. */
  47985. getBodyPressure(impostor: PhysicsImpostor): number;
  47986. /**
  47987. * Sets pressure inside a soft body impostor
  47988. * Cloth and rope must remain 0 pressure
  47989. * @param impostor impostor to set pressure on
  47990. * @param pressure pressure value
  47991. */
  47992. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47993. /**
  47994. * Gets stiffness of the impostor
  47995. * @param impostor impostor to get stiffness from
  47996. * @returns pressure value
  47997. */
  47998. getBodyStiffness(impostor: PhysicsImpostor): number;
  47999. /**
  48000. * Sets stiffness of the impostor
  48001. * @param impostor impostor to set stiffness on
  48002. * @param stiffness stiffness value from 0 to 1
  48003. */
  48004. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48005. /**
  48006. * Gets velocityIterations of the impostor
  48007. * @param impostor impostor to get velocity iterations from
  48008. * @returns velocityIterations value
  48009. */
  48010. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48011. /**
  48012. * Sets velocityIterations of the impostor
  48013. * @param impostor impostor to set velocity iterations on
  48014. * @param velocityIterations velocityIterations value
  48015. */
  48016. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48017. /**
  48018. * Gets positionIterations of the impostor
  48019. * @param impostor impostor to get position iterations from
  48020. * @returns positionIterations value
  48021. */
  48022. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48023. /**
  48024. * Sets positionIterations of the impostor
  48025. * @param impostor impostor to set position on
  48026. * @param positionIterations positionIterations value
  48027. */
  48028. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48029. /**
  48030. * Append an anchor to a cloth object
  48031. * @param impostor is the cloth impostor to add anchor to
  48032. * @param otherImpostor is the rigid impostor to anchor to
  48033. * @param width ratio across width from 0 to 1
  48034. * @param height ratio up height from 0 to 1
  48035. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48036. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48037. */
  48038. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48039. /**
  48040. * Append an hook to a rope object
  48041. * @param impostor is the rope impostor to add hook to
  48042. * @param otherImpostor is the rigid impostor to hook to
  48043. * @param length ratio along the rope from 0 to 1
  48044. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48045. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48046. */
  48047. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48048. /**
  48049. * Sleeps the physics body and stops it from being active
  48050. * @param impostor impostor to sleep
  48051. */
  48052. sleepBody(impostor: PhysicsImpostor): void;
  48053. /**
  48054. * Activates the physics body
  48055. * @param impostor impostor to activate
  48056. */
  48057. wakeUpBody(impostor: PhysicsImpostor): void;
  48058. /**
  48059. * Updates the distance parameters of the joint
  48060. * @param joint joint to update
  48061. * @param maxDistance maximum distance of the joint
  48062. * @param minDistance minimum distance of the joint
  48063. */
  48064. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48065. /**
  48066. * Sets a motor on the joint
  48067. * @param joint joint to set motor on
  48068. * @param speed speed of the motor
  48069. * @param maxForce maximum force of the motor
  48070. * @param motorIndex index of the motor
  48071. */
  48072. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48073. /**
  48074. * Sets the motors limit
  48075. * @param joint joint to set limit on
  48076. * @param upperLimit upper limit
  48077. * @param lowerLimit lower limit
  48078. */
  48079. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48080. /**
  48081. * Syncs the position and rotation of a mesh with the impostor
  48082. * @param mesh mesh to sync
  48083. * @param impostor impostor to update the mesh with
  48084. */
  48085. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48086. /**
  48087. * Gets the radius of the impostor
  48088. * @param impostor impostor to get radius from
  48089. * @returns the radius
  48090. */
  48091. getRadius(impostor: PhysicsImpostor): number;
  48092. /**
  48093. * Gets the box size of the impostor
  48094. * @param impostor impostor to get box size from
  48095. * @param result the resulting box size
  48096. */
  48097. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48098. /**
  48099. * Disposes of the impostor
  48100. */
  48101. dispose(): void;
  48102. /**
  48103. * Does a raycast in the physics world
  48104. * @param from when should the ray start?
  48105. * @param to when should the ray end?
  48106. * @returns PhysicsRaycastResult
  48107. */
  48108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48109. }
  48110. }
  48111. declare module BABYLON {
  48112. interface AbstractScene {
  48113. /**
  48114. * The list of reflection probes added to the scene
  48115. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48116. */
  48117. reflectionProbes: Array<ReflectionProbe>;
  48118. /**
  48119. * Removes the given reflection probe from this scene.
  48120. * @param toRemove The reflection probe to remove
  48121. * @returns The index of the removed reflection probe
  48122. */
  48123. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48124. /**
  48125. * Adds the given reflection probe to this scene.
  48126. * @param newReflectionProbe The reflection probe to add
  48127. */
  48128. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48129. }
  48130. /**
  48131. * Class used to generate realtime reflection / refraction cube textures
  48132. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48133. */
  48134. export class ReflectionProbe {
  48135. /** defines the name of the probe */
  48136. name: string;
  48137. private _scene;
  48138. private _renderTargetTexture;
  48139. private _projectionMatrix;
  48140. private _viewMatrix;
  48141. private _target;
  48142. private _add;
  48143. private _attachedMesh;
  48144. private _invertYAxis;
  48145. /** Gets or sets probe position (center of the cube map) */
  48146. position: Vector3;
  48147. /**
  48148. * Creates a new reflection probe
  48149. * @param name defines the name of the probe
  48150. * @param size defines the texture resolution (for each face)
  48151. * @param scene defines the hosting scene
  48152. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48153. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48154. */
  48155. constructor(
  48156. /** defines the name of the probe */
  48157. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48158. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48159. samples: number;
  48160. /** Gets or sets the refresh rate to use (on every frame by default) */
  48161. refreshRate: number;
  48162. /**
  48163. * Gets the hosting scene
  48164. * @returns a Scene
  48165. */
  48166. getScene(): Scene;
  48167. /** Gets the internal CubeTexture used to render to */
  48168. readonly cubeTexture: RenderTargetTexture;
  48169. /** Gets the list of meshes to render */
  48170. readonly renderList: Nullable<AbstractMesh[]>;
  48171. /**
  48172. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48173. * @param mesh defines the mesh to attach to
  48174. */
  48175. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48176. /**
  48177. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48178. * @param renderingGroupId The rendering group id corresponding to its index
  48179. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48180. */
  48181. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48182. /**
  48183. * Clean all associated resources
  48184. */
  48185. dispose(): void;
  48186. /**
  48187. * Converts the reflection probe information to a readable string for debug purpose.
  48188. * @param fullDetails Supports for multiple levels of logging within scene loading
  48189. * @returns the human readable reflection probe info
  48190. */
  48191. toString(fullDetails?: boolean): string;
  48192. /**
  48193. * Get the class name of the relfection probe.
  48194. * @returns "ReflectionProbe"
  48195. */
  48196. getClassName(): string;
  48197. /**
  48198. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48199. * @returns The JSON representation of the texture
  48200. */
  48201. serialize(): any;
  48202. /**
  48203. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48204. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48205. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48206. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48207. * @returns The parsed reflection probe if successful
  48208. */
  48209. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48210. }
  48211. }
  48212. declare module BABYLON {
  48213. /** @hidden */
  48214. export var _BabylonLoaderRegistered: boolean;
  48215. }
  48216. declare module BABYLON {
  48217. /**
  48218. * The Physically based simple base material of BJS.
  48219. *
  48220. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48221. * It is used as the base class for both the specGloss and metalRough conventions.
  48222. */
  48223. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48224. /**
  48225. * Number of Simultaneous lights allowed on the material.
  48226. */
  48227. maxSimultaneousLights: number;
  48228. /**
  48229. * If sets to true, disables all the lights affecting the material.
  48230. */
  48231. disableLighting: boolean;
  48232. /**
  48233. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48234. */
  48235. environmentTexture: BaseTexture;
  48236. /**
  48237. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48238. */
  48239. invertNormalMapX: boolean;
  48240. /**
  48241. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48242. */
  48243. invertNormalMapY: boolean;
  48244. /**
  48245. * Normal map used in the model.
  48246. */
  48247. normalTexture: BaseTexture;
  48248. /**
  48249. * Emissivie color used to self-illuminate the model.
  48250. */
  48251. emissiveColor: Color3;
  48252. /**
  48253. * Emissivie texture used to self-illuminate the model.
  48254. */
  48255. emissiveTexture: BaseTexture;
  48256. /**
  48257. * Occlusion Channel Strenght.
  48258. */
  48259. occlusionStrength: number;
  48260. /**
  48261. * Occlusion Texture of the material (adding extra occlusion effects).
  48262. */
  48263. occlusionTexture: BaseTexture;
  48264. /**
  48265. * Defines the alpha limits in alpha test mode.
  48266. */
  48267. alphaCutOff: number;
  48268. /**
  48269. * Gets the current double sided mode.
  48270. */
  48271. /**
  48272. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48273. */
  48274. doubleSided: boolean;
  48275. /**
  48276. * Stores the pre-calculated light information of a mesh in a texture.
  48277. */
  48278. lightmapTexture: BaseTexture;
  48279. /**
  48280. * If true, the light map contains occlusion information instead of lighting info.
  48281. */
  48282. useLightmapAsShadowmap: boolean;
  48283. /**
  48284. * Instantiates a new PBRMaterial instance.
  48285. *
  48286. * @param name The material name
  48287. * @param scene The scene the material will be use in.
  48288. */
  48289. constructor(name: string, scene: Scene);
  48290. getClassName(): string;
  48291. }
  48292. }
  48293. declare module BABYLON {
  48294. /**
  48295. * The PBR material of BJS following the metal roughness convention.
  48296. *
  48297. * This fits to the PBR convention in the GLTF definition:
  48298. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48299. */
  48300. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48301. /**
  48302. * The base color has two different interpretations depending on the value of metalness.
  48303. * When the material is a metal, the base color is the specific measured reflectance value
  48304. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48305. * of the material.
  48306. */
  48307. baseColor: Color3;
  48308. /**
  48309. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48310. * well as opacity information in the alpha channel.
  48311. */
  48312. baseTexture: BaseTexture;
  48313. /**
  48314. * Specifies the metallic scalar value of the material.
  48315. * Can also be used to scale the metalness values of the metallic texture.
  48316. */
  48317. metallic: number;
  48318. /**
  48319. * Specifies the roughness scalar value of the material.
  48320. * Can also be used to scale the roughness values of the metallic texture.
  48321. */
  48322. roughness: number;
  48323. /**
  48324. * Texture containing both the metallic value in the B channel and the
  48325. * roughness value in the G channel to keep better precision.
  48326. */
  48327. metallicRoughnessTexture: BaseTexture;
  48328. /**
  48329. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48330. *
  48331. * @param name The material name
  48332. * @param scene The scene the material will be use in.
  48333. */
  48334. constructor(name: string, scene: Scene);
  48335. /**
  48336. * Return the currrent class name of the material.
  48337. */
  48338. getClassName(): string;
  48339. /**
  48340. * Makes a duplicate of the current material.
  48341. * @param name - name to use for the new material.
  48342. */
  48343. clone(name: string): PBRMetallicRoughnessMaterial;
  48344. /**
  48345. * Serialize the material to a parsable JSON object.
  48346. */
  48347. serialize(): any;
  48348. /**
  48349. * Parses a JSON object correponding to the serialize function.
  48350. */
  48351. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48352. }
  48353. }
  48354. declare module BABYLON {
  48355. /**
  48356. * The PBR material of BJS following the specular glossiness convention.
  48357. *
  48358. * This fits to the PBR convention in the GLTF definition:
  48359. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48360. */
  48361. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48362. /**
  48363. * Specifies the diffuse color of the material.
  48364. */
  48365. diffuseColor: Color3;
  48366. /**
  48367. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48368. * channel.
  48369. */
  48370. diffuseTexture: BaseTexture;
  48371. /**
  48372. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48373. */
  48374. specularColor: Color3;
  48375. /**
  48376. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48377. */
  48378. glossiness: number;
  48379. /**
  48380. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48381. */
  48382. specularGlossinessTexture: BaseTexture;
  48383. /**
  48384. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48385. *
  48386. * @param name The material name
  48387. * @param scene The scene the material will be use in.
  48388. */
  48389. constructor(name: string, scene: Scene);
  48390. /**
  48391. * Return the currrent class name of the material.
  48392. */
  48393. getClassName(): string;
  48394. /**
  48395. * Makes a duplicate of the current material.
  48396. * @param name - name to use for the new material.
  48397. */
  48398. clone(name: string): PBRSpecularGlossinessMaterial;
  48399. /**
  48400. * Serialize the material to a parsable JSON object.
  48401. */
  48402. serialize(): any;
  48403. /**
  48404. * Parses a JSON object correponding to the serialize function.
  48405. */
  48406. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48412. * It can help converting any input color in a desired output one. This can then be used to create effects
  48413. * from sepia, black and white to sixties or futuristic rendering...
  48414. *
  48415. * The only supported format is currently 3dl.
  48416. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48417. */
  48418. export class ColorGradingTexture extends BaseTexture {
  48419. /**
  48420. * The current texture matrix. (will always be identity in color grading texture)
  48421. */
  48422. private _textureMatrix;
  48423. /**
  48424. * The texture URL.
  48425. */
  48426. url: string;
  48427. /**
  48428. * Empty line regex stored for GC.
  48429. */
  48430. private static _noneEmptyLineRegex;
  48431. private _engine;
  48432. /**
  48433. * Instantiates a ColorGradingTexture from the following parameters.
  48434. *
  48435. * @param url The location of the color gradind data (currently only supporting 3dl)
  48436. * @param scene The scene the texture will be used in
  48437. */
  48438. constructor(url: string, scene: Scene);
  48439. /**
  48440. * Returns the texture matrix used in most of the material.
  48441. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48442. */
  48443. getTextureMatrix(): Matrix;
  48444. /**
  48445. * Occurs when the file being loaded is a .3dl LUT file.
  48446. */
  48447. private load3dlTexture;
  48448. /**
  48449. * Starts the loading process of the texture.
  48450. */
  48451. private loadTexture;
  48452. /**
  48453. * Clones the color gradind texture.
  48454. */
  48455. clone(): ColorGradingTexture;
  48456. /**
  48457. * Called during delayed load for textures.
  48458. */
  48459. delayLoad(): void;
  48460. /**
  48461. * Parses a color grading texture serialized by Babylon.
  48462. * @param parsedTexture The texture information being parsedTexture
  48463. * @param scene The scene to load the texture in
  48464. * @param rootUrl The root url of the data assets to load
  48465. * @return A color gradind texture
  48466. */
  48467. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48468. /**
  48469. * Serializes the LUT texture to json format.
  48470. */
  48471. serialize(): any;
  48472. }
  48473. }
  48474. declare module BABYLON {
  48475. /**
  48476. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48477. */
  48478. export class EquiRectangularCubeTexture extends BaseTexture {
  48479. /** The six faces of the cube. */
  48480. private static _FacesMapping;
  48481. private _noMipmap;
  48482. private _onLoad;
  48483. private _onError;
  48484. /** The size of the cubemap. */
  48485. private _size;
  48486. /** The buffer of the image. */
  48487. private _buffer;
  48488. /** The width of the input image. */
  48489. private _width;
  48490. /** The height of the input image. */
  48491. private _height;
  48492. /** The URL to the image. */
  48493. url: string;
  48494. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48495. coordinatesMode: number;
  48496. /**
  48497. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48498. * @param url The location of the image
  48499. * @param scene The scene the texture will be used in
  48500. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48501. * @param noMipmap Forces to not generate the mipmap if true
  48502. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48503. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48504. * @param onLoad — defines a callback called when texture is loaded
  48505. * @param onError — defines a callback called if there is an error
  48506. */
  48507. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48508. /**
  48509. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48510. */
  48511. private loadImage;
  48512. /**
  48513. * Convert the image buffer into a cubemap and create a CubeTexture.
  48514. */
  48515. private loadTexture;
  48516. /**
  48517. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48518. * @param buffer The ArrayBuffer that should be converted.
  48519. * @returns The buffer as Float32Array.
  48520. */
  48521. private getFloat32ArrayFromArrayBuffer;
  48522. /**
  48523. * Get the current class name of the texture useful for serialization or dynamic coding.
  48524. * @returns "EquiRectangularCubeTexture"
  48525. */
  48526. getClassName(): string;
  48527. /**
  48528. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48529. * @returns A clone of the current EquiRectangularCubeTexture.
  48530. */
  48531. clone(): EquiRectangularCubeTexture;
  48532. }
  48533. }
  48534. declare module BABYLON {
  48535. /**
  48536. * Based on jsTGALoader - Javascript loader for TGA file
  48537. * By Vincent Thibault
  48538. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48539. */
  48540. export class TGATools {
  48541. private static _TYPE_INDEXED;
  48542. private static _TYPE_RGB;
  48543. private static _TYPE_GREY;
  48544. private static _TYPE_RLE_INDEXED;
  48545. private static _TYPE_RLE_RGB;
  48546. private static _TYPE_RLE_GREY;
  48547. private static _ORIGIN_MASK;
  48548. private static _ORIGIN_SHIFT;
  48549. private static _ORIGIN_BL;
  48550. private static _ORIGIN_BR;
  48551. private static _ORIGIN_UL;
  48552. private static _ORIGIN_UR;
  48553. /**
  48554. * Gets the header of a TGA file
  48555. * @param data defines the TGA data
  48556. * @returns the header
  48557. */
  48558. static GetTGAHeader(data: Uint8Array): any;
  48559. /**
  48560. * Uploads TGA content to a Babylon Texture
  48561. * @hidden
  48562. */
  48563. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48564. /** @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;
  48565. /** @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;
  48566. /** @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;
  48567. /** @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;
  48568. /** @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;
  48569. /** @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;
  48570. }
  48571. }
  48572. declare module BABYLON {
  48573. /**
  48574. * Implementation of the TGA Texture Loader.
  48575. * @hidden
  48576. */
  48577. export class _TGATextureLoader implements IInternalTextureLoader {
  48578. /**
  48579. * Defines wether the loader supports cascade loading the different faces.
  48580. */
  48581. readonly supportCascades: boolean;
  48582. /**
  48583. * This returns if the loader support the current file information.
  48584. * @param extension defines the file extension of the file being loaded
  48585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48586. * @param fallback defines the fallback internal texture if any
  48587. * @param isBase64 defines whether the texture is encoded as a base64
  48588. * @param isBuffer defines whether the texture data are stored as a buffer
  48589. * @returns true if the loader can load the specified file
  48590. */
  48591. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48592. /**
  48593. * Transform the url before loading if required.
  48594. * @param rootUrl the url of the texture
  48595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48596. * @returns the transformed texture
  48597. */
  48598. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48599. /**
  48600. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48601. * @param rootUrl the url of the texture
  48602. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48603. * @returns the fallback texture
  48604. */
  48605. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48606. /**
  48607. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48608. * @param data contains the texture data
  48609. * @param texture defines the BabylonJS internal texture
  48610. * @param createPolynomials will be true if polynomials have been requested
  48611. * @param onLoad defines the callback to trigger once the texture is ready
  48612. * @param onError defines the callback to trigger in case of error
  48613. */
  48614. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48615. /**
  48616. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48617. * @param data contains the texture data
  48618. * @param texture defines the BabylonJS internal texture
  48619. * @param callback defines the method to call once ready to upload
  48620. */
  48621. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48622. }
  48623. }
  48624. declare module BABYLON {
  48625. /**
  48626. * 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.
  48627. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48629. */
  48630. export class CustomProceduralTexture extends ProceduralTexture {
  48631. private _animate;
  48632. private _time;
  48633. private _config;
  48634. private _texturePath;
  48635. /**
  48636. * Instantiates a new Custom Procedural Texture.
  48637. * 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.
  48638. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48640. * @param name Define the name of the texture
  48641. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48642. * @param size Define the size of the texture to create
  48643. * @param scene Define the scene the texture belongs to
  48644. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48645. * @param generateMipMaps Define if the texture should creates mip maps or not
  48646. */
  48647. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48648. private _loadJson;
  48649. /**
  48650. * Is the texture ready to be used ? (rendered at least once)
  48651. * @returns true if ready, otherwise, false.
  48652. */
  48653. isReady(): boolean;
  48654. /**
  48655. * Render the texture to its associated render target.
  48656. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48657. */
  48658. render(useCameraPostProcess?: boolean): void;
  48659. /**
  48660. * Update the list of dependant textures samplers in the shader.
  48661. */
  48662. updateTextures(): void;
  48663. /**
  48664. * Update the uniform values of the procedural texture in the shader.
  48665. */
  48666. updateShaderUniforms(): void;
  48667. /**
  48668. * Define if the texture animates or not.
  48669. */
  48670. animate: boolean;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /** @hidden */
  48675. export var noisePixelShader: {
  48676. name: string;
  48677. shader: string;
  48678. };
  48679. }
  48680. declare module BABYLON {
  48681. /**
  48682. * Class used to generate noise procedural textures
  48683. */
  48684. export class NoiseProceduralTexture extends ProceduralTexture {
  48685. private _time;
  48686. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48687. brightness: number;
  48688. /** Defines the number of octaves to process */
  48689. octaves: number;
  48690. /** Defines the level of persistence (0.8 by default) */
  48691. persistence: number;
  48692. /** Gets or sets animation speed factor (default is 1) */
  48693. animationSpeedFactor: number;
  48694. /**
  48695. * Creates a new NoiseProceduralTexture
  48696. * @param name defines the name fo the texture
  48697. * @param size defines the size of the texture (default is 256)
  48698. * @param scene defines the hosting scene
  48699. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48700. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48701. */
  48702. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48703. private _updateShaderUniforms;
  48704. protected _getDefines(): string;
  48705. /** Generate the current state of the procedural texture */
  48706. render(useCameraPostProcess?: boolean): void;
  48707. /**
  48708. * Serializes this noise procedural texture
  48709. * @returns a serialized noise procedural texture object
  48710. */
  48711. serialize(): any;
  48712. /**
  48713. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48714. * @param parsedTexture defines parsed texture data
  48715. * @param scene defines the current scene
  48716. * @param rootUrl defines the root URL containing noise procedural texture information
  48717. * @returns a parsed NoiseProceduralTexture
  48718. */
  48719. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /**
  48724. * Raw cube texture where the raw buffers are passed in
  48725. */
  48726. export class RawCubeTexture extends CubeTexture {
  48727. /**
  48728. * Creates a cube texture where the raw buffers are passed in.
  48729. * @param scene defines the scene the texture is attached to
  48730. * @param data defines the array of data to use to create each face
  48731. * @param size defines the size of the textures
  48732. * @param format defines the format of the data
  48733. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48734. * @param generateMipMaps defines if the engine should generate the mip levels
  48735. * @param invertY defines if data must be stored with Y axis inverted
  48736. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48737. * @param compression defines the compression used (null by default)
  48738. */
  48739. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48740. /**
  48741. * Updates the raw cube texture.
  48742. * @param data defines the data to store
  48743. * @param format defines the data format
  48744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48745. * @param invertY defines if data must be stored with Y axis inverted
  48746. * @param compression defines the compression used (null by default)
  48747. * @param level defines which level of the texture to update
  48748. */
  48749. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48750. /**
  48751. * Updates a raw cube texture with RGBD encoded data.
  48752. * @param data defines the array of data [mipmap][face] to use to create each face
  48753. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48756. * @returns a promsie that resolves when the operation is complete
  48757. */
  48758. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48759. /**
  48760. * Clones the raw cube texture.
  48761. * @return a new cube texture
  48762. */
  48763. clone(): CubeTexture;
  48764. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48765. }
  48766. }
  48767. declare module BABYLON {
  48768. /**
  48769. * Class used to store 3D textures containing user data
  48770. */
  48771. export class RawTexture3D extends Texture {
  48772. /** Gets or sets the texture format to use */
  48773. format: number;
  48774. private _engine;
  48775. /**
  48776. * Create a new RawTexture3D
  48777. * @param data defines the data of the texture
  48778. * @param width defines the width of the texture
  48779. * @param height defines the height of the texture
  48780. * @param depth defines the depth of the texture
  48781. * @param format defines the texture format to use
  48782. * @param scene defines the hosting scene
  48783. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48784. * @param invertY defines if texture must be stored with Y axis inverted
  48785. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48787. */
  48788. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48789. /** Gets or sets the texture format to use */
  48790. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48791. /**
  48792. * Update the texture with new data
  48793. * @param data defines the data to store in the texture
  48794. */
  48795. update(data: ArrayBufferView): void;
  48796. }
  48797. }
  48798. declare module BABYLON {
  48799. /**
  48800. * Creates a refraction texture used by refraction channel of the standard material.
  48801. * It is like a mirror but to see through a material.
  48802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48803. */
  48804. export class RefractionTexture extends RenderTargetTexture {
  48805. /**
  48806. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48807. * 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.
  48808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48809. */
  48810. refractionPlane: Plane;
  48811. /**
  48812. * Define how deep under the surface we should see.
  48813. */
  48814. depth: number;
  48815. /**
  48816. * Creates a refraction texture used by refraction channel of the standard material.
  48817. * It is like a mirror but to see through a material.
  48818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48819. * @param name Define the texture name
  48820. * @param size Define the size of the underlying texture
  48821. * @param scene Define the scene the refraction belongs to
  48822. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48823. */
  48824. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48825. /**
  48826. * Clone the refraction texture.
  48827. * @returns the cloned texture
  48828. */
  48829. clone(): RefractionTexture;
  48830. /**
  48831. * Serialize the texture to a JSON representation you could use in Parse later on
  48832. * @returns the serialized JSON representation
  48833. */
  48834. serialize(): any;
  48835. }
  48836. }
  48837. declare module BABYLON {
  48838. /**
  48839. * Defines the options related to the creation of an HtmlElementTexture
  48840. */
  48841. export interface IHtmlElementTextureOptions {
  48842. /**
  48843. * Defines wether mip maps should be created or not.
  48844. */
  48845. generateMipMaps?: boolean;
  48846. /**
  48847. * Defines the sampling mode of the texture.
  48848. */
  48849. samplingMode?: number;
  48850. /**
  48851. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48852. */
  48853. engine: Nullable<Engine>;
  48854. /**
  48855. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48856. */
  48857. scene: Nullable<Scene>;
  48858. }
  48859. /**
  48860. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48861. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48862. * is automatically managed.
  48863. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48864. * in your application.
  48865. *
  48866. * As the update is not automatic, you need to call them manually.
  48867. */
  48868. export class HtmlElementTexture extends BaseTexture {
  48869. /**
  48870. * The texture URL.
  48871. */
  48872. element: HTMLVideoElement | HTMLCanvasElement;
  48873. private static readonly DefaultOptions;
  48874. private _textureMatrix;
  48875. private _engine;
  48876. private _isVideo;
  48877. private _generateMipMaps;
  48878. private _samplingMode;
  48879. /**
  48880. * Instantiates a HtmlElementTexture from the following parameters.
  48881. *
  48882. * @param name Defines the name of the texture
  48883. * @param element Defines the video or canvas the texture is filled with
  48884. * @param options Defines the other none mandatory texture creation options
  48885. */
  48886. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48887. private _createInternalTexture;
  48888. /**
  48889. * Returns the texture matrix used in most of the material.
  48890. */
  48891. getTextureMatrix(): Matrix;
  48892. /**
  48893. * Updates the content of the texture.
  48894. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48895. */
  48896. update(invertY?: Nullable<boolean>): void;
  48897. }
  48898. }
  48899. declare module BABYLON {
  48900. /**
  48901. * Helper class to push actions to a pool of workers.
  48902. */
  48903. export class WorkerPool implements IDisposable {
  48904. private _workerInfos;
  48905. private _pendingActions;
  48906. /**
  48907. * Constructor
  48908. * @param workers Array of workers to use for actions
  48909. */
  48910. constructor(workers: Array<Worker>);
  48911. /**
  48912. * Terminates all workers and clears any pending actions.
  48913. */
  48914. dispose(): void;
  48915. /**
  48916. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48917. * pended until a worker has completed its action.
  48918. * @param action The action to perform. Call onComplete when the action is complete.
  48919. */
  48920. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48921. private _execute;
  48922. }
  48923. }
  48924. declare module BABYLON {
  48925. /**
  48926. * Configuration for Draco compression
  48927. */
  48928. export interface IDracoCompressionConfiguration {
  48929. /**
  48930. * Configuration for the decoder.
  48931. */
  48932. decoder?: {
  48933. /**
  48934. * The url to the WebAssembly module.
  48935. */
  48936. wasmUrl?: string;
  48937. /**
  48938. * The url to the WebAssembly binary.
  48939. */
  48940. wasmBinaryUrl?: string;
  48941. /**
  48942. * The url to the fallback JavaScript module.
  48943. */
  48944. fallbackUrl?: string;
  48945. };
  48946. }
  48947. /**
  48948. * Draco compression (https://google.github.io/draco/)
  48949. *
  48950. * This class wraps the Draco module.
  48951. *
  48952. * **Encoder**
  48953. *
  48954. * The encoder is not currently implemented.
  48955. *
  48956. * **Decoder**
  48957. *
  48958. * 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.
  48959. *
  48960. * To update the configuration, use the following code:
  48961. * ```javascript
  48962. * DracoCompression.Configuration = {
  48963. * decoder: {
  48964. * wasmUrl: "<url to the WebAssembly library>",
  48965. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48966. * fallbackUrl: "<url to the fallback JavaScript library>",
  48967. * }
  48968. * };
  48969. * ```
  48970. *
  48971. * 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.
  48972. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48973. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48974. *
  48975. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48976. * ```javascript
  48977. * var dracoCompression = new DracoCompression();
  48978. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48979. * [VertexBuffer.PositionKind]: 0
  48980. * });
  48981. * ```
  48982. *
  48983. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48984. */
  48985. export class DracoCompression implements IDisposable {
  48986. private _workerPoolPromise;
  48987. /**
  48988. * The configuration. Defaults to the following urls:
  48989. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48990. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48991. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48992. */
  48993. static Configuration: IDracoCompressionConfiguration;
  48994. /**
  48995. * Returns true if the decoder is available.
  48996. */
  48997. static readonly DecoderAvailable: boolean;
  48998. /**
  48999. * Default number of workers to create when creating the draco compression object.
  49000. */
  49001. static DefaultNumWorkers: number;
  49002. private static GetDefaultNumWorkers;
  49003. /**
  49004. * Constructor
  49005. * @param numWorkers The number of workers for async operations
  49006. */
  49007. constructor(numWorkers?: number);
  49008. /**
  49009. * Stop all async operations and release resources.
  49010. */
  49011. dispose(): void;
  49012. /**
  49013. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49014. * @returns a promise that resolves when ready
  49015. */
  49016. whenReadyAsync(): Promise<void>;
  49017. /**
  49018. * Decode Draco compressed mesh data to vertex data.
  49019. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49020. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49021. * @returns A promise that resolves with the decoded vertex data
  49022. */
  49023. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49024. [kind: string]: number;
  49025. }): Promise<VertexData>;
  49026. /**
  49027. * The worker function that gets converted to a blob url to pass into a worker.
  49028. */
  49029. private static _Worker;
  49030. private _loadDecoderWasmBinaryAsync;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * Class for building Constructive Solid Geometry
  49036. */
  49037. export class CSG {
  49038. private polygons;
  49039. /**
  49040. * The world matrix
  49041. */
  49042. matrix: Matrix;
  49043. /**
  49044. * Stores the position
  49045. */
  49046. position: Vector3;
  49047. /**
  49048. * Stores the rotation
  49049. */
  49050. rotation: Vector3;
  49051. /**
  49052. * Stores the rotation quaternion
  49053. */
  49054. rotationQuaternion: Nullable<Quaternion>;
  49055. /**
  49056. * Stores the scaling vector
  49057. */
  49058. scaling: Vector3;
  49059. /**
  49060. * Convert the Mesh to CSG
  49061. * @param mesh The Mesh to convert to CSG
  49062. * @returns A new CSG from the Mesh
  49063. */
  49064. static FromMesh(mesh: Mesh): CSG;
  49065. /**
  49066. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49067. * @param polygons Polygons used to construct a CSG solid
  49068. */
  49069. private static FromPolygons;
  49070. /**
  49071. * Clones, or makes a deep copy, of the CSG
  49072. * @returns A new CSG
  49073. */
  49074. clone(): CSG;
  49075. /**
  49076. * Unions this CSG with another CSG
  49077. * @param csg The CSG to union against this CSG
  49078. * @returns The unioned CSG
  49079. */
  49080. union(csg: CSG): CSG;
  49081. /**
  49082. * Unions this CSG with another CSG in place
  49083. * @param csg The CSG to union against this CSG
  49084. */
  49085. unionInPlace(csg: CSG): void;
  49086. /**
  49087. * Subtracts this CSG with another CSG
  49088. * @param csg The CSG to subtract against this CSG
  49089. * @returns A new CSG
  49090. */
  49091. subtract(csg: CSG): CSG;
  49092. /**
  49093. * Subtracts this CSG with another CSG in place
  49094. * @param csg The CSG to subtact against this CSG
  49095. */
  49096. subtractInPlace(csg: CSG): void;
  49097. /**
  49098. * Intersect this CSG with another CSG
  49099. * @param csg The CSG to intersect against this CSG
  49100. * @returns A new CSG
  49101. */
  49102. intersect(csg: CSG): CSG;
  49103. /**
  49104. * Intersects this CSG with another CSG in place
  49105. * @param csg The CSG to intersect against this CSG
  49106. */
  49107. intersectInPlace(csg: CSG): void;
  49108. /**
  49109. * Return a new CSG solid with solid and empty space switched. This solid is
  49110. * not modified.
  49111. * @returns A new CSG solid with solid and empty space switched
  49112. */
  49113. inverse(): CSG;
  49114. /**
  49115. * Inverses the CSG in place
  49116. */
  49117. inverseInPlace(): void;
  49118. /**
  49119. * This is used to keep meshes transformations so they can be restored
  49120. * when we build back a Babylon Mesh
  49121. * NB : All CSG operations are performed in world coordinates
  49122. * @param csg The CSG to copy the transform attributes from
  49123. * @returns This CSG
  49124. */
  49125. copyTransformAttributes(csg: CSG): CSG;
  49126. /**
  49127. * Build Raw mesh from CSG
  49128. * Coordinates here are in world space
  49129. * @param name The name of the mesh geometry
  49130. * @param scene The Scene
  49131. * @param keepSubMeshes Specifies if the submeshes should be kept
  49132. * @returns A new Mesh
  49133. */
  49134. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49135. /**
  49136. * Build Mesh from CSG taking material and transforms into account
  49137. * @param name The name of the Mesh
  49138. * @param material The material of the Mesh
  49139. * @param scene The Scene
  49140. * @param keepSubMeshes Specifies if submeshes should be kept
  49141. * @returns The new Mesh
  49142. */
  49143. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49144. }
  49145. }
  49146. declare module BABYLON {
  49147. /**
  49148. * Class used to create a trail following a mesh
  49149. */
  49150. export class TrailMesh extends Mesh {
  49151. private _generator;
  49152. private _autoStart;
  49153. private _running;
  49154. private _diameter;
  49155. private _length;
  49156. private _sectionPolygonPointsCount;
  49157. private _sectionVectors;
  49158. private _sectionNormalVectors;
  49159. private _beforeRenderObserver;
  49160. /**
  49161. * @constructor
  49162. * @param name The value used by scene.getMeshByName() to do a lookup.
  49163. * @param generator The mesh to generate a trail.
  49164. * @param scene The scene to add this mesh to.
  49165. * @param diameter Diameter of trailing mesh. Default is 1.
  49166. * @param length Length of trailing mesh. Default is 60.
  49167. * @param autoStart Automatically start trailing mesh. Default true.
  49168. */
  49169. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49170. /**
  49171. * "TrailMesh"
  49172. * @returns "TrailMesh"
  49173. */
  49174. getClassName(): string;
  49175. private _createMesh;
  49176. /**
  49177. * Start trailing mesh.
  49178. */
  49179. start(): void;
  49180. /**
  49181. * Stop trailing mesh.
  49182. */
  49183. stop(): void;
  49184. /**
  49185. * Update trailing mesh geometry.
  49186. */
  49187. update(): void;
  49188. /**
  49189. * Returns a new TrailMesh object.
  49190. * @param name is a string, the name given to the new mesh
  49191. * @param newGenerator use new generator object for cloned trail mesh
  49192. * @returns a new mesh
  49193. */
  49194. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49195. /**
  49196. * Serializes this trail mesh
  49197. * @param serializationObject object to write serialization to
  49198. */
  49199. serialize(serializationObject: any): void;
  49200. /**
  49201. * Parses a serialized trail mesh
  49202. * @param parsedMesh the serialized mesh
  49203. * @param scene the scene to create the trail mesh in
  49204. * @returns the created trail mesh
  49205. */
  49206. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * Class containing static functions to help procedurally build meshes
  49212. */
  49213. export class TorusKnotBuilder {
  49214. /**
  49215. * Creates a torus knot mesh
  49216. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49217. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49218. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49219. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49221. * * 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
  49222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49223. * @param name defines the name of the mesh
  49224. * @param options defines the options used to create the mesh
  49225. * @param scene defines the hosting scene
  49226. * @returns the torus knot mesh
  49227. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49228. */
  49229. static CreateTorusKnot(name: string, options: {
  49230. radius?: number;
  49231. tube?: number;
  49232. radialSegments?: number;
  49233. tubularSegments?: number;
  49234. p?: number;
  49235. q?: number;
  49236. updatable?: boolean;
  49237. sideOrientation?: number;
  49238. frontUVs?: Vector4;
  49239. backUVs?: Vector4;
  49240. }, scene: any): Mesh;
  49241. }
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * Polygon
  49246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49247. */
  49248. export class Polygon {
  49249. /**
  49250. * Creates a rectangle
  49251. * @param xmin bottom X coord
  49252. * @param ymin bottom Y coord
  49253. * @param xmax top X coord
  49254. * @param ymax top Y coord
  49255. * @returns points that make the resulting rectation
  49256. */
  49257. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49258. /**
  49259. * Creates a circle
  49260. * @param radius radius of circle
  49261. * @param cx scale in x
  49262. * @param cy scale in y
  49263. * @param numberOfSides number of sides that make up the circle
  49264. * @returns points that make the resulting circle
  49265. */
  49266. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49267. /**
  49268. * Creates a polygon from input string
  49269. * @param input Input polygon data
  49270. * @returns the parsed points
  49271. */
  49272. static Parse(input: string): Vector2[];
  49273. /**
  49274. * Starts building a polygon from x and y coordinates
  49275. * @param x x coordinate
  49276. * @param y y coordinate
  49277. * @returns the started path2
  49278. */
  49279. static StartingAt(x: number, y: number): Path2;
  49280. }
  49281. /**
  49282. * Builds a polygon
  49283. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49284. */
  49285. export class PolygonMeshBuilder {
  49286. private _points;
  49287. private _outlinepoints;
  49288. private _holes;
  49289. private _name;
  49290. private _scene;
  49291. private _epoints;
  49292. private _eholes;
  49293. private _addToepoint;
  49294. /**
  49295. * Babylon reference to the earcut plugin.
  49296. */
  49297. bjsEarcut: any;
  49298. /**
  49299. * Creates a PolygonMeshBuilder
  49300. * @param name name of the builder
  49301. * @param contours Path of the polygon
  49302. * @param scene scene to add to when creating the mesh
  49303. * @param earcutInjection can be used to inject your own earcut reference
  49304. */
  49305. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49306. /**
  49307. * Adds a whole within the polygon
  49308. * @param hole Array of points defining the hole
  49309. * @returns this
  49310. */
  49311. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49312. /**
  49313. * Creates the polygon
  49314. * @param updatable If the mesh should be updatable
  49315. * @param depth The depth of the mesh created
  49316. * @returns the created mesh
  49317. */
  49318. build(updatable?: boolean, depth?: number): Mesh;
  49319. /**
  49320. * Creates the polygon
  49321. * @param depth The depth of the mesh created
  49322. * @returns the created VertexData
  49323. */
  49324. buildVertexData(depth?: number): VertexData;
  49325. /**
  49326. * Adds a side to the polygon
  49327. * @param positions points that make the polygon
  49328. * @param normals normals of the polygon
  49329. * @param uvs uvs of the polygon
  49330. * @param indices indices of the polygon
  49331. * @param bounds bounds of the polygon
  49332. * @param points points of the polygon
  49333. * @param depth depth of the polygon
  49334. * @param flip flip of the polygon
  49335. */
  49336. private addSide;
  49337. }
  49338. }
  49339. declare module BABYLON {
  49340. /**
  49341. * Class containing static functions to help procedurally build meshes
  49342. */
  49343. export class PolygonBuilder {
  49344. /**
  49345. * Creates a polygon mesh
  49346. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49347. * * 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
  49348. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49350. * * 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)
  49351. * * Remember you can only change the shape positions, not their number when updating a polygon
  49352. * @param name defines the name of the mesh
  49353. * @param options defines the options used to create the mesh
  49354. * @param scene defines the hosting scene
  49355. * @param earcutInjection can be used to inject your own earcut reference
  49356. * @returns the polygon mesh
  49357. */
  49358. static CreatePolygon(name: string, options: {
  49359. shape: Vector3[];
  49360. holes?: Vector3[][];
  49361. depth?: number;
  49362. faceUV?: Vector4[];
  49363. faceColors?: Color4[];
  49364. updatable?: boolean;
  49365. sideOrientation?: number;
  49366. frontUVs?: Vector4;
  49367. backUVs?: Vector4;
  49368. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49369. /**
  49370. * Creates an extruded polygon mesh, with depth in the Y direction.
  49371. * * 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)
  49372. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49373. * @param name defines the name of the mesh
  49374. * @param options defines the options used to create the mesh
  49375. * @param scene defines the hosting scene
  49376. * @param earcutInjection can be used to inject your own earcut reference
  49377. * @returns the polygon mesh
  49378. */
  49379. static ExtrudePolygon(name: string, options: {
  49380. shape: Vector3[];
  49381. holes?: Vector3[][];
  49382. depth?: number;
  49383. faceUV?: Vector4[];
  49384. faceColors?: Color4[];
  49385. updatable?: boolean;
  49386. sideOrientation?: number;
  49387. frontUVs?: Vector4;
  49388. backUVs?: Vector4;
  49389. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49390. }
  49391. }
  49392. declare module BABYLON {
  49393. /**
  49394. * Class containing static functions to help procedurally build meshes
  49395. */
  49396. export class LatheBuilder {
  49397. /**
  49398. * Creates lathe mesh.
  49399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49400. * * 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
  49401. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49402. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49403. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49404. * * 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
  49405. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49406. * * 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
  49407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49408. * * 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
  49409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49411. * @param name defines the name of the mesh
  49412. * @param options defines the options used to create the mesh
  49413. * @param scene defines the hosting scene
  49414. * @returns the lathe mesh
  49415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49416. */
  49417. static CreateLathe(name: string, options: {
  49418. shape: Vector3[];
  49419. radius?: number;
  49420. tessellation?: number;
  49421. clip?: number;
  49422. arc?: number;
  49423. closed?: boolean;
  49424. updatable?: boolean;
  49425. sideOrientation?: number;
  49426. frontUVs?: Vector4;
  49427. backUVs?: Vector4;
  49428. cap?: number;
  49429. invertUV?: boolean;
  49430. }, scene?: Nullable<Scene>): Mesh;
  49431. }
  49432. }
  49433. declare module BABYLON {
  49434. /**
  49435. * Class containing static functions to help procedurally build meshes
  49436. */
  49437. export class TubeBuilder {
  49438. /**
  49439. * Creates a tube mesh.
  49440. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49441. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49442. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49443. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49444. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49445. * * 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)
  49446. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49447. * * 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
  49448. * * 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
  49449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49450. * * 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
  49451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49453. * @param name defines the name of the mesh
  49454. * @param options defines the options used to create the mesh
  49455. * @param scene defines the hosting scene
  49456. * @returns the tube mesh
  49457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49458. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49459. */
  49460. static CreateTube(name: string, options: {
  49461. path: Vector3[];
  49462. radius?: number;
  49463. tessellation?: number;
  49464. radiusFunction?: {
  49465. (i: number, distance: number): number;
  49466. };
  49467. cap?: number;
  49468. arc?: number;
  49469. updatable?: boolean;
  49470. sideOrientation?: number;
  49471. frontUVs?: Vector4;
  49472. backUVs?: Vector4;
  49473. instance?: Mesh;
  49474. invertUV?: boolean;
  49475. }, scene?: Nullable<Scene>): Mesh;
  49476. }
  49477. }
  49478. declare module BABYLON {
  49479. /**
  49480. * Class containing static functions to help procedurally build meshes
  49481. */
  49482. export class IcoSphereBuilder {
  49483. /**
  49484. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49485. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49486. * * 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`)
  49487. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49488. * * 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
  49489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49490. * * 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
  49491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49492. * @param name defines the name of the mesh
  49493. * @param options defines the options used to create the mesh
  49494. * @param scene defines the hosting scene
  49495. * @returns the icosahedron mesh
  49496. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49497. */
  49498. static CreateIcoSphere(name: string, options: {
  49499. radius?: number;
  49500. radiusX?: number;
  49501. radiusY?: number;
  49502. radiusZ?: number;
  49503. flat?: boolean;
  49504. subdivisions?: number;
  49505. sideOrientation?: number;
  49506. frontUVs?: Vector4;
  49507. backUVs?: Vector4;
  49508. updatable?: boolean;
  49509. }, scene?: Nullable<Scene>): Mesh;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /**
  49514. * Class containing static functions to help procedurally build meshes
  49515. */
  49516. export class DecalBuilder {
  49517. /**
  49518. * Creates a decal mesh.
  49519. * 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
  49520. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49521. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49522. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49523. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49524. * @param name defines the name of the mesh
  49525. * @param sourceMesh defines the mesh where the decal must be applied
  49526. * @param options defines the options used to create the mesh
  49527. * @param scene defines the hosting scene
  49528. * @returns the decal mesh
  49529. * @see https://doc.babylonjs.com/how_to/decals
  49530. */
  49531. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49532. position?: Vector3;
  49533. normal?: Vector3;
  49534. size?: Vector3;
  49535. angle?: number;
  49536. }): Mesh;
  49537. }
  49538. }
  49539. declare module BABYLON {
  49540. /**
  49541. * Class containing static functions to help procedurally build meshes
  49542. */
  49543. export class MeshBuilder {
  49544. /**
  49545. * Creates a box mesh
  49546. * * The parameter `size` sets the size (float) of each box side (default 1)
  49547. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49548. * * 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)
  49549. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49551. * * 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
  49552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49553. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49554. * @param name defines the name of the mesh
  49555. * @param options defines the options used to create the mesh
  49556. * @param scene defines the hosting scene
  49557. * @returns the box mesh
  49558. */
  49559. static CreateBox(name: string, options: {
  49560. size?: number;
  49561. width?: number;
  49562. height?: number;
  49563. depth?: number;
  49564. faceUV?: Vector4[];
  49565. faceColors?: Color4[];
  49566. sideOrientation?: number;
  49567. frontUVs?: Vector4;
  49568. backUVs?: Vector4;
  49569. updatable?: boolean;
  49570. }, scene?: Nullable<Scene>): Mesh;
  49571. /**
  49572. * Creates a sphere mesh
  49573. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49574. * * 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`)
  49575. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49576. * * 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
  49577. * * 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)
  49578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49579. * * 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
  49580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49581. * @param name defines the name of the mesh
  49582. * @param options defines the options used to create the mesh
  49583. * @param scene defines the hosting scene
  49584. * @returns the sphere mesh
  49585. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49586. */
  49587. static CreateSphere(name: string, options: {
  49588. segments?: number;
  49589. diameter?: number;
  49590. diameterX?: number;
  49591. diameterY?: number;
  49592. diameterZ?: number;
  49593. arc?: number;
  49594. slice?: number;
  49595. sideOrientation?: number;
  49596. frontUVs?: Vector4;
  49597. backUVs?: Vector4;
  49598. updatable?: boolean;
  49599. }, scene?: Nullable<Scene>): Mesh;
  49600. /**
  49601. * Creates a plane polygonal mesh. By default, this is a disc
  49602. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49603. * * 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
  49604. * * 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
  49605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49606. * * 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
  49607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49608. * @param name defines the name of the mesh
  49609. * @param options defines the options used to create the mesh
  49610. * @param scene defines the hosting scene
  49611. * @returns the plane polygonal mesh
  49612. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49613. */
  49614. static CreateDisc(name: string, options: {
  49615. radius?: number;
  49616. tessellation?: number;
  49617. arc?: number;
  49618. updatable?: boolean;
  49619. sideOrientation?: number;
  49620. frontUVs?: Vector4;
  49621. backUVs?: Vector4;
  49622. }, scene?: Nullable<Scene>): Mesh;
  49623. /**
  49624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49626. * * 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`)
  49627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49628. * * 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
  49629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49630. * * 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
  49631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49632. * @param name defines the name of the mesh
  49633. * @param options defines the options used to create the mesh
  49634. * @param scene defines the hosting scene
  49635. * @returns the icosahedron mesh
  49636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49637. */
  49638. static CreateIcoSphere(name: string, options: {
  49639. radius?: number;
  49640. radiusX?: number;
  49641. radiusY?: number;
  49642. radiusZ?: number;
  49643. flat?: boolean;
  49644. subdivisions?: number;
  49645. sideOrientation?: number;
  49646. frontUVs?: Vector4;
  49647. backUVs?: Vector4;
  49648. updatable?: boolean;
  49649. }, scene?: Nullable<Scene>): Mesh;
  49650. /**
  49651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49655. * * 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
  49656. * * 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
  49657. * * 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
  49658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49659. * * 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
  49660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49661. * * 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
  49662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49663. * * 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
  49664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49666. * @param name defines the name of the mesh
  49667. * @param options defines the options used to create the mesh
  49668. * @param scene defines the hosting scene
  49669. * @returns the ribbon mesh
  49670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49672. */
  49673. static CreateRibbon(name: string, options: {
  49674. pathArray: Vector3[][];
  49675. closeArray?: boolean;
  49676. closePath?: boolean;
  49677. offset?: number;
  49678. updatable?: boolean;
  49679. sideOrientation?: number;
  49680. frontUVs?: Vector4;
  49681. backUVs?: Vector4;
  49682. instance?: Mesh;
  49683. invertUV?: boolean;
  49684. uvs?: Vector2[];
  49685. colors?: Color4[];
  49686. }, scene?: Nullable<Scene>): Mesh;
  49687. /**
  49688. * Creates a cylinder or a cone mesh
  49689. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49690. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49691. * * 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.
  49692. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49693. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49694. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49695. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49696. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49697. * * 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).
  49698. * * 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
  49699. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49700. * * 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
  49701. * * 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.
  49702. * * If `enclose` is false, a ring surface is one element.
  49703. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49704. * * 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
  49705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49706. * * 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
  49707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49708. * @param name defines the name of the mesh
  49709. * @param options defines the options used to create the mesh
  49710. * @param scene defines the hosting scene
  49711. * @returns the cylinder mesh
  49712. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49713. */
  49714. static CreateCylinder(name: string, options: {
  49715. height?: number;
  49716. diameterTop?: number;
  49717. diameterBottom?: number;
  49718. diameter?: number;
  49719. tessellation?: number;
  49720. subdivisions?: number;
  49721. arc?: number;
  49722. faceColors?: Color4[];
  49723. faceUV?: Vector4[];
  49724. updatable?: boolean;
  49725. hasRings?: boolean;
  49726. enclose?: boolean;
  49727. sideOrientation?: number;
  49728. frontUVs?: Vector4;
  49729. backUVs?: Vector4;
  49730. }, scene?: Nullable<Scene>): Mesh;
  49731. /**
  49732. * Creates a torus mesh
  49733. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49734. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49735. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49737. * * 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
  49738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49739. * @param name defines the name of the mesh
  49740. * @param options defines the options used to create the mesh
  49741. * @param scene defines the hosting scene
  49742. * @returns the torus mesh
  49743. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49744. */
  49745. static CreateTorus(name: string, options: {
  49746. diameter?: number;
  49747. thickness?: number;
  49748. tessellation?: number;
  49749. updatable?: boolean;
  49750. sideOrientation?: number;
  49751. frontUVs?: Vector4;
  49752. backUVs?: Vector4;
  49753. }, scene?: Nullable<Scene>): Mesh;
  49754. /**
  49755. * Creates a torus knot mesh
  49756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49761. * * 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
  49762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49763. * @param name defines the name of the mesh
  49764. * @param options defines the options used to create the mesh
  49765. * @param scene defines the hosting scene
  49766. * @returns the torus knot mesh
  49767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49768. */
  49769. static CreateTorusKnot(name: string, options: {
  49770. radius?: number;
  49771. tube?: number;
  49772. radialSegments?: number;
  49773. tubularSegments?: number;
  49774. p?: number;
  49775. q?: number;
  49776. updatable?: boolean;
  49777. sideOrientation?: number;
  49778. frontUVs?: Vector4;
  49779. backUVs?: Vector4;
  49780. }, scene?: Nullable<Scene>): Mesh;
  49781. /**
  49782. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49783. * * 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
  49784. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49785. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49786. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49787. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49788. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49789. * * 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
  49790. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49793. * @param name defines the name of the new line system
  49794. * @param options defines the options used to create the line system
  49795. * @param scene defines the hosting scene
  49796. * @returns a new line system mesh
  49797. */
  49798. static CreateLineSystem(name: string, options: {
  49799. lines: Vector3[][];
  49800. updatable?: boolean;
  49801. instance?: Nullable<LinesMesh>;
  49802. colors?: Nullable<Color4[][]>;
  49803. useVertexAlpha?: boolean;
  49804. }, scene: Nullable<Scene>): LinesMesh;
  49805. /**
  49806. * Creates a line mesh
  49807. * 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
  49808. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49809. * * The parameter `points` is an array successive Vector3
  49810. * * 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
  49811. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49813. * * When updating an instance, remember that only point positions can change, not the number of points
  49814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49816. * @param name defines the name of the new line system
  49817. * @param options defines the options used to create the line system
  49818. * @param scene defines the hosting scene
  49819. * @returns a new line mesh
  49820. */
  49821. static CreateLines(name: string, options: {
  49822. points: Vector3[];
  49823. updatable?: boolean;
  49824. instance?: Nullable<LinesMesh>;
  49825. colors?: Color4[];
  49826. useVertexAlpha?: boolean;
  49827. }, scene?: Nullable<Scene>): LinesMesh;
  49828. /**
  49829. * Creates a dashed line mesh
  49830. * * 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
  49831. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49832. * * The parameter `points` is an array successive Vector3
  49833. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49834. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49835. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49836. * * 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
  49837. * * When updating an instance, remember that only point positions can change, not the number of points
  49838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49839. * @param name defines the name of the mesh
  49840. * @param options defines the options used to create the mesh
  49841. * @param scene defines the hosting scene
  49842. * @returns the dashed line mesh
  49843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49844. */
  49845. static CreateDashedLines(name: string, options: {
  49846. points: Vector3[];
  49847. dashSize?: number;
  49848. gapSize?: number;
  49849. dashNb?: number;
  49850. updatable?: boolean;
  49851. instance?: LinesMesh;
  49852. }, scene?: Nullable<Scene>): LinesMesh;
  49853. /**
  49854. * 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.
  49855. * * 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.
  49856. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49857. * * 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.
  49858. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49859. * * 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
  49860. * * 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
  49861. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49863. * * 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
  49864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49866. * @param name defines the name of the mesh
  49867. * @param options defines the options used to create the mesh
  49868. * @param scene defines the hosting scene
  49869. * @returns the extruded shape mesh
  49870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49872. */
  49873. static ExtrudeShape(name: string, options: {
  49874. shape: Vector3[];
  49875. path: Vector3[];
  49876. scale?: number;
  49877. rotation?: number;
  49878. cap?: number;
  49879. updatable?: boolean;
  49880. sideOrientation?: number;
  49881. frontUVs?: Vector4;
  49882. backUVs?: Vector4;
  49883. instance?: Mesh;
  49884. invertUV?: boolean;
  49885. }, scene?: Nullable<Scene>): Mesh;
  49886. /**
  49887. * Creates an custom extruded shape mesh.
  49888. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49889. * * 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.
  49890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49891. * * 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
  49892. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49893. * * 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
  49894. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49895. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49896. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49897. * * 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
  49898. * * 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
  49899. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49901. * * 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
  49902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49904. * @param name defines the name of the mesh
  49905. * @param options defines the options used to create the mesh
  49906. * @param scene defines the hosting scene
  49907. * @returns the custom extruded shape mesh
  49908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49911. */
  49912. static ExtrudeShapeCustom(name: string, options: {
  49913. shape: Vector3[];
  49914. path: Vector3[];
  49915. scaleFunction?: any;
  49916. rotationFunction?: any;
  49917. ribbonCloseArray?: boolean;
  49918. ribbonClosePath?: boolean;
  49919. cap?: number;
  49920. updatable?: boolean;
  49921. sideOrientation?: number;
  49922. frontUVs?: Vector4;
  49923. backUVs?: Vector4;
  49924. instance?: Mesh;
  49925. invertUV?: boolean;
  49926. }, scene?: Nullable<Scene>): Mesh;
  49927. /**
  49928. * Creates lathe mesh.
  49929. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49930. * * 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
  49931. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49932. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49933. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49934. * * 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
  49935. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49936. * * 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
  49937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49938. * * 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
  49939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49941. * @param name defines the name of the mesh
  49942. * @param options defines the options used to create the mesh
  49943. * @param scene defines the hosting scene
  49944. * @returns the lathe mesh
  49945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49946. */
  49947. static CreateLathe(name: string, options: {
  49948. shape: Vector3[];
  49949. radius?: number;
  49950. tessellation?: number;
  49951. clip?: number;
  49952. arc?: number;
  49953. closed?: boolean;
  49954. updatable?: boolean;
  49955. sideOrientation?: number;
  49956. frontUVs?: Vector4;
  49957. backUVs?: Vector4;
  49958. cap?: number;
  49959. invertUV?: boolean;
  49960. }, scene?: Nullable<Scene>): Mesh;
  49961. /**
  49962. * Creates a plane mesh
  49963. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49964. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49965. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49967. * * 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
  49968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49969. * @param name defines the name of the mesh
  49970. * @param options defines the options used to create the mesh
  49971. * @param scene defines the hosting scene
  49972. * @returns the plane mesh
  49973. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49974. */
  49975. static CreatePlane(name: string, options: {
  49976. size?: number;
  49977. width?: number;
  49978. height?: number;
  49979. sideOrientation?: number;
  49980. frontUVs?: Vector4;
  49981. backUVs?: Vector4;
  49982. updatable?: boolean;
  49983. sourcePlane?: Plane;
  49984. }, scene?: Nullable<Scene>): Mesh;
  49985. /**
  49986. * Creates a ground mesh
  49987. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49988. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49990. * @param name defines the name of the mesh
  49991. * @param options defines the options used to create the mesh
  49992. * @param scene defines the hosting scene
  49993. * @returns the ground mesh
  49994. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49995. */
  49996. static CreateGround(name: string, options: {
  49997. width?: number;
  49998. height?: number;
  49999. subdivisions?: number;
  50000. subdivisionsX?: number;
  50001. subdivisionsY?: number;
  50002. updatable?: boolean;
  50003. }, scene?: Nullable<Scene>): Mesh;
  50004. /**
  50005. * Creates a tiled ground mesh
  50006. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50007. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50008. * * 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
  50009. * * 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
  50010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50011. * @param name defines the name of the mesh
  50012. * @param options defines the options used to create the mesh
  50013. * @param scene defines the hosting scene
  50014. * @returns the tiled ground mesh
  50015. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50016. */
  50017. static CreateTiledGround(name: string, options: {
  50018. xmin: number;
  50019. zmin: number;
  50020. xmax: number;
  50021. zmax: number;
  50022. subdivisions?: {
  50023. w: number;
  50024. h: number;
  50025. };
  50026. precision?: {
  50027. w: number;
  50028. h: number;
  50029. };
  50030. updatable?: boolean;
  50031. }, scene?: Nullable<Scene>): Mesh;
  50032. /**
  50033. * Creates a ground mesh from a height map
  50034. * * The parameter `url` sets the URL of the height map image resource.
  50035. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50036. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50037. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50038. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50039. * * 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.
  50040. * * 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).
  50041. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50043. * @param name defines the name of the mesh
  50044. * @param url defines the url to the height map
  50045. * @param options defines the options used to create the mesh
  50046. * @param scene defines the hosting scene
  50047. * @returns the ground mesh
  50048. * @see https://doc.babylonjs.com/babylon101/height_map
  50049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50050. */
  50051. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50052. width?: number;
  50053. height?: number;
  50054. subdivisions?: number;
  50055. minHeight?: number;
  50056. maxHeight?: number;
  50057. colorFilter?: Color3;
  50058. alphaFilter?: number;
  50059. updatable?: boolean;
  50060. onReady?: (mesh: GroundMesh) => void;
  50061. }, scene?: Nullable<Scene>): GroundMesh;
  50062. /**
  50063. * Creates a polygon mesh
  50064. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50065. * * 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
  50066. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50068. * * 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)
  50069. * * Remember you can only change the shape positions, not their number when updating a polygon
  50070. * @param name defines the name of the mesh
  50071. * @param options defines the options used to create the mesh
  50072. * @param scene defines the hosting scene
  50073. * @param earcutInjection can be used to inject your own earcut reference
  50074. * @returns the polygon mesh
  50075. */
  50076. static CreatePolygon(name: string, options: {
  50077. shape: Vector3[];
  50078. holes?: Vector3[][];
  50079. depth?: number;
  50080. faceUV?: Vector4[];
  50081. faceColors?: Color4[];
  50082. updatable?: boolean;
  50083. sideOrientation?: number;
  50084. frontUVs?: Vector4;
  50085. backUVs?: Vector4;
  50086. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50087. /**
  50088. * Creates an extruded polygon mesh, with depth in the Y direction.
  50089. * * 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)
  50090. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50091. * @param name defines the name of the mesh
  50092. * @param options defines the options used to create the mesh
  50093. * @param scene defines the hosting scene
  50094. * @param earcutInjection can be used to inject your own earcut reference
  50095. * @returns the polygon mesh
  50096. */
  50097. static ExtrudePolygon(name: string, options: {
  50098. shape: Vector3[];
  50099. holes?: Vector3[][];
  50100. depth?: number;
  50101. faceUV?: Vector4[];
  50102. faceColors?: Color4[];
  50103. updatable?: boolean;
  50104. sideOrientation?: number;
  50105. frontUVs?: Vector4;
  50106. backUVs?: Vector4;
  50107. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50108. /**
  50109. * Creates a tube mesh.
  50110. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50111. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50112. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50113. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50114. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50115. * * 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)
  50116. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50117. * * 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
  50118. * * 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
  50119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50120. * * 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
  50121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50123. * @param name defines the name of the mesh
  50124. * @param options defines the options used to create the mesh
  50125. * @param scene defines the hosting scene
  50126. * @returns the tube mesh
  50127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50128. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50129. */
  50130. static CreateTube(name: string, options: {
  50131. path: Vector3[];
  50132. radius?: number;
  50133. tessellation?: number;
  50134. radiusFunction?: {
  50135. (i: number, distance: number): number;
  50136. };
  50137. cap?: number;
  50138. arc?: number;
  50139. updatable?: boolean;
  50140. sideOrientation?: number;
  50141. frontUVs?: Vector4;
  50142. backUVs?: Vector4;
  50143. instance?: Mesh;
  50144. invertUV?: boolean;
  50145. }, scene?: Nullable<Scene>): Mesh;
  50146. /**
  50147. * Creates a polyhedron mesh
  50148. * * 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
  50149. * * The parameter `size` (positive float, default 1) sets the polygon size
  50150. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50151. * * 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`
  50152. * * 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
  50153. * * 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)`)
  50154. * * 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
  50155. * * 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
  50156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50157. * * 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
  50158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50159. * @param name defines the name of the mesh
  50160. * @param options defines the options used to create the mesh
  50161. * @param scene defines the hosting scene
  50162. * @returns the polyhedron mesh
  50163. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50164. */
  50165. static CreatePolyhedron(name: string, options: {
  50166. type?: number;
  50167. size?: number;
  50168. sizeX?: number;
  50169. sizeY?: number;
  50170. sizeZ?: number;
  50171. custom?: any;
  50172. faceUV?: Vector4[];
  50173. faceColors?: Color4[];
  50174. flat?: boolean;
  50175. updatable?: boolean;
  50176. sideOrientation?: number;
  50177. frontUVs?: Vector4;
  50178. backUVs?: Vector4;
  50179. }, scene?: Nullable<Scene>): Mesh;
  50180. /**
  50181. * Creates a decal mesh.
  50182. * 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
  50183. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50184. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50185. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50186. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50187. * @param name defines the name of the mesh
  50188. * @param sourceMesh defines the mesh where the decal must be applied
  50189. * @param options defines the options used to create the mesh
  50190. * @param scene defines the hosting scene
  50191. * @returns the decal mesh
  50192. * @see https://doc.babylonjs.com/how_to/decals
  50193. */
  50194. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50195. position?: Vector3;
  50196. normal?: Vector3;
  50197. size?: Vector3;
  50198. angle?: number;
  50199. }): Mesh;
  50200. }
  50201. }
  50202. declare module BABYLON {
  50203. /**
  50204. * A simplifier interface for future simplification implementations
  50205. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50206. */
  50207. export interface ISimplifier {
  50208. /**
  50209. * Simplification of a given mesh according to the given settings.
  50210. * Since this requires computation, it is assumed that the function runs async.
  50211. * @param settings The settings of the simplification, including quality and distance
  50212. * @param successCallback A callback that will be called after the mesh was simplified.
  50213. * @param errorCallback in case of an error, this callback will be called. optional.
  50214. */
  50215. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50216. }
  50217. /**
  50218. * Expected simplification settings.
  50219. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50221. */
  50222. export interface ISimplificationSettings {
  50223. /**
  50224. * Gets or sets the expected quality
  50225. */
  50226. quality: number;
  50227. /**
  50228. * Gets or sets the distance when this optimized version should be used
  50229. */
  50230. distance: number;
  50231. /**
  50232. * Gets an already optimized mesh
  50233. */
  50234. optimizeMesh?: boolean;
  50235. }
  50236. /**
  50237. * Class used to specify simplification options
  50238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50239. */
  50240. export class SimplificationSettings implements ISimplificationSettings {
  50241. /** expected quality */
  50242. quality: number;
  50243. /** distance when this optimized version should be used */
  50244. distance: number;
  50245. /** already optimized mesh */
  50246. optimizeMesh?: boolean | undefined;
  50247. /**
  50248. * Creates a SimplificationSettings
  50249. * @param quality expected quality
  50250. * @param distance distance when this optimized version should be used
  50251. * @param optimizeMesh already optimized mesh
  50252. */
  50253. constructor(
  50254. /** expected quality */
  50255. quality: number,
  50256. /** distance when this optimized version should be used */
  50257. distance: number,
  50258. /** already optimized mesh */
  50259. optimizeMesh?: boolean | undefined);
  50260. }
  50261. /**
  50262. * Interface used to define a simplification task
  50263. */
  50264. export interface ISimplificationTask {
  50265. /**
  50266. * Array of settings
  50267. */
  50268. settings: Array<ISimplificationSettings>;
  50269. /**
  50270. * Simplification type
  50271. */
  50272. simplificationType: SimplificationType;
  50273. /**
  50274. * Mesh to simplify
  50275. */
  50276. mesh: Mesh;
  50277. /**
  50278. * Callback called on success
  50279. */
  50280. successCallback?: () => void;
  50281. /**
  50282. * Defines if parallel processing can be used
  50283. */
  50284. parallelProcessing: boolean;
  50285. }
  50286. /**
  50287. * Queue used to order the simplification tasks
  50288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50289. */
  50290. export class SimplificationQueue {
  50291. private _simplificationArray;
  50292. /**
  50293. * Gets a boolean indicating that the process is still running
  50294. */
  50295. running: boolean;
  50296. /**
  50297. * Creates a new queue
  50298. */
  50299. constructor();
  50300. /**
  50301. * Adds a new simplification task
  50302. * @param task defines a task to add
  50303. */
  50304. addTask(task: ISimplificationTask): void;
  50305. /**
  50306. * Execute next task
  50307. */
  50308. executeNext(): void;
  50309. /**
  50310. * Execute a simplification task
  50311. * @param task defines the task to run
  50312. */
  50313. runSimplification(task: ISimplificationTask): void;
  50314. private getSimplifier;
  50315. }
  50316. /**
  50317. * The implemented types of simplification
  50318. * At the moment only Quadratic Error Decimation is implemented
  50319. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50320. */
  50321. export enum SimplificationType {
  50322. /** Quadratic error decimation */
  50323. QUADRATIC = 0
  50324. }
  50325. }
  50326. declare module BABYLON {
  50327. interface Scene {
  50328. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50329. /**
  50330. * Gets or sets the simplification queue attached to the scene
  50331. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50332. */
  50333. simplificationQueue: SimplificationQueue;
  50334. }
  50335. interface Mesh {
  50336. /**
  50337. * Simplify the mesh according to the given array of settings.
  50338. * Function will return immediately and will simplify async
  50339. * @param settings a collection of simplification settings
  50340. * @param parallelProcessing should all levels calculate parallel or one after the other
  50341. * @param simplificationType the type of simplification to run
  50342. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50343. * @returns the current mesh
  50344. */
  50345. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50346. }
  50347. /**
  50348. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50349. * created in a scene
  50350. */
  50351. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50352. /**
  50353. * The component name helpfull to identify the component in the list of scene components.
  50354. */
  50355. readonly name: string;
  50356. /**
  50357. * The scene the component belongs to.
  50358. */
  50359. scene: Scene;
  50360. /**
  50361. * Creates a new instance of the component for the given scene
  50362. * @param scene Defines the scene to register the component in
  50363. */
  50364. constructor(scene: Scene);
  50365. /**
  50366. * Registers the component in a given scene
  50367. */
  50368. register(): void;
  50369. /**
  50370. * Rebuilds the elements related to this component in case of
  50371. * context lost for instance.
  50372. */
  50373. rebuild(): void;
  50374. /**
  50375. * Disposes the component and the associated ressources
  50376. */
  50377. dispose(): void;
  50378. private _beforeCameraUpdate;
  50379. }
  50380. }
  50381. declare module BABYLON {
  50382. /**
  50383. * Class used to enable access to IndexedDB
  50384. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50385. */
  50386. export class Database implements IOfflineProvider {
  50387. private _callbackManifestChecked;
  50388. private _currentSceneUrl;
  50389. private _db;
  50390. private _enableSceneOffline;
  50391. private _enableTexturesOffline;
  50392. private _manifestVersionFound;
  50393. private _mustUpdateRessources;
  50394. private _hasReachedQuota;
  50395. private _isSupported;
  50396. private _idbFactory;
  50397. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50398. private static IsUASupportingBlobStorage;
  50399. /**
  50400. * Gets a boolean indicating if Database storate is enabled (off by default)
  50401. */
  50402. static IDBStorageEnabled: boolean;
  50403. /**
  50404. * Gets a boolean indicating if scene must be saved in the database
  50405. */
  50406. readonly enableSceneOffline: boolean;
  50407. /**
  50408. * Gets a boolean indicating if textures must be saved in the database
  50409. */
  50410. readonly enableTexturesOffline: boolean;
  50411. /**
  50412. * Creates a new Database
  50413. * @param urlToScene defines the url to load the scene
  50414. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50415. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50416. */
  50417. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50418. private static _ParseURL;
  50419. private static _ReturnFullUrlLocation;
  50420. private _checkManifestFile;
  50421. /**
  50422. * Open the database and make it available
  50423. * @param successCallback defines the callback to call on success
  50424. * @param errorCallback defines the callback to call on error
  50425. */
  50426. open(successCallback: () => void, errorCallback: () => void): void;
  50427. /**
  50428. * Loads an image from the database
  50429. * @param url defines the url to load from
  50430. * @param image defines the target DOM image
  50431. */
  50432. loadImage(url: string, image: HTMLImageElement): void;
  50433. private _loadImageFromDBAsync;
  50434. private _saveImageIntoDBAsync;
  50435. private _checkVersionFromDB;
  50436. private _loadVersionFromDBAsync;
  50437. private _saveVersionIntoDBAsync;
  50438. /**
  50439. * Loads a file from database
  50440. * @param url defines the URL to load from
  50441. * @param sceneLoaded defines a callback to call on success
  50442. * @param progressCallBack defines a callback to call when progress changed
  50443. * @param errorCallback defines a callback to call on error
  50444. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50445. */
  50446. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50447. private _loadFileAsync;
  50448. private _saveFileAsync;
  50449. /**
  50450. * Validates if xhr data is correct
  50451. * @param xhr defines the request to validate
  50452. * @param dataType defines the expected data type
  50453. * @returns true if data is correct
  50454. */
  50455. private static _ValidateXHRData;
  50456. }
  50457. }
  50458. declare module BABYLON {
  50459. /** @hidden */
  50460. export var gpuUpdateParticlesPixelShader: {
  50461. name: string;
  50462. shader: string;
  50463. };
  50464. }
  50465. declare module BABYLON {
  50466. /** @hidden */
  50467. export var gpuUpdateParticlesVertexShader: {
  50468. name: string;
  50469. shader: string;
  50470. };
  50471. }
  50472. declare module BABYLON {
  50473. /** @hidden */
  50474. export var clipPlaneFragmentDeclaration2: {
  50475. name: string;
  50476. shader: string;
  50477. };
  50478. }
  50479. declare module BABYLON {
  50480. /** @hidden */
  50481. export var gpuRenderParticlesPixelShader: {
  50482. name: string;
  50483. shader: string;
  50484. };
  50485. }
  50486. declare module BABYLON {
  50487. /** @hidden */
  50488. export var clipPlaneVertexDeclaration2: {
  50489. name: string;
  50490. shader: string;
  50491. };
  50492. }
  50493. declare module BABYLON {
  50494. /** @hidden */
  50495. export var gpuRenderParticlesVertexShader: {
  50496. name: string;
  50497. shader: string;
  50498. };
  50499. }
  50500. declare module BABYLON {
  50501. /**
  50502. * This represents a GPU particle system in Babylon
  50503. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50504. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50505. */
  50506. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50507. /**
  50508. * The layer mask we are rendering the particles through.
  50509. */
  50510. layerMask: number;
  50511. private _capacity;
  50512. private _activeCount;
  50513. private _currentActiveCount;
  50514. private _accumulatedCount;
  50515. private _renderEffect;
  50516. private _updateEffect;
  50517. private _buffer0;
  50518. private _buffer1;
  50519. private _spriteBuffer;
  50520. private _updateVAO;
  50521. private _renderVAO;
  50522. private _targetIndex;
  50523. private _sourceBuffer;
  50524. private _targetBuffer;
  50525. private _engine;
  50526. private _currentRenderId;
  50527. private _started;
  50528. private _stopped;
  50529. private _timeDelta;
  50530. private _randomTexture;
  50531. private _randomTexture2;
  50532. private _attributesStrideSize;
  50533. private _updateEffectOptions;
  50534. private _randomTextureSize;
  50535. private _actualFrame;
  50536. private readonly _rawTextureWidth;
  50537. /**
  50538. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50539. */
  50540. static readonly IsSupported: boolean;
  50541. /**
  50542. * An event triggered when the system is disposed.
  50543. */
  50544. onDisposeObservable: Observable<GPUParticleSystem>;
  50545. /**
  50546. * Gets the maximum number of particles active at the same time.
  50547. * @returns The max number of active particles.
  50548. */
  50549. getCapacity(): number;
  50550. /**
  50551. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50552. * to override the particles.
  50553. */
  50554. forceDepthWrite: boolean;
  50555. /**
  50556. * Gets or set the number of active particles
  50557. */
  50558. activeParticleCount: number;
  50559. private _preWarmDone;
  50560. /**
  50561. * Is this system ready to be used/rendered
  50562. * @return true if the system is ready
  50563. */
  50564. isReady(): boolean;
  50565. /**
  50566. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50567. * @returns True if it has been started, otherwise false.
  50568. */
  50569. isStarted(): boolean;
  50570. /**
  50571. * Starts the particle system and begins to emit
  50572. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50573. */
  50574. start(delay?: number): void;
  50575. /**
  50576. * Stops the particle system.
  50577. */
  50578. stop(): void;
  50579. /**
  50580. * Remove all active particles
  50581. */
  50582. reset(): void;
  50583. /**
  50584. * Returns the string "GPUParticleSystem"
  50585. * @returns a string containing the class name
  50586. */
  50587. getClassName(): string;
  50588. private _colorGradientsTexture;
  50589. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50590. /**
  50591. * Adds a new color gradient
  50592. * @param gradient defines the gradient to use (between 0 and 1)
  50593. * @param color1 defines the color to affect to the specified gradient
  50594. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50595. * @returns the current particle system
  50596. */
  50597. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50598. /**
  50599. * Remove a specific color gradient
  50600. * @param gradient defines the gradient to remove
  50601. * @returns the current particle system
  50602. */
  50603. removeColorGradient(gradient: number): GPUParticleSystem;
  50604. private _angularSpeedGradientsTexture;
  50605. private _sizeGradientsTexture;
  50606. private _velocityGradientsTexture;
  50607. private _limitVelocityGradientsTexture;
  50608. private _dragGradientsTexture;
  50609. private _addFactorGradient;
  50610. /**
  50611. * Adds a new size gradient
  50612. * @param gradient defines the gradient to use (between 0 and 1)
  50613. * @param factor defines the size factor to affect to the specified gradient
  50614. * @returns the current particle system
  50615. */
  50616. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50617. /**
  50618. * Remove a specific size gradient
  50619. * @param gradient defines the gradient to remove
  50620. * @returns the current particle system
  50621. */
  50622. removeSizeGradient(gradient: number): GPUParticleSystem;
  50623. /**
  50624. * Adds a new angular speed gradient
  50625. * @param gradient defines the gradient to use (between 0 and 1)
  50626. * @param factor defines the angular speed to affect to the specified gradient
  50627. * @returns the current particle system
  50628. */
  50629. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50630. /**
  50631. * Remove a specific angular speed gradient
  50632. * @param gradient defines the gradient to remove
  50633. * @returns the current particle system
  50634. */
  50635. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50636. /**
  50637. * Adds a new velocity gradient
  50638. * @param gradient defines the gradient to use (between 0 and 1)
  50639. * @param factor defines the velocity to affect to the specified gradient
  50640. * @returns the current particle system
  50641. */
  50642. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50643. /**
  50644. * Remove a specific velocity gradient
  50645. * @param gradient defines the gradient to remove
  50646. * @returns the current particle system
  50647. */
  50648. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50649. /**
  50650. * Adds a new limit velocity gradient
  50651. * @param gradient defines the gradient to use (between 0 and 1)
  50652. * @param factor defines the limit velocity value to affect to the specified gradient
  50653. * @returns the current particle system
  50654. */
  50655. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50656. /**
  50657. * Remove a specific limit velocity gradient
  50658. * @param gradient defines the gradient to remove
  50659. * @returns the current particle system
  50660. */
  50661. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50662. /**
  50663. * Adds a new drag gradient
  50664. * @param gradient defines the gradient to use (between 0 and 1)
  50665. * @param factor defines the drag value to affect to the specified gradient
  50666. * @returns the current particle system
  50667. */
  50668. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50669. /**
  50670. * Remove a specific drag gradient
  50671. * @param gradient defines the gradient to remove
  50672. * @returns the current particle system
  50673. */
  50674. removeDragGradient(gradient: number): GPUParticleSystem;
  50675. /**
  50676. * Not supported by GPUParticleSystem
  50677. * @param gradient defines the gradient to use (between 0 and 1)
  50678. * @param factor defines the emit rate value to affect to the specified gradient
  50679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50680. * @returns the current particle system
  50681. */
  50682. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50683. /**
  50684. * Not supported by GPUParticleSystem
  50685. * @param gradient defines the gradient to remove
  50686. * @returns the current particle system
  50687. */
  50688. removeEmitRateGradient(gradient: number): IParticleSystem;
  50689. /**
  50690. * Not supported by GPUParticleSystem
  50691. * @param gradient defines the gradient to use (between 0 and 1)
  50692. * @param factor defines the start size value to affect to the specified gradient
  50693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50694. * @returns the current particle system
  50695. */
  50696. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50697. /**
  50698. * Not supported by GPUParticleSystem
  50699. * @param gradient defines the gradient to remove
  50700. * @returns the current particle system
  50701. */
  50702. removeStartSizeGradient(gradient: number): IParticleSystem;
  50703. /**
  50704. * Not supported by GPUParticleSystem
  50705. * @param gradient defines the gradient to use (between 0 and 1)
  50706. * @param min defines the color remap minimal range
  50707. * @param max defines the color remap maximal range
  50708. * @returns the current particle system
  50709. */
  50710. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50711. /**
  50712. * Not supported by GPUParticleSystem
  50713. * @param gradient defines the gradient to remove
  50714. * @returns the current particle system
  50715. */
  50716. removeColorRemapGradient(): IParticleSystem;
  50717. /**
  50718. * Not supported by GPUParticleSystem
  50719. * @param gradient defines the gradient to use (between 0 and 1)
  50720. * @param min defines the alpha remap minimal range
  50721. * @param max defines the alpha remap maximal range
  50722. * @returns the current particle system
  50723. */
  50724. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50725. /**
  50726. * Not supported by GPUParticleSystem
  50727. * @param gradient defines the gradient to remove
  50728. * @returns the current particle system
  50729. */
  50730. removeAlphaRemapGradient(): IParticleSystem;
  50731. /**
  50732. * Not supported by GPUParticleSystem
  50733. * @param gradient defines the gradient to use (between 0 and 1)
  50734. * @param color defines the color to affect to the specified gradient
  50735. * @returns the current particle system
  50736. */
  50737. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50738. /**
  50739. * Not supported by GPUParticleSystem
  50740. * @param gradient defines the gradient to remove
  50741. * @returns the current particle system
  50742. */
  50743. removeRampGradient(): IParticleSystem;
  50744. /**
  50745. * Not supported by GPUParticleSystem
  50746. * @returns the list of ramp gradients
  50747. */
  50748. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50749. /**
  50750. * Not supported by GPUParticleSystem
  50751. * Gets or sets a boolean indicating that ramp gradients must be used
  50752. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50753. */
  50754. useRampGradients: boolean;
  50755. /**
  50756. * Not supported by GPUParticleSystem
  50757. * @param gradient defines the gradient to use (between 0 and 1)
  50758. * @param factor defines the life time factor to affect to the specified gradient
  50759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50760. * @returns the current particle system
  50761. */
  50762. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50763. /**
  50764. * Not supported by GPUParticleSystem
  50765. * @param gradient defines the gradient to remove
  50766. * @returns the current particle system
  50767. */
  50768. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50769. /**
  50770. * Instantiates a GPU particle system.
  50771. * 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.
  50772. * @param name The name of the particle system
  50773. * @param options The options used to create the system
  50774. * @param scene The scene the particle system belongs to
  50775. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50776. */
  50777. constructor(name: string, options: Partial<{
  50778. capacity: number;
  50779. randomTextureSize: number;
  50780. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50781. protected _reset(): void;
  50782. private _createUpdateVAO;
  50783. private _createRenderVAO;
  50784. private _initialize;
  50785. /** @hidden */ recreateUpdateEffect(): void;
  50786. /** @hidden */ recreateRenderEffect(): void;
  50787. /**
  50788. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50789. * @param preWarm defines if we are in the pre-warmimg phase
  50790. */
  50791. animate(preWarm?: boolean): void;
  50792. private _createFactorGradientTexture;
  50793. private _createSizeGradientTexture;
  50794. private _createAngularSpeedGradientTexture;
  50795. private _createVelocityGradientTexture;
  50796. private _createLimitVelocityGradientTexture;
  50797. private _createDragGradientTexture;
  50798. private _createColorGradientTexture;
  50799. /**
  50800. * Renders the particle system in its current state
  50801. * @param preWarm defines if the system should only update the particles but not render them
  50802. * @returns the current number of particles
  50803. */
  50804. render(preWarm?: boolean): number;
  50805. /**
  50806. * Rebuilds the particle system
  50807. */
  50808. rebuild(): void;
  50809. private _releaseBuffers;
  50810. private _releaseVAOs;
  50811. /**
  50812. * Disposes the particle system and free the associated resources
  50813. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50814. */
  50815. dispose(disposeTexture?: boolean): void;
  50816. /**
  50817. * Clones the particle system.
  50818. * @param name The name of the cloned object
  50819. * @param newEmitter The new emitter to use
  50820. * @returns the cloned particle system
  50821. */
  50822. clone(name: string, newEmitter: any): GPUParticleSystem;
  50823. /**
  50824. * Serializes the particle system to a JSON object.
  50825. * @returns the JSON object
  50826. */
  50827. serialize(): any;
  50828. /**
  50829. * Parses a JSON object to create a GPU particle system.
  50830. * @param parsedParticleSystem The JSON object to parse
  50831. * @param scene The scene to create the particle system in
  50832. * @param rootUrl The root url to use to load external dependencies like texture
  50833. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50834. * @returns the parsed GPU particle system
  50835. */
  50836. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50837. }
  50838. }
  50839. declare module BABYLON {
  50840. /**
  50841. * Represents a set of particle systems working together to create a specific effect
  50842. */
  50843. export class ParticleSystemSet implements IDisposable {
  50844. private _emitterCreationOptions;
  50845. private _emitterNode;
  50846. /**
  50847. * Gets the particle system list
  50848. */
  50849. systems: IParticleSystem[];
  50850. /**
  50851. * Gets the emitter node used with this set
  50852. */
  50853. readonly emitterNode: Nullable<TransformNode>;
  50854. /**
  50855. * Creates a new emitter mesh as a sphere
  50856. * @param options defines the options used to create the sphere
  50857. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50858. * @param scene defines the hosting scene
  50859. */
  50860. setEmitterAsSphere(options: {
  50861. diameter: number;
  50862. segments: number;
  50863. color: Color3;
  50864. }, renderingGroupId: number, scene: Scene): void;
  50865. /**
  50866. * Starts all particle systems of the set
  50867. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50868. */
  50869. start(emitter?: AbstractMesh): void;
  50870. /**
  50871. * Release all associated resources
  50872. */
  50873. dispose(): void;
  50874. /**
  50875. * Serialize the set into a JSON compatible object
  50876. * @returns a JSON compatible representation of the set
  50877. */
  50878. serialize(): any;
  50879. /**
  50880. * Parse a new ParticleSystemSet from a serialized source
  50881. * @param data defines a JSON compatible representation of the set
  50882. * @param scene defines the hosting scene
  50883. * @param gpu defines if we want GPU particles or CPU particles
  50884. * @returns a new ParticleSystemSet
  50885. */
  50886. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50887. }
  50888. }
  50889. declare module BABYLON {
  50890. /**
  50891. * This class is made for on one-liner static method to help creating particle system set.
  50892. */
  50893. export class ParticleHelper {
  50894. /**
  50895. * Gets or sets base Assets URL
  50896. */
  50897. static BaseAssetsUrl: string;
  50898. /**
  50899. * Create a default particle system that you can tweak
  50900. * @param emitter defines the emitter to use
  50901. * @param capacity defines the system capacity (default is 500 particles)
  50902. * @param scene defines the hosting scene
  50903. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50904. * @returns the new Particle system
  50905. */
  50906. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50907. /**
  50908. * This is the main static method (one-liner) of this helper to create different particle systems
  50909. * @param type This string represents the type to the particle system to create
  50910. * @param scene The scene where the particle system should live
  50911. * @param gpu If the system will use gpu
  50912. * @returns the ParticleSystemSet created
  50913. */
  50914. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50915. /**
  50916. * Static function used to export a particle system to a ParticleSystemSet variable.
  50917. * Please note that the emitter shape is not exported
  50918. * @param systems defines the particle systems to export
  50919. * @returns the created particle system set
  50920. */
  50921. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50922. }
  50923. }
  50924. declare module BABYLON {
  50925. interface Engine {
  50926. /**
  50927. * Create an effect to use with particle systems.
  50928. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50929. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50930. * @param uniformsNames defines a list of attribute names
  50931. * @param samplers defines an array of string used to represent textures
  50932. * @param defines defines the string containing the defines to use to compile the shaders
  50933. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50934. * @param onCompiled defines a function to call when the effect creation is successful
  50935. * @param onError defines a function to call when the effect creation has failed
  50936. * @returns the new Effect
  50937. */
  50938. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50939. }
  50940. interface Mesh {
  50941. /**
  50942. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50943. * @returns an array of IParticleSystem
  50944. */
  50945. getEmittedParticleSystems(): IParticleSystem[];
  50946. /**
  50947. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50948. * @returns an array of IParticleSystem
  50949. */
  50950. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50951. }
  50952. /**
  50953. * @hidden
  50954. */
  50955. export var _IDoNeedToBeInTheBuild: number;
  50956. }
  50957. declare module BABYLON {
  50958. interface Scene {
  50959. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50960. /**
  50961. * Gets the current physics engine
  50962. * @returns a IPhysicsEngine or null if none attached
  50963. */
  50964. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50965. /**
  50966. * Enables physics to the current scene
  50967. * @param gravity defines the scene's gravity for the physics engine
  50968. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50969. * @return a boolean indicating if the physics engine was initialized
  50970. */
  50971. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50972. /**
  50973. * Disables and disposes the physics engine associated with the scene
  50974. */
  50975. disablePhysicsEngine(): void;
  50976. /**
  50977. * Gets a boolean indicating if there is an active physics engine
  50978. * @returns a boolean indicating if there is an active physics engine
  50979. */
  50980. isPhysicsEnabled(): boolean;
  50981. /**
  50982. * Deletes a physics compound impostor
  50983. * @param compound defines the compound to delete
  50984. */
  50985. deleteCompoundImpostor(compound: any): void;
  50986. /**
  50987. * An event triggered when physic simulation is about to be run
  50988. */
  50989. onBeforePhysicsObservable: Observable<Scene>;
  50990. /**
  50991. * An event triggered when physic simulation has been done
  50992. */
  50993. onAfterPhysicsObservable: Observable<Scene>;
  50994. }
  50995. interface AbstractMesh {
  50996. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50997. /**
  50998. * Gets or sets impostor used for physic simulation
  50999. * @see http://doc.babylonjs.com/features/physics_engine
  51000. */
  51001. physicsImpostor: Nullable<PhysicsImpostor>;
  51002. /**
  51003. * Gets the current physics impostor
  51004. * @see http://doc.babylonjs.com/features/physics_engine
  51005. * @returns a physics impostor or null
  51006. */
  51007. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51008. /** Apply a physic impulse to the mesh
  51009. * @param force defines the force to apply
  51010. * @param contactPoint defines where to apply the force
  51011. * @returns the current mesh
  51012. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51013. */
  51014. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51015. /**
  51016. * Creates a physic joint between two meshes
  51017. * @param otherMesh defines the other mesh to use
  51018. * @param pivot1 defines the pivot to use on this mesh
  51019. * @param pivot2 defines the pivot to use on the other mesh
  51020. * @param options defines additional options (can be plugin dependent)
  51021. * @returns the current mesh
  51022. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51023. */
  51024. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51025. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  51026. }
  51027. /**
  51028. * Defines the physics engine scene component responsible to manage a physics engine
  51029. */
  51030. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51031. /**
  51032. * The component name helpful to identify the component in the list of scene components.
  51033. */
  51034. readonly name: string;
  51035. /**
  51036. * The scene the component belongs to.
  51037. */
  51038. scene: Scene;
  51039. /**
  51040. * Creates a new instance of the component for the given scene
  51041. * @param scene Defines the scene to register the component in
  51042. */
  51043. constructor(scene: Scene);
  51044. /**
  51045. * Registers the component in a given scene
  51046. */
  51047. register(): void;
  51048. /**
  51049. * Rebuilds the elements related to this component in case of
  51050. * context lost for instance.
  51051. */
  51052. rebuild(): void;
  51053. /**
  51054. * Disposes the component and the associated ressources
  51055. */
  51056. dispose(): void;
  51057. }
  51058. }
  51059. declare module BABYLON {
  51060. /**
  51061. * A helper for physics simulations
  51062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51063. */
  51064. export class PhysicsHelper {
  51065. private _scene;
  51066. private _physicsEngine;
  51067. /**
  51068. * Initializes the Physics helper
  51069. * @param scene Babylon.js scene
  51070. */
  51071. constructor(scene: Scene);
  51072. /**
  51073. * Applies a radial explosion impulse
  51074. * @param origin the origin of the explosion
  51075. * @param radiusOrEventOptions the radius or the options of radial explosion
  51076. * @param strength the explosion strength
  51077. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51078. * @returns A physics radial explosion event, or null
  51079. */
  51080. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51081. /**
  51082. * Applies a radial explosion force
  51083. * @param origin the origin of the explosion
  51084. * @param radiusOrEventOptions the radius or the options of radial explosion
  51085. * @param strength the explosion strength
  51086. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51087. * @returns A physics radial explosion event, or null
  51088. */
  51089. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51090. /**
  51091. * Creates a gravitational field
  51092. * @param origin the origin of the explosion
  51093. * @param radiusOrEventOptions the radius or the options of radial explosion
  51094. * @param strength the explosion strength
  51095. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51096. * @returns A physics gravitational field event, or null
  51097. */
  51098. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51099. /**
  51100. * Creates a physics updraft event
  51101. * @param origin the origin of the updraft
  51102. * @param radiusOrEventOptions the radius or the options of the updraft
  51103. * @param strength the strength of the updraft
  51104. * @param height the height of the updraft
  51105. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51106. * @returns A physics updraft event, or null
  51107. */
  51108. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51109. /**
  51110. * Creates a physics vortex event
  51111. * @param origin the of the vortex
  51112. * @param radiusOrEventOptions the radius or the options of the vortex
  51113. * @param strength the strength of the vortex
  51114. * @param height the height of the vortex
  51115. * @returns a Physics vortex event, or null
  51116. * A physics vortex event or null
  51117. */
  51118. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51119. }
  51120. /**
  51121. * Represents a physics radial explosion event
  51122. */
  51123. class PhysicsRadialExplosionEvent {
  51124. private _scene;
  51125. private _options;
  51126. private _sphere;
  51127. private _dataFetched;
  51128. /**
  51129. * Initializes a radial explosioin event
  51130. * @param _scene BabylonJS scene
  51131. * @param _options The options for the vortex event
  51132. */
  51133. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51134. /**
  51135. * Returns the data related to the radial explosion event (sphere).
  51136. * @returns The radial explosion event data
  51137. */
  51138. getData(): PhysicsRadialExplosionEventData;
  51139. /**
  51140. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51141. * @param impostor A physics imposter
  51142. * @param origin the origin of the explosion
  51143. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51144. */
  51145. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51146. /**
  51147. * Triggers affecterd impostors callbacks
  51148. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51149. */
  51150. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51151. /**
  51152. * Disposes the sphere.
  51153. * @param force Specifies if the sphere should be disposed by force
  51154. */
  51155. dispose(force?: boolean): void;
  51156. /*** Helpers ***/
  51157. private _prepareSphere;
  51158. private _intersectsWithSphere;
  51159. }
  51160. /**
  51161. * Represents a gravitational field event
  51162. */
  51163. class PhysicsGravitationalFieldEvent {
  51164. private _physicsHelper;
  51165. private _scene;
  51166. private _origin;
  51167. private _options;
  51168. private _tickCallback;
  51169. private _sphere;
  51170. private _dataFetched;
  51171. /**
  51172. * Initializes the physics gravitational field event
  51173. * @param _physicsHelper A physics helper
  51174. * @param _scene BabylonJS scene
  51175. * @param _origin The origin position of the gravitational field event
  51176. * @param _options The options for the vortex event
  51177. */
  51178. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51179. /**
  51180. * Returns the data related to the gravitational field event (sphere).
  51181. * @returns A gravitational field event
  51182. */
  51183. getData(): PhysicsGravitationalFieldEventData;
  51184. /**
  51185. * Enables the gravitational field.
  51186. */
  51187. enable(): void;
  51188. /**
  51189. * Disables the gravitational field.
  51190. */
  51191. disable(): void;
  51192. /**
  51193. * Disposes the sphere.
  51194. * @param force The force to dispose from the gravitational field event
  51195. */
  51196. dispose(force?: boolean): void;
  51197. private _tick;
  51198. }
  51199. /**
  51200. * Represents a physics updraft event
  51201. */
  51202. class PhysicsUpdraftEvent {
  51203. private _scene;
  51204. private _origin;
  51205. private _options;
  51206. private _physicsEngine;
  51207. private _originTop;
  51208. private _originDirection;
  51209. private _tickCallback;
  51210. private _cylinder;
  51211. private _cylinderPosition;
  51212. private _dataFetched;
  51213. /**
  51214. * Initializes the physics updraft event
  51215. * @param _scene BabylonJS scene
  51216. * @param _origin The origin position of the updraft
  51217. * @param _options The options for the updraft event
  51218. */
  51219. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51220. /**
  51221. * Returns the data related to the updraft event (cylinder).
  51222. * @returns A physics updraft event
  51223. */
  51224. getData(): PhysicsUpdraftEventData;
  51225. /**
  51226. * Enables the updraft.
  51227. */
  51228. enable(): void;
  51229. /**
  51230. * Disables the updraft.
  51231. */
  51232. disable(): void;
  51233. /**
  51234. * Disposes the cylinder.
  51235. * @param force Specifies if the updraft should be disposed by force
  51236. */
  51237. dispose(force?: boolean): void;
  51238. private getImpostorHitData;
  51239. private _tick;
  51240. /*** Helpers ***/
  51241. private _prepareCylinder;
  51242. private _intersectsWithCylinder;
  51243. }
  51244. /**
  51245. * Represents a physics vortex event
  51246. */
  51247. class PhysicsVortexEvent {
  51248. private _scene;
  51249. private _origin;
  51250. private _options;
  51251. private _physicsEngine;
  51252. private _originTop;
  51253. private _tickCallback;
  51254. private _cylinder;
  51255. private _cylinderPosition;
  51256. private _dataFetched;
  51257. /**
  51258. * Initializes the physics vortex event
  51259. * @param _scene The BabylonJS scene
  51260. * @param _origin The origin position of the vortex
  51261. * @param _options The options for the vortex event
  51262. */
  51263. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51264. /**
  51265. * Returns the data related to the vortex event (cylinder).
  51266. * @returns The physics vortex event data
  51267. */
  51268. getData(): PhysicsVortexEventData;
  51269. /**
  51270. * Enables the vortex.
  51271. */
  51272. enable(): void;
  51273. /**
  51274. * Disables the cortex.
  51275. */
  51276. disable(): void;
  51277. /**
  51278. * Disposes the sphere.
  51279. * @param force
  51280. */
  51281. dispose(force?: boolean): void;
  51282. private getImpostorHitData;
  51283. private _tick;
  51284. /*** Helpers ***/
  51285. private _prepareCylinder;
  51286. private _intersectsWithCylinder;
  51287. }
  51288. /**
  51289. * Options fot the radial explosion event
  51290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51291. */
  51292. export class PhysicsRadialExplosionEventOptions {
  51293. /**
  51294. * The radius of the sphere for the radial explosion.
  51295. */
  51296. radius: number;
  51297. /**
  51298. * The strenth of the explosion.
  51299. */
  51300. strength: number;
  51301. /**
  51302. * The strenght of the force in correspondence to the distance of the affected object
  51303. */
  51304. falloff: PhysicsRadialImpulseFalloff;
  51305. /**
  51306. * Sphere options for the radial explosion.
  51307. */
  51308. sphere: {
  51309. segments: number;
  51310. diameter: number;
  51311. };
  51312. /**
  51313. * Sphere options for the radial explosion.
  51314. */
  51315. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51316. }
  51317. /**
  51318. * Options fot the updraft event
  51319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51320. */
  51321. export class PhysicsUpdraftEventOptions {
  51322. /**
  51323. * The radius of the cylinder for the vortex
  51324. */
  51325. radius: number;
  51326. /**
  51327. * The strenth of the updraft.
  51328. */
  51329. strength: number;
  51330. /**
  51331. * The height of the cylinder for the updraft.
  51332. */
  51333. height: number;
  51334. /**
  51335. * The mode for the the updraft.
  51336. */
  51337. updraftMode: PhysicsUpdraftMode;
  51338. }
  51339. /**
  51340. * Options fot the vortex event
  51341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51342. */
  51343. export class PhysicsVortexEventOptions {
  51344. /**
  51345. * The radius of the cylinder for the vortex
  51346. */
  51347. radius: number;
  51348. /**
  51349. * The strenth of the vortex.
  51350. */
  51351. strength: number;
  51352. /**
  51353. * The height of the cylinder for the vortex.
  51354. */
  51355. height: number;
  51356. /**
  51357. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51358. */
  51359. centripetalForceThreshold: number;
  51360. /**
  51361. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51362. */
  51363. centripetalForceMultiplier: number;
  51364. /**
  51365. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51366. */
  51367. centrifugalForceMultiplier: number;
  51368. /**
  51369. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51370. */
  51371. updraftForceMultiplier: number;
  51372. }
  51373. /**
  51374. * The strenght of the force in correspondence to the distance of the affected object
  51375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51376. */
  51377. export enum PhysicsRadialImpulseFalloff {
  51378. /** Defines that impulse is constant in strength across it's whole radius */
  51379. Constant = 0,
  51380. /** Defines that impulse gets weaker if it's further from the origin */
  51381. Linear = 1
  51382. }
  51383. /**
  51384. * The strength of the force in correspondence to the distance of the affected object
  51385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51386. */
  51387. export enum PhysicsUpdraftMode {
  51388. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51389. Center = 0,
  51390. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51391. Perpendicular = 1
  51392. }
  51393. /**
  51394. * Interface for a physics hit data
  51395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51396. */
  51397. export interface PhysicsHitData {
  51398. /**
  51399. * The force applied at the contact point
  51400. */
  51401. force: Vector3;
  51402. /**
  51403. * The contact point
  51404. */
  51405. contactPoint: Vector3;
  51406. /**
  51407. * The distance from the origin to the contact point
  51408. */
  51409. distanceFromOrigin: number;
  51410. }
  51411. /**
  51412. * Interface for radial explosion event data
  51413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51414. */
  51415. export interface PhysicsRadialExplosionEventData {
  51416. /**
  51417. * A sphere used for the radial explosion event
  51418. */
  51419. sphere: Mesh;
  51420. }
  51421. /**
  51422. * Interface for gravitational field event data
  51423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51424. */
  51425. export interface PhysicsGravitationalFieldEventData {
  51426. /**
  51427. * A sphere mesh used for the gravitational field event
  51428. */
  51429. sphere: Mesh;
  51430. }
  51431. /**
  51432. * Interface for updraft event data
  51433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51434. */
  51435. export interface PhysicsUpdraftEventData {
  51436. /**
  51437. * A cylinder used for the updraft event
  51438. */
  51439. cylinder: Mesh;
  51440. }
  51441. /**
  51442. * Interface for vortex event data
  51443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51444. */
  51445. export interface PhysicsVortexEventData {
  51446. /**
  51447. * A cylinder used for the vortex event
  51448. */
  51449. cylinder: Mesh;
  51450. }
  51451. /**
  51452. * Interface for an affected physics impostor
  51453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51454. */
  51455. export interface PhysicsAffectedImpostorWithData {
  51456. /**
  51457. * The impostor affected by the effect
  51458. */
  51459. impostor: PhysicsImpostor;
  51460. /**
  51461. * The data about the hit/horce from the explosion
  51462. */
  51463. hitData: PhysicsHitData;
  51464. }
  51465. }
  51466. declare module BABYLON {
  51467. /** @hidden */
  51468. export var blackAndWhitePixelShader: {
  51469. name: string;
  51470. shader: string;
  51471. };
  51472. }
  51473. declare module BABYLON {
  51474. /**
  51475. * Post process used to render in black and white
  51476. */
  51477. export class BlackAndWhitePostProcess extends PostProcess {
  51478. /**
  51479. * Linear about to convert he result to black and white (default: 1)
  51480. */
  51481. degree: number;
  51482. /**
  51483. * Creates a black and white post process
  51484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51485. * @param name The name of the effect.
  51486. * @param options The required width/height ratio to downsize to before computing the render pass.
  51487. * @param camera The camera to apply the render pass to.
  51488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51489. * @param engine The engine which the post process will be applied. (default: current engine)
  51490. * @param reusable If the post process can be reused on the same frame. (default: false)
  51491. */
  51492. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51493. }
  51494. }
  51495. declare module BABYLON {
  51496. /**
  51497. * This represents a set of one or more post processes in Babylon.
  51498. * A post process can be used to apply a shader to a texture after it is rendered.
  51499. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51500. */
  51501. export class PostProcessRenderEffect {
  51502. private _postProcesses;
  51503. private _getPostProcesses;
  51504. private _singleInstance;
  51505. private _cameras;
  51506. private _indicesForCamera;
  51507. /**
  51508. * Name of the effect
  51509. * @hidden
  51510. */ name: string;
  51511. /**
  51512. * Instantiates a post process render effect.
  51513. * A post process can be used to apply a shader to a texture after it is rendered.
  51514. * @param engine The engine the effect is tied to
  51515. * @param name The name of the effect
  51516. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51517. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51518. */
  51519. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51520. /**
  51521. * Checks if all the post processes in the effect are supported.
  51522. */
  51523. readonly isSupported: boolean;
  51524. /**
  51525. * Updates the current state of the effect
  51526. * @hidden
  51527. */ update(): void;
  51528. /**
  51529. * Attaches the effect on cameras
  51530. * @param cameras The camera to attach to.
  51531. * @hidden
  51532. */ attachCameras(cameras: Camera): void;
  51533. /**
  51534. * Attaches the effect on cameras
  51535. * @param cameras The camera to attach to.
  51536. * @hidden
  51537. */ attachCameras(cameras: Camera[]): void;
  51538. /**
  51539. * Detaches the effect on cameras
  51540. * @param cameras The camera to detatch from.
  51541. * @hidden
  51542. */ detachCameras(cameras: Camera): void;
  51543. /**
  51544. * Detatches the effect on cameras
  51545. * @param cameras The camera to detatch from.
  51546. * @hidden
  51547. */ detachCameras(cameras: Camera[]): void;
  51548. /**
  51549. * Enables the effect on given cameras
  51550. * @param cameras The camera to enable.
  51551. * @hidden
  51552. */ enable(cameras: Camera): void;
  51553. /**
  51554. * Enables the effect on given cameras
  51555. * @param cameras The camera to enable.
  51556. * @hidden
  51557. */ enable(cameras: Nullable<Camera[]>): void;
  51558. /**
  51559. * Disables the effect on the given cameras
  51560. * @param cameras The camera to disable.
  51561. * @hidden
  51562. */ disable(cameras: Camera): void;
  51563. /**
  51564. * Disables the effect on the given cameras
  51565. * @param cameras The camera to disable.
  51566. * @hidden
  51567. */ disable(cameras: Nullable<Camera[]>): void;
  51568. /**
  51569. * Gets a list of the post processes contained in the effect.
  51570. * @param camera The camera to get the post processes on.
  51571. * @returns The list of the post processes in the effect.
  51572. */
  51573. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /** @hidden */
  51578. export var extractHighlightsPixelShader: {
  51579. name: string;
  51580. shader: string;
  51581. };
  51582. }
  51583. declare module BABYLON {
  51584. /**
  51585. * 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.
  51586. */
  51587. export class ExtractHighlightsPostProcess extends PostProcess {
  51588. /**
  51589. * The luminance threshold, pixels below this value will be set to black.
  51590. */
  51591. threshold: number;
  51592. /** @hidden */ exposure: number;
  51593. /**
  51594. * Post process which has the input texture to be used when performing highlight extraction
  51595. * @hidden
  51596. */ inputPostProcess: Nullable<PostProcess>;
  51597. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51598. }
  51599. }
  51600. declare module BABYLON {
  51601. /** @hidden */
  51602. export var bloomMergePixelShader: {
  51603. name: string;
  51604. shader: string;
  51605. };
  51606. }
  51607. declare module BABYLON {
  51608. /**
  51609. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51610. */
  51611. export class BloomMergePostProcess extends PostProcess {
  51612. /** Weight of the bloom to be added to the original input. */
  51613. weight: number;
  51614. /**
  51615. * Creates a new instance of @see BloomMergePostProcess
  51616. * @param name The name of the effect.
  51617. * @param originalFromInput Post process which's input will be used for the merge.
  51618. * @param blurred Blurred highlights post process which's output will be used.
  51619. * @param weight Weight of the bloom to be added to the original input.
  51620. * @param options The required width/height ratio to downsize to before computing the render pass.
  51621. * @param camera The camera to apply the render pass to.
  51622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51623. * @param engine The engine which the post process will be applied. (default: current engine)
  51624. * @param reusable If the post process can be reused on the same frame. (default: false)
  51625. * @param textureType Type of textures used when performing the post process. (default: 0)
  51626. * @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)
  51627. */
  51628. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51629. /** Weight of the bloom to be added to the original input. */
  51630. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51631. }
  51632. }
  51633. declare module BABYLON {
  51634. /**
  51635. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51636. */
  51637. export class BloomEffect extends PostProcessRenderEffect {
  51638. private bloomScale;
  51639. /**
  51640. * @hidden Internal
  51641. */ effects: Array<PostProcess>;
  51642. /**
  51643. * @hidden Internal
  51644. */ downscale: ExtractHighlightsPostProcess;
  51645. private _blurX;
  51646. private _blurY;
  51647. private _merge;
  51648. /**
  51649. * The luminance threshold to find bright areas of the image to bloom.
  51650. */
  51651. threshold: number;
  51652. /**
  51653. * The strength of the bloom.
  51654. */
  51655. weight: number;
  51656. /**
  51657. * Specifies the size of the bloom blur kernel, relative to the final output size
  51658. */
  51659. kernel: number;
  51660. /**
  51661. * Creates a new instance of @see BloomEffect
  51662. * @param scene The scene the effect belongs to.
  51663. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51664. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51665. * @param bloomWeight The the strength of bloom.
  51666. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51667. * @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)
  51668. */
  51669. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51670. /**
  51671. * Disposes each of the internal effects for a given camera.
  51672. * @param camera The camera to dispose the effect on.
  51673. */
  51674. disposeEffects(camera: Camera): void;
  51675. /**
  51676. * @hidden Internal
  51677. */ updateEffects(): void;
  51678. /**
  51679. * Internal
  51680. * @returns if all the contained post processes are ready.
  51681. * @hidden
  51682. */ isReady(): boolean;
  51683. }
  51684. }
  51685. declare module BABYLON {
  51686. /** @hidden */
  51687. export var chromaticAberrationPixelShader: {
  51688. name: string;
  51689. shader: string;
  51690. };
  51691. }
  51692. declare module BABYLON {
  51693. /**
  51694. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51695. */
  51696. export class ChromaticAberrationPostProcess extends PostProcess {
  51697. /**
  51698. * The amount of seperation of rgb channels (default: 30)
  51699. */
  51700. aberrationAmount: number;
  51701. /**
  51702. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51703. */
  51704. radialIntensity: number;
  51705. /**
  51706. * 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))
  51707. */
  51708. direction: Vector2;
  51709. /**
  51710. * 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))
  51711. */
  51712. centerPosition: Vector2;
  51713. /**
  51714. * Creates a new instance ChromaticAberrationPostProcess
  51715. * @param name The name of the effect.
  51716. * @param screenWidth The width of the screen to apply the effect on.
  51717. * @param screenHeight The height of the screen to apply the effect on.
  51718. * @param options The required width/height ratio to downsize to before computing the render pass.
  51719. * @param camera The camera to apply the render pass to.
  51720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51721. * @param engine The engine which the post process will be applied. (default: current engine)
  51722. * @param reusable If the post process can be reused on the same frame. (default: false)
  51723. * @param textureType Type of textures used when performing the post process. (default: 0)
  51724. * @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)
  51725. */
  51726. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51727. }
  51728. }
  51729. declare module BABYLON {
  51730. /** @hidden */
  51731. export var circleOfConfusionPixelShader: {
  51732. name: string;
  51733. shader: string;
  51734. };
  51735. }
  51736. declare module BABYLON {
  51737. /**
  51738. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51739. */
  51740. export class CircleOfConfusionPostProcess extends PostProcess {
  51741. /**
  51742. * 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.
  51743. */
  51744. lensSize: number;
  51745. /**
  51746. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51747. */
  51748. fStop: number;
  51749. /**
  51750. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51751. */
  51752. focusDistance: number;
  51753. /**
  51754. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51755. */
  51756. focalLength: number;
  51757. private _depthTexture;
  51758. /**
  51759. * Creates a new instance CircleOfConfusionPostProcess
  51760. * @param name The name of the effect.
  51761. * @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.
  51762. * @param options The required width/height ratio to downsize to before computing the render pass.
  51763. * @param camera The camera to apply the render pass to.
  51764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51765. * @param engine The engine which the post process will be applied. (default: current engine)
  51766. * @param reusable If the post process can be reused on the same frame. (default: false)
  51767. * @param textureType Type of textures used when performing the post process. (default: 0)
  51768. * @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)
  51769. */
  51770. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51771. /**
  51772. * 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.
  51773. */
  51774. depthTexture: RenderTargetTexture;
  51775. }
  51776. }
  51777. declare module BABYLON {
  51778. /** @hidden */
  51779. export var colorCorrectionPixelShader: {
  51780. name: string;
  51781. shader: string;
  51782. };
  51783. }
  51784. declare module BABYLON {
  51785. /**
  51786. *
  51787. * This post-process allows the modification of rendered colors by using
  51788. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51789. *
  51790. * The object needs to be provided an url to a texture containing the color
  51791. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51792. * Use an image editing software to tweak the LUT to match your needs.
  51793. *
  51794. * For an example of a color LUT, see here:
  51795. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51796. * For explanations on color grading, see here:
  51797. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51798. *
  51799. */
  51800. export class ColorCorrectionPostProcess extends PostProcess {
  51801. private _colorTableTexture;
  51802. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51803. }
  51804. }
  51805. declare module BABYLON {
  51806. /** @hidden */
  51807. export var convolutionPixelShader: {
  51808. name: string;
  51809. shader: string;
  51810. };
  51811. }
  51812. declare module BABYLON {
  51813. /**
  51814. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51815. * input texture to perform effects such as edge detection or sharpening
  51816. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51817. */
  51818. export class ConvolutionPostProcess extends PostProcess {
  51819. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51820. kernel: number[];
  51821. /**
  51822. * Creates a new instance ConvolutionPostProcess
  51823. * @param name The name of the effect.
  51824. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51825. * @param options The required width/height ratio to downsize to before computing the render pass.
  51826. * @param camera The camera to apply the render pass to.
  51827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51828. * @param engine The engine which the post process will be applied. (default: current engine)
  51829. * @param reusable If the post process can be reused on the same frame. (default: false)
  51830. * @param textureType Type of textures used when performing the post process. (default: 0)
  51831. */
  51832. constructor(name: string,
  51833. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51834. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51835. /**
  51836. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51837. */
  51838. static EdgeDetect0Kernel: number[];
  51839. /**
  51840. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51841. */
  51842. static EdgeDetect1Kernel: number[];
  51843. /**
  51844. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51845. */
  51846. static EdgeDetect2Kernel: number[];
  51847. /**
  51848. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51849. */
  51850. static SharpenKernel: number[];
  51851. /**
  51852. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51853. */
  51854. static EmbossKernel: number[];
  51855. /**
  51856. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51857. */
  51858. static GaussianKernel: number[];
  51859. }
  51860. }
  51861. declare module BABYLON {
  51862. /**
  51863. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51864. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51865. * based on samples that have a large difference in distance than the center pixel.
  51866. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51867. */
  51868. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51869. direction: Vector2;
  51870. /**
  51871. * Creates a new instance CircleOfConfusionPostProcess
  51872. * @param name The name of the effect.
  51873. * @param scene The scene the effect belongs to.
  51874. * @param direction The direction the blur should be applied.
  51875. * @param kernel The size of the kernel used to blur.
  51876. * @param options The required width/height ratio to downsize to before computing the render pass.
  51877. * @param camera The camera to apply the render pass to.
  51878. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51879. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51881. * @param engine The engine which the post process will be applied. (default: current engine)
  51882. * @param reusable If the post process can be reused on the same frame. (default: false)
  51883. * @param textureType Type of textures used when performing the post process. (default: 0)
  51884. * @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)
  51885. */
  51886. 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);
  51887. }
  51888. }
  51889. declare module BABYLON {
  51890. /** @hidden */
  51891. export var depthOfFieldMergePixelShader: {
  51892. name: string;
  51893. shader: string;
  51894. };
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * Options to be set when merging outputs from the default pipeline.
  51899. */
  51900. export class DepthOfFieldMergePostProcessOptions {
  51901. /**
  51902. * The original image to merge on top of
  51903. */
  51904. originalFromInput: PostProcess;
  51905. /**
  51906. * Parameters to perform the merge of the depth of field effect
  51907. */
  51908. depthOfField?: {
  51909. circleOfConfusion: PostProcess;
  51910. blurSteps: Array<PostProcess>;
  51911. };
  51912. /**
  51913. * Parameters to perform the merge of bloom effect
  51914. */
  51915. bloom?: {
  51916. blurred: PostProcess;
  51917. weight: number;
  51918. };
  51919. }
  51920. /**
  51921. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51922. */
  51923. export class DepthOfFieldMergePostProcess extends PostProcess {
  51924. private blurSteps;
  51925. /**
  51926. * Creates a new instance of DepthOfFieldMergePostProcess
  51927. * @param name The name of the effect.
  51928. * @param originalFromInput Post process which's input will be used for the merge.
  51929. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51930. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51931. * @param options The required width/height ratio to downsize to before computing the render pass.
  51932. * @param camera The camera to apply the render pass to.
  51933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51934. * @param engine The engine which the post process will be applied. (default: current engine)
  51935. * @param reusable If the post process can be reused on the same frame. (default: false)
  51936. * @param textureType Type of textures used when performing the post process. (default: 0)
  51937. * @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)
  51938. */
  51939. 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);
  51940. /**
  51941. * Updates the effect with the current post process compile time values and recompiles the shader.
  51942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51945. * @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
  51946. * @param onCompiled Called when the shader has been compiled.
  51947. * @param onError Called if there is an error when compiling a shader.
  51948. */
  51949. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51950. }
  51951. }
  51952. declare module BABYLON {
  51953. /**
  51954. * Specifies the level of max blur that should be applied when using the depth of field effect
  51955. */
  51956. export enum DepthOfFieldEffectBlurLevel {
  51957. /**
  51958. * Subtle blur
  51959. */
  51960. Low = 0,
  51961. /**
  51962. * Medium blur
  51963. */
  51964. Medium = 1,
  51965. /**
  51966. * Large blur
  51967. */
  51968. High = 2
  51969. }
  51970. /**
  51971. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51972. */
  51973. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51974. private _circleOfConfusion;
  51975. /**
  51976. * @hidden Internal, blurs from high to low
  51977. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51978. private _depthOfFieldBlurY;
  51979. private _dofMerge;
  51980. /**
  51981. * @hidden Internal post processes in depth of field effect
  51982. */ effects: Array<PostProcess>;
  51983. /**
  51984. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51985. */
  51986. focalLength: number;
  51987. /**
  51988. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51989. */
  51990. fStop: number;
  51991. /**
  51992. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51993. */
  51994. focusDistance: number;
  51995. /**
  51996. * 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.
  51997. */
  51998. lensSize: number;
  51999. /**
  52000. * Creates a new instance DepthOfFieldEffect
  52001. * @param scene The scene the effect belongs to.
  52002. * @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.
  52003. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52004. * @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)
  52005. */
  52006. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52007. /**
  52008. * Get the current class name of the current effet
  52009. * @returns "DepthOfFieldEffect"
  52010. */
  52011. getClassName(): string;
  52012. /**
  52013. * 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.
  52014. */
  52015. depthTexture: RenderTargetTexture;
  52016. /**
  52017. * Disposes each of the internal effects for a given camera.
  52018. * @param camera The camera to dispose the effect on.
  52019. */
  52020. disposeEffects(camera: Camera): void;
  52021. /**
  52022. * @hidden Internal
  52023. */ updateEffects(): void;
  52024. /**
  52025. * Internal
  52026. * @returns if all the contained post processes are ready.
  52027. * @hidden
  52028. */ isReady(): boolean;
  52029. }
  52030. }
  52031. declare module BABYLON {
  52032. /** @hidden */
  52033. export var displayPassPixelShader: {
  52034. name: string;
  52035. shader: string;
  52036. };
  52037. }
  52038. declare module BABYLON {
  52039. /**
  52040. * DisplayPassPostProcess which produces an output the same as it's input
  52041. */
  52042. export class DisplayPassPostProcess extends PostProcess {
  52043. /**
  52044. * Creates the DisplayPassPostProcess
  52045. * @param name The name of the effect.
  52046. * @param options The required width/height ratio to downsize to before computing the render pass.
  52047. * @param camera The camera to apply the render pass to.
  52048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52049. * @param engine The engine which the post process will be applied. (default: current engine)
  52050. * @param reusable If the post process can be reused on the same frame. (default: false)
  52051. */
  52052. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52053. }
  52054. }
  52055. declare module BABYLON {
  52056. /** @hidden */
  52057. export var filterPixelShader: {
  52058. name: string;
  52059. shader: string;
  52060. };
  52061. }
  52062. declare module BABYLON {
  52063. /**
  52064. * Applies a kernel filter to the image
  52065. */
  52066. export class FilterPostProcess extends PostProcess {
  52067. /** The matrix to be applied to the image */
  52068. kernelMatrix: Matrix;
  52069. /**
  52070. *
  52071. * @param name The name of the effect.
  52072. * @param kernelMatrix The matrix to be applied to the image
  52073. * @param options The required width/height ratio to downsize to before computing the render pass.
  52074. * @param camera The camera to apply the render pass to.
  52075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52076. * @param engine The engine which the post process will be applied. (default: current engine)
  52077. * @param reusable If the post process can be reused on the same frame. (default: false)
  52078. */
  52079. constructor(name: string,
  52080. /** The matrix to be applied to the image */
  52081. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /** @hidden */
  52086. export var fxaaPixelShader: {
  52087. name: string;
  52088. shader: string;
  52089. };
  52090. }
  52091. declare module BABYLON {
  52092. /** @hidden */
  52093. export var fxaaVertexShader: {
  52094. name: string;
  52095. shader: string;
  52096. };
  52097. }
  52098. declare module BABYLON {
  52099. /**
  52100. * Fxaa post process
  52101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52102. */
  52103. export class FxaaPostProcess extends PostProcess {
  52104. /** @hidden */
  52105. texelWidth: number;
  52106. /** @hidden */
  52107. texelHeight: number;
  52108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52109. private _getDefines;
  52110. }
  52111. }
  52112. declare module BABYLON {
  52113. /** @hidden */
  52114. export var grainPixelShader: {
  52115. name: string;
  52116. shader: string;
  52117. };
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * The GrainPostProcess adds noise to the image at mid luminance levels
  52122. */
  52123. export class GrainPostProcess extends PostProcess {
  52124. /**
  52125. * The intensity of the grain added (default: 30)
  52126. */
  52127. intensity: number;
  52128. /**
  52129. * If the grain should be randomized on every frame
  52130. */
  52131. animated: boolean;
  52132. /**
  52133. * Creates a new instance of @see GrainPostProcess
  52134. * @param name The name of the effect.
  52135. * @param options The required width/height ratio to downsize to before computing the render pass.
  52136. * @param camera The camera to apply the render pass to.
  52137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52138. * @param engine The engine which the post process will be applied. (default: current engine)
  52139. * @param reusable If the post process can be reused on the same frame. (default: false)
  52140. * @param textureType Type of textures used when performing the post process. (default: 0)
  52141. * @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)
  52142. */
  52143. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52144. }
  52145. }
  52146. declare module BABYLON {
  52147. /** @hidden */
  52148. export var highlightsPixelShader: {
  52149. name: string;
  52150. shader: string;
  52151. };
  52152. }
  52153. declare module BABYLON {
  52154. /**
  52155. * Extracts highlights from the image
  52156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52157. */
  52158. export class HighlightsPostProcess extends PostProcess {
  52159. /**
  52160. * Extracts highlights from the image
  52161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52162. * @param name The name of the effect.
  52163. * @param options The required width/height ratio to downsize to before computing the render pass.
  52164. * @param camera The camera to apply the render pass to.
  52165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52166. * @param engine The engine which the post process will be applied. (default: current engine)
  52167. * @param reusable If the post process can be reused on the same frame. (default: false)
  52168. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52169. */
  52170. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52171. }
  52172. }
  52173. declare module BABYLON {
  52174. /** @hidden */
  52175. export var mrtFragmentDeclaration: {
  52176. name: string;
  52177. shader: string;
  52178. };
  52179. }
  52180. declare module BABYLON {
  52181. /** @hidden */
  52182. export var geometryPixelShader: {
  52183. name: string;
  52184. shader: string;
  52185. };
  52186. }
  52187. declare module BABYLON {
  52188. /** @hidden */
  52189. export var geometryVertexShader: {
  52190. name: string;
  52191. shader: string;
  52192. };
  52193. }
  52194. declare module BABYLON {
  52195. /**
  52196. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52197. */
  52198. export class GeometryBufferRenderer {
  52199. /**
  52200. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52201. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52202. */
  52203. static readonly POSITION_TEXTURE_TYPE: number;
  52204. /**
  52205. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52206. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52207. */
  52208. static readonly VELOCITY_TEXTURE_TYPE: number;
  52209. /**
  52210. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52211. * in order to compute objects velocities when enableVelocity is set to "true"
  52212. * @hidden
  52213. */ previousTransformationMatrices: {
  52214. [index: number]: Matrix;
  52215. };
  52216. private _scene;
  52217. private _multiRenderTarget;
  52218. private _ratio;
  52219. private _enablePosition;
  52220. private _enableVelocity;
  52221. private _positionIndex;
  52222. private _velocityIndex;
  52223. protected _effect: Effect;
  52224. protected _cachedDefines: string;
  52225. /**
  52226. * Set the render list (meshes to be rendered) used in the G buffer.
  52227. */
  52228. renderList: Mesh[];
  52229. /**
  52230. * Gets wether or not G buffer are supported by the running hardware.
  52231. * This requires draw buffer supports
  52232. */
  52233. readonly isSupported: boolean;
  52234. /**
  52235. * Returns the index of the given texture type in the G-Buffer textures array
  52236. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52237. * @returns the index of the given texture type in the G-Buffer textures array
  52238. */
  52239. getTextureIndex(textureType: number): number;
  52240. /**
  52241. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52242. */
  52243. /**
  52244. * Sets whether or not objects positions are enabled for the G buffer.
  52245. */
  52246. enablePosition: boolean;
  52247. /**
  52248. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52249. */
  52250. /**
  52251. * Sets wether or not objects velocities are enabled for the G buffer.
  52252. */
  52253. enableVelocity: boolean;
  52254. /**
  52255. * Gets the scene associated with the buffer.
  52256. */
  52257. readonly scene: Scene;
  52258. /**
  52259. * Gets the ratio used by the buffer during its creation.
  52260. * How big is the buffer related to the main canvas.
  52261. */
  52262. readonly ratio: number;
  52263. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52264. /**
  52265. * Creates a new G Buffer for the scene
  52266. * @param scene The scene the buffer belongs to
  52267. * @param ratio How big is the buffer related to the main canvas.
  52268. */
  52269. constructor(scene: Scene, ratio?: number);
  52270. /**
  52271. * Checks wether everything is ready to render a submesh to the G buffer.
  52272. * @param subMesh the submesh to check readiness for
  52273. * @param useInstances is the mesh drawn using instance or not
  52274. * @returns true if ready otherwise false
  52275. */
  52276. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52277. /**
  52278. * Gets the current underlying G Buffer.
  52279. * @returns the buffer
  52280. */
  52281. getGBuffer(): MultiRenderTarget;
  52282. /**
  52283. * Gets the number of samples used to render the buffer (anti aliasing).
  52284. */
  52285. /**
  52286. * Sets the number of samples used to render the buffer (anti aliasing).
  52287. */
  52288. samples: number;
  52289. /**
  52290. * Disposes the renderer and frees up associated resources.
  52291. */
  52292. dispose(): void;
  52293. protected _createRenderTargets(): void;
  52294. }
  52295. }
  52296. declare module BABYLON {
  52297. interface Scene {
  52298. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52299. /**
  52300. * Gets or Sets the current geometry buffer associated to the scene.
  52301. */
  52302. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52303. /**
  52304. * Enables a GeometryBufferRender and associates it with the scene
  52305. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52306. * @returns the GeometryBufferRenderer
  52307. */
  52308. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52309. /**
  52310. * Disables the GeometryBufferRender associated with the scene
  52311. */
  52312. disableGeometryBufferRenderer(): void;
  52313. }
  52314. /**
  52315. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52316. * in several rendering techniques.
  52317. */
  52318. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52319. /**
  52320. * The component name helpful to identify the component in the list of scene components.
  52321. */
  52322. readonly name: string;
  52323. /**
  52324. * The scene the component belongs to.
  52325. */
  52326. scene: Scene;
  52327. /**
  52328. * Creates a new instance of the component for the given scene
  52329. * @param scene Defines the scene to register the component in
  52330. */
  52331. constructor(scene: Scene);
  52332. /**
  52333. * Registers the component in a given scene
  52334. */
  52335. register(): void;
  52336. /**
  52337. * Rebuilds the elements related to this component in case of
  52338. * context lost for instance.
  52339. */
  52340. rebuild(): void;
  52341. /**
  52342. * Disposes the component and the associated ressources
  52343. */
  52344. dispose(): void;
  52345. private _gatherRenderTargets;
  52346. }
  52347. }
  52348. declare module BABYLON {
  52349. /** @hidden */
  52350. export var motionBlurPixelShader: {
  52351. name: string;
  52352. shader: string;
  52353. };
  52354. }
  52355. declare module BABYLON {
  52356. /**
  52357. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52358. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52359. * As an example, all you have to do is to create the post-process:
  52360. * var mb = new BABYLON.MotionBlurPostProcess(
  52361. * 'mb', // The name of the effect.
  52362. * scene, // The scene containing the objects to blur according to their velocity.
  52363. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52364. * camera // The camera to apply the render pass to.
  52365. * );
  52366. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52367. */
  52368. export class MotionBlurPostProcess extends PostProcess {
  52369. /**
  52370. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52371. */
  52372. motionStrength: number;
  52373. /**
  52374. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52375. */
  52376. /**
  52377. * Sets the number of iterations to be used for motion blur quality
  52378. */
  52379. motionBlurSamples: number;
  52380. private _motionBlurSamples;
  52381. private _geometryBufferRenderer;
  52382. /**
  52383. * Creates a new instance MotionBlurPostProcess
  52384. * @param name The name of the effect.
  52385. * @param scene The scene containing the objects to blur according to their velocity.
  52386. * @param options The required width/height ratio to downsize to before computing the render pass.
  52387. * @param camera The camera to apply the render pass to.
  52388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52389. * @param engine The engine which the post process will be applied. (default: current engine)
  52390. * @param reusable If the post process can be reused on the same frame. (default: false)
  52391. * @param textureType Type of textures used when performing the post process. (default: 0)
  52392. * @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)
  52393. */
  52394. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52395. /**
  52396. * Disposes the post process.
  52397. * @param camera The camera to dispose the post process on.
  52398. */
  52399. dispose(camera?: Camera): void;
  52400. }
  52401. }
  52402. declare module BABYLON {
  52403. /** @hidden */
  52404. export var refractionPixelShader: {
  52405. name: string;
  52406. shader: string;
  52407. };
  52408. }
  52409. declare module BABYLON {
  52410. /**
  52411. * Post process which applies a refractin texture
  52412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52413. */
  52414. export class RefractionPostProcess extends PostProcess {
  52415. /** the base color of the refraction (used to taint the rendering) */
  52416. color: Color3;
  52417. /** simulated refraction depth */
  52418. depth: number;
  52419. /** the coefficient of the base color (0 to remove base color tainting) */
  52420. colorLevel: number;
  52421. private _refTexture;
  52422. private _ownRefractionTexture;
  52423. /**
  52424. * Gets or sets the refraction texture
  52425. * Please note that you are responsible for disposing the texture if you set it manually
  52426. */
  52427. refractionTexture: Texture;
  52428. /**
  52429. * Initializes the RefractionPostProcess
  52430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52431. * @param name The name of the effect.
  52432. * @param refractionTextureUrl Url of the refraction texture to use
  52433. * @param color the base color of the refraction (used to taint the rendering)
  52434. * @param depth simulated refraction depth
  52435. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52436. * @param camera The camera to apply the render pass to.
  52437. * @param options The required width/height ratio to downsize to before computing the render pass.
  52438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52439. * @param engine The engine which the post process will be applied. (default: current engine)
  52440. * @param reusable If the post process can be reused on the same frame. (default: false)
  52441. */
  52442. constructor(name: string, refractionTextureUrl: string,
  52443. /** the base color of the refraction (used to taint the rendering) */
  52444. color: Color3,
  52445. /** simulated refraction depth */
  52446. depth: number,
  52447. /** the coefficient of the base color (0 to remove base color tainting) */
  52448. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52449. /**
  52450. * Disposes of the post process
  52451. * @param camera Camera to dispose post process on
  52452. */
  52453. dispose(camera: Camera): void;
  52454. }
  52455. }
  52456. declare module BABYLON {
  52457. /** @hidden */
  52458. export var sharpenPixelShader: {
  52459. name: string;
  52460. shader: string;
  52461. };
  52462. }
  52463. declare module BABYLON {
  52464. /**
  52465. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52466. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52467. */
  52468. export class SharpenPostProcess extends PostProcess {
  52469. /**
  52470. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52471. */
  52472. colorAmount: number;
  52473. /**
  52474. * How much sharpness should be applied (default: 0.3)
  52475. */
  52476. edgeAmount: number;
  52477. /**
  52478. * Creates a new instance ConvolutionPostProcess
  52479. * @param name The name of the effect.
  52480. * @param options The required width/height ratio to downsize to before computing the render pass.
  52481. * @param camera The camera to apply the render pass to.
  52482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52483. * @param engine The engine which the post process will be applied. (default: current engine)
  52484. * @param reusable If the post process can be reused on the same frame. (default: false)
  52485. * @param textureType Type of textures used when performing the post process. (default: 0)
  52486. * @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)
  52487. */
  52488. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52489. }
  52490. }
  52491. declare module BABYLON {
  52492. /**
  52493. * PostProcessRenderPipeline
  52494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52495. */
  52496. export class PostProcessRenderPipeline {
  52497. private engine;
  52498. private _renderEffects;
  52499. private _renderEffectsForIsolatedPass;
  52500. /**
  52501. * List of inspectable custom properties (used by the Inspector)
  52502. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52503. */
  52504. inspectableCustomProperties: IInspectable[];
  52505. /**
  52506. * @hidden
  52507. */
  52508. protected _cameras: Camera[];
  52509. /** @hidden */ name: string;
  52510. /**
  52511. * Gets pipeline name
  52512. */
  52513. readonly name: string;
  52514. /**
  52515. * Initializes a PostProcessRenderPipeline
  52516. * @param engine engine to add the pipeline to
  52517. * @param name name of the pipeline
  52518. */
  52519. constructor(engine: Engine, name: string);
  52520. /**
  52521. * Gets the class name
  52522. * @returns "PostProcessRenderPipeline"
  52523. */
  52524. getClassName(): string;
  52525. /**
  52526. * If all the render effects in the pipeline are supported
  52527. */
  52528. readonly isSupported: boolean;
  52529. /**
  52530. * Adds an effect to the pipeline
  52531. * @param renderEffect the effect to add
  52532. */
  52533. addEffect(renderEffect: PostProcessRenderEffect): void;
  52534. /** @hidden */ rebuild(): void;
  52535. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52536. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52537. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52538. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52539. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52540. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52541. /** @hidden */ detachCameras(cameras: Camera): void;
  52542. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52543. /** @hidden */ update(): void;
  52544. /** @hidden */ reset(): void;
  52545. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52546. /**
  52547. * Disposes of the pipeline
  52548. */
  52549. dispose(): void;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * PostProcessRenderPipelineManager class
  52555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52556. */
  52557. export class PostProcessRenderPipelineManager {
  52558. private _renderPipelines;
  52559. /**
  52560. * Initializes a PostProcessRenderPipelineManager
  52561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52562. */
  52563. constructor();
  52564. /**
  52565. * Gets the list of supported render pipelines
  52566. */
  52567. readonly supportedPipelines: PostProcessRenderPipeline[];
  52568. /**
  52569. * Adds a pipeline to the manager
  52570. * @param renderPipeline The pipeline to add
  52571. */
  52572. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52573. /**
  52574. * Attaches a camera to the pipeline
  52575. * @param renderPipelineName The name of the pipeline to attach to
  52576. * @param cameras the camera to attach
  52577. * @param unique if the camera can be attached multiple times to the pipeline
  52578. */
  52579. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52580. /**
  52581. * Detaches a camera from the pipeline
  52582. * @param renderPipelineName The name of the pipeline to detach from
  52583. * @param cameras the camera to detach
  52584. */
  52585. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52586. /**
  52587. * Enables an effect by name on a pipeline
  52588. * @param renderPipelineName the name of the pipeline to enable the effect in
  52589. * @param renderEffectName the name of the effect to enable
  52590. * @param cameras the cameras that the effect should be enabled on
  52591. */
  52592. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52593. /**
  52594. * Disables an effect by name on a pipeline
  52595. * @param renderPipelineName the name of the pipeline to disable the effect in
  52596. * @param renderEffectName the name of the effect to disable
  52597. * @param cameras the cameras that the effect should be disabled on
  52598. */
  52599. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52600. /**
  52601. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52602. */
  52603. update(): void;
  52604. /** @hidden */ rebuild(): void;
  52605. /**
  52606. * Disposes of the manager and pipelines
  52607. */
  52608. dispose(): void;
  52609. }
  52610. }
  52611. declare module BABYLON {
  52612. interface Scene {
  52613. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52614. /**
  52615. * Gets the postprocess render pipeline manager
  52616. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52617. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52618. */
  52619. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52620. }
  52621. /**
  52622. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52623. */
  52624. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52625. /**
  52626. * The component name helpfull to identify the component in the list of scene components.
  52627. */
  52628. readonly name: string;
  52629. /**
  52630. * The scene the component belongs to.
  52631. */
  52632. scene: Scene;
  52633. /**
  52634. * Creates a new instance of the component for the given scene
  52635. * @param scene Defines the scene to register the component in
  52636. */
  52637. constructor(scene: Scene);
  52638. /**
  52639. * Registers the component in a given scene
  52640. */
  52641. register(): void;
  52642. /**
  52643. * Rebuilds the elements related to this component in case of
  52644. * context lost for instance.
  52645. */
  52646. rebuild(): void;
  52647. /**
  52648. * Disposes the component and the associated ressources
  52649. */
  52650. dispose(): void;
  52651. private _gatherRenderTargets;
  52652. }
  52653. }
  52654. declare module BABYLON {
  52655. /**
  52656. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52657. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52658. */
  52659. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52660. private _scene;
  52661. private _camerasToBeAttached;
  52662. /**
  52663. * ID of the sharpen post process,
  52664. */
  52665. private readonly SharpenPostProcessId;
  52666. /**
  52667. * @ignore
  52668. * ID of the image processing post process;
  52669. */
  52670. readonly ImageProcessingPostProcessId: string;
  52671. /**
  52672. * @ignore
  52673. * ID of the Fast Approximate Anti-Aliasing post process;
  52674. */
  52675. readonly FxaaPostProcessId: string;
  52676. /**
  52677. * ID of the chromatic aberration post process,
  52678. */
  52679. private readonly ChromaticAberrationPostProcessId;
  52680. /**
  52681. * ID of the grain post process
  52682. */
  52683. private readonly GrainPostProcessId;
  52684. /**
  52685. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52686. */
  52687. sharpen: SharpenPostProcess;
  52688. private _sharpenEffect;
  52689. private bloom;
  52690. /**
  52691. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52692. */
  52693. depthOfField: DepthOfFieldEffect;
  52694. /**
  52695. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52696. */
  52697. fxaa: FxaaPostProcess;
  52698. /**
  52699. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52700. */
  52701. imageProcessing: ImageProcessingPostProcess;
  52702. /**
  52703. * Chromatic aberration post process which will shift rgb colors in the image
  52704. */
  52705. chromaticAberration: ChromaticAberrationPostProcess;
  52706. private _chromaticAberrationEffect;
  52707. /**
  52708. * Grain post process which add noise to the image
  52709. */
  52710. grain: GrainPostProcess;
  52711. private _grainEffect;
  52712. /**
  52713. * Glow post process which adds a glow to emissive areas of the image
  52714. */
  52715. private _glowLayer;
  52716. /**
  52717. * Animations which can be used to tweak settings over a period of time
  52718. */
  52719. animations: Animation[];
  52720. private _imageProcessingConfigurationObserver;
  52721. private _sharpenEnabled;
  52722. private _bloomEnabled;
  52723. private _depthOfFieldEnabled;
  52724. private _depthOfFieldBlurLevel;
  52725. private _fxaaEnabled;
  52726. private _imageProcessingEnabled;
  52727. private _defaultPipelineTextureType;
  52728. private _bloomScale;
  52729. private _chromaticAberrationEnabled;
  52730. private _grainEnabled;
  52731. private _buildAllowed;
  52732. /**
  52733. * Gets active scene
  52734. */
  52735. readonly scene: Scene;
  52736. /**
  52737. * Enable or disable the sharpen process from the pipeline
  52738. */
  52739. sharpenEnabled: boolean;
  52740. private _resizeObserver;
  52741. private _hardwareScaleLevel;
  52742. private _bloomKernel;
  52743. /**
  52744. * Specifies the size of the bloom blur kernel, relative to the final output size
  52745. */
  52746. bloomKernel: number;
  52747. /**
  52748. * Specifies the weight of the bloom in the final rendering
  52749. */
  52750. private _bloomWeight;
  52751. /**
  52752. * Specifies the luma threshold for the area that will be blurred by the bloom
  52753. */
  52754. private _bloomThreshold;
  52755. private _hdr;
  52756. /**
  52757. * The strength of the bloom.
  52758. */
  52759. bloomWeight: number;
  52760. /**
  52761. * The strength of the bloom.
  52762. */
  52763. bloomThreshold: number;
  52764. /**
  52765. * The scale of the bloom, lower value will provide better performance.
  52766. */
  52767. bloomScale: number;
  52768. /**
  52769. * Enable or disable the bloom from the pipeline
  52770. */
  52771. bloomEnabled: boolean;
  52772. private _rebuildBloom;
  52773. /**
  52774. * If the depth of field is enabled.
  52775. */
  52776. depthOfFieldEnabled: boolean;
  52777. /**
  52778. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52779. */
  52780. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52781. /**
  52782. * If the anti aliasing is enabled.
  52783. */
  52784. fxaaEnabled: boolean;
  52785. private _samples;
  52786. /**
  52787. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52788. */
  52789. samples: number;
  52790. /**
  52791. * If image processing is enabled.
  52792. */
  52793. imageProcessingEnabled: boolean;
  52794. /**
  52795. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52796. */
  52797. glowLayerEnabled: boolean;
  52798. /**
  52799. * Enable or disable the chromaticAberration process from the pipeline
  52800. */
  52801. chromaticAberrationEnabled: boolean;
  52802. /**
  52803. * Enable or disable the grain process from the pipeline
  52804. */
  52805. grainEnabled: boolean;
  52806. /**
  52807. * @constructor
  52808. * @param name - The rendering pipeline name (default: "")
  52809. * @param hdr - If high dynamic range textures should be used (default: true)
  52810. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52811. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52812. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52813. */
  52814. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52815. /**
  52816. * Get the class name
  52817. * @returns "DefaultRenderingPipeline"
  52818. */
  52819. getClassName(): string;
  52820. /**
  52821. * Force the compilation of the entire pipeline.
  52822. */
  52823. prepare(): void;
  52824. private _hasCleared;
  52825. private _prevPostProcess;
  52826. private _prevPrevPostProcess;
  52827. private _setAutoClearAndTextureSharing;
  52828. private _depthOfFieldSceneObserver;
  52829. private _buildPipeline;
  52830. private _disposePostProcesses;
  52831. /**
  52832. * Adds a camera to the pipeline
  52833. * @param camera the camera to be added
  52834. */
  52835. addCamera(camera: Camera): void;
  52836. /**
  52837. * Removes a camera from the pipeline
  52838. * @param camera the camera to remove
  52839. */
  52840. removeCamera(camera: Camera): void;
  52841. /**
  52842. * Dispose of the pipeline and stop all post processes
  52843. */
  52844. dispose(): void;
  52845. /**
  52846. * Serialize the rendering pipeline (Used when exporting)
  52847. * @returns the serialized object
  52848. */
  52849. serialize(): any;
  52850. /**
  52851. * Parse the serialized pipeline
  52852. * @param source Source pipeline.
  52853. * @param scene The scene to load the pipeline to.
  52854. * @param rootUrl The URL of the serialized pipeline.
  52855. * @returns An instantiated pipeline from the serialized object.
  52856. */
  52857. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52858. }
  52859. }
  52860. declare module BABYLON {
  52861. /** @hidden */
  52862. export var lensHighlightsPixelShader: {
  52863. name: string;
  52864. shader: string;
  52865. };
  52866. }
  52867. declare module BABYLON {
  52868. /** @hidden */
  52869. export var depthOfFieldPixelShader: {
  52870. name: string;
  52871. shader: string;
  52872. };
  52873. }
  52874. declare module BABYLON {
  52875. /**
  52876. * BABYLON.JS Chromatic Aberration GLSL Shader
  52877. * Author: Olivier Guyot
  52878. * Separates very slightly R, G and B colors on the edges of the screen
  52879. * Inspired by Francois Tarlier & Martins Upitis
  52880. */
  52881. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52882. /**
  52883. * @ignore
  52884. * The chromatic aberration PostProcess id in the pipeline
  52885. */
  52886. LensChromaticAberrationEffect: string;
  52887. /**
  52888. * @ignore
  52889. * The highlights enhancing PostProcess id in the pipeline
  52890. */
  52891. HighlightsEnhancingEffect: string;
  52892. /**
  52893. * @ignore
  52894. * The depth-of-field PostProcess id in the pipeline
  52895. */
  52896. LensDepthOfFieldEffect: string;
  52897. private _scene;
  52898. private _depthTexture;
  52899. private _grainTexture;
  52900. private _chromaticAberrationPostProcess;
  52901. private _highlightsPostProcess;
  52902. private _depthOfFieldPostProcess;
  52903. private _edgeBlur;
  52904. private _grainAmount;
  52905. private _chromaticAberration;
  52906. private _distortion;
  52907. private _highlightsGain;
  52908. private _highlightsThreshold;
  52909. private _dofDistance;
  52910. private _dofAperture;
  52911. private _dofDarken;
  52912. private _dofPentagon;
  52913. private _blurNoise;
  52914. /**
  52915. * @constructor
  52916. *
  52917. * Effect parameters are as follow:
  52918. * {
  52919. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52920. * edge_blur: number; // from 0 to x (1 for realism)
  52921. * distortion: number; // from 0 to x (1 for realism)
  52922. * grain_amount: number; // from 0 to 1
  52923. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52924. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52925. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52926. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52927. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52928. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52929. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52930. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52931. * }
  52932. * Note: if an effect parameter is unset, effect is disabled
  52933. *
  52934. * @param name The rendering pipeline name
  52935. * @param parameters - An object containing all parameters (see above)
  52936. * @param scene The scene linked to this pipeline
  52937. * @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)
  52938. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52939. */
  52940. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52941. /**
  52942. * Get the class name
  52943. * @returns "LensRenderingPipeline"
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Gets associated scene
  52948. */
  52949. readonly scene: Scene;
  52950. /**
  52951. * Gets or sets the edge blur
  52952. */
  52953. edgeBlur: number;
  52954. /**
  52955. * Gets or sets the grain amount
  52956. */
  52957. grainAmount: number;
  52958. /**
  52959. * Gets or sets the chromatic aberration amount
  52960. */
  52961. chromaticAberration: number;
  52962. /**
  52963. * Gets or sets the depth of field aperture
  52964. */
  52965. dofAperture: number;
  52966. /**
  52967. * Gets or sets the edge distortion
  52968. */
  52969. edgeDistortion: number;
  52970. /**
  52971. * Gets or sets the depth of field distortion
  52972. */
  52973. dofDistortion: number;
  52974. /**
  52975. * Gets or sets the darken out of focus amount
  52976. */
  52977. darkenOutOfFocus: number;
  52978. /**
  52979. * Gets or sets a boolean indicating if blur noise is enabled
  52980. */
  52981. blurNoise: boolean;
  52982. /**
  52983. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52984. */
  52985. pentagonBokeh: boolean;
  52986. /**
  52987. * Gets or sets the highlight grain amount
  52988. */
  52989. highlightsGain: number;
  52990. /**
  52991. * Gets or sets the highlight threshold
  52992. */
  52993. highlightsThreshold: number;
  52994. /**
  52995. * Sets the amount of blur at the edges
  52996. * @param amount blur amount
  52997. */
  52998. setEdgeBlur(amount: number): void;
  52999. /**
  53000. * Sets edge blur to 0
  53001. */
  53002. disableEdgeBlur(): void;
  53003. /**
  53004. * Sets the amout of grain
  53005. * @param amount Amount of grain
  53006. */
  53007. setGrainAmount(amount: number): void;
  53008. /**
  53009. * Set grain amount to 0
  53010. */
  53011. disableGrain(): void;
  53012. /**
  53013. * Sets the chromatic aberration amount
  53014. * @param amount amount of chromatic aberration
  53015. */
  53016. setChromaticAberration(amount: number): void;
  53017. /**
  53018. * Sets chromatic aberration amount to 0
  53019. */
  53020. disableChromaticAberration(): void;
  53021. /**
  53022. * Sets the EdgeDistortion amount
  53023. * @param amount amount of EdgeDistortion
  53024. */
  53025. setEdgeDistortion(amount: number): void;
  53026. /**
  53027. * Sets edge distortion to 0
  53028. */
  53029. disableEdgeDistortion(): void;
  53030. /**
  53031. * Sets the FocusDistance amount
  53032. * @param amount amount of FocusDistance
  53033. */
  53034. setFocusDistance(amount: number): void;
  53035. /**
  53036. * Disables depth of field
  53037. */
  53038. disableDepthOfField(): void;
  53039. /**
  53040. * Sets the Aperture amount
  53041. * @param amount amount of Aperture
  53042. */
  53043. setAperture(amount: number): void;
  53044. /**
  53045. * Sets the DarkenOutOfFocus amount
  53046. * @param amount amount of DarkenOutOfFocus
  53047. */
  53048. setDarkenOutOfFocus(amount: number): void;
  53049. private _pentagonBokehIsEnabled;
  53050. /**
  53051. * Creates a pentagon bokeh effect
  53052. */
  53053. enablePentagonBokeh(): void;
  53054. /**
  53055. * Disables the pentagon bokeh effect
  53056. */
  53057. disablePentagonBokeh(): void;
  53058. /**
  53059. * Enables noise blur
  53060. */
  53061. enableNoiseBlur(): void;
  53062. /**
  53063. * Disables noise blur
  53064. */
  53065. disableNoiseBlur(): void;
  53066. /**
  53067. * Sets the HighlightsGain amount
  53068. * @param amount amount of HighlightsGain
  53069. */
  53070. setHighlightsGain(amount: number): void;
  53071. /**
  53072. * Sets the HighlightsThreshold amount
  53073. * @param amount amount of HighlightsThreshold
  53074. */
  53075. setHighlightsThreshold(amount: number): void;
  53076. /**
  53077. * Disables highlights
  53078. */
  53079. disableHighlights(): void;
  53080. /**
  53081. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53082. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53083. */
  53084. dispose(disableDepthRender?: boolean): void;
  53085. private _createChromaticAberrationPostProcess;
  53086. private _createHighlightsPostProcess;
  53087. private _createDepthOfFieldPostProcess;
  53088. private _createGrainTexture;
  53089. }
  53090. }
  53091. declare module BABYLON {
  53092. /** @hidden */
  53093. export var ssao2PixelShader: {
  53094. name: string;
  53095. shader: string;
  53096. };
  53097. }
  53098. declare module BABYLON {
  53099. /** @hidden */
  53100. export var ssaoCombinePixelShader: {
  53101. name: string;
  53102. shader: string;
  53103. };
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Render pipeline to produce ssao effect
  53108. */
  53109. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53110. /**
  53111. * @ignore
  53112. * The PassPostProcess id in the pipeline that contains the original scene color
  53113. */
  53114. SSAOOriginalSceneColorEffect: string;
  53115. /**
  53116. * @ignore
  53117. * The SSAO PostProcess id in the pipeline
  53118. */
  53119. SSAORenderEffect: string;
  53120. /**
  53121. * @ignore
  53122. * The horizontal blur PostProcess id in the pipeline
  53123. */
  53124. SSAOBlurHRenderEffect: string;
  53125. /**
  53126. * @ignore
  53127. * The vertical blur PostProcess id in the pipeline
  53128. */
  53129. SSAOBlurVRenderEffect: string;
  53130. /**
  53131. * @ignore
  53132. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53133. */
  53134. SSAOCombineRenderEffect: string;
  53135. /**
  53136. * The output strength of the SSAO post-process. Default value is 1.0.
  53137. */
  53138. totalStrength: number;
  53139. /**
  53140. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53141. */
  53142. maxZ: number;
  53143. /**
  53144. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53145. */
  53146. minZAspect: number;
  53147. private _samples;
  53148. /**
  53149. * Number of samples used for the SSAO calculations. Default value is 8
  53150. */
  53151. samples: number;
  53152. private _textureSamples;
  53153. /**
  53154. * Number of samples to use for antialiasing
  53155. */
  53156. textureSamples: number;
  53157. /**
  53158. * Ratio object used for SSAO ratio and blur ratio
  53159. */
  53160. private _ratio;
  53161. /**
  53162. * Dynamically generated sphere sampler.
  53163. */
  53164. private _sampleSphere;
  53165. /**
  53166. * Blur filter offsets
  53167. */
  53168. private _samplerOffsets;
  53169. private _expensiveBlur;
  53170. /**
  53171. * If bilateral blur should be used
  53172. */
  53173. expensiveBlur: boolean;
  53174. /**
  53175. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53176. */
  53177. radius: number;
  53178. /**
  53179. * The base color of the SSAO post-process
  53180. * The final result is "base + ssao" between [0, 1]
  53181. */
  53182. base: number;
  53183. /**
  53184. * Support test.
  53185. */
  53186. static readonly IsSupported: boolean;
  53187. private _scene;
  53188. private _depthTexture;
  53189. private _normalTexture;
  53190. private _randomTexture;
  53191. private _originalColorPostProcess;
  53192. private _ssaoPostProcess;
  53193. private _blurHPostProcess;
  53194. private _blurVPostProcess;
  53195. private _ssaoCombinePostProcess;
  53196. private _firstUpdate;
  53197. /**
  53198. * Gets active scene
  53199. */
  53200. readonly scene: Scene;
  53201. /**
  53202. * @constructor
  53203. * @param name The rendering pipeline name
  53204. * @param scene The scene linked to this pipeline
  53205. * @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 }
  53206. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53207. */
  53208. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53209. /**
  53210. * Get the class name
  53211. * @returns "SSAO2RenderingPipeline"
  53212. */
  53213. getClassName(): string;
  53214. /**
  53215. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53216. */
  53217. dispose(disableGeometryBufferRenderer?: boolean): void;
  53218. private _createBlurPostProcess;
  53219. /** @hidden */ rebuild(): void;
  53220. private _bits;
  53221. private _radicalInverse_VdC;
  53222. private _hammersley;
  53223. private _hemisphereSample_uniform;
  53224. private _generateHemisphere;
  53225. private _createSSAOPostProcess;
  53226. private _createSSAOCombinePostProcess;
  53227. private _createRandomTexture;
  53228. /**
  53229. * Serialize the rendering pipeline (Used when exporting)
  53230. * @returns the serialized object
  53231. */
  53232. serialize(): any;
  53233. /**
  53234. * Parse the serialized pipeline
  53235. * @param source Source pipeline.
  53236. * @param scene The scene to load the pipeline to.
  53237. * @param rootUrl The URL of the serialized pipeline.
  53238. * @returns An instantiated pipeline from the serialized object.
  53239. */
  53240. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53241. }
  53242. }
  53243. declare module BABYLON {
  53244. /** @hidden */
  53245. export var ssaoPixelShader: {
  53246. name: string;
  53247. shader: string;
  53248. };
  53249. }
  53250. declare module BABYLON {
  53251. /**
  53252. * Render pipeline to produce ssao effect
  53253. */
  53254. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53255. /**
  53256. * @ignore
  53257. * The PassPostProcess id in the pipeline that contains the original scene color
  53258. */
  53259. SSAOOriginalSceneColorEffect: string;
  53260. /**
  53261. * @ignore
  53262. * The SSAO PostProcess id in the pipeline
  53263. */
  53264. SSAORenderEffect: string;
  53265. /**
  53266. * @ignore
  53267. * The horizontal blur PostProcess id in the pipeline
  53268. */
  53269. SSAOBlurHRenderEffect: string;
  53270. /**
  53271. * @ignore
  53272. * The vertical blur PostProcess id in the pipeline
  53273. */
  53274. SSAOBlurVRenderEffect: string;
  53275. /**
  53276. * @ignore
  53277. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53278. */
  53279. SSAOCombineRenderEffect: string;
  53280. /**
  53281. * The output strength of the SSAO post-process. Default value is 1.0.
  53282. */
  53283. totalStrength: number;
  53284. /**
  53285. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53286. */
  53287. radius: number;
  53288. /**
  53289. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53290. * Must not be equal to fallOff and superior to fallOff.
  53291. * Default value is 0.0075
  53292. */
  53293. area: number;
  53294. /**
  53295. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53296. * Must not be equal to area and inferior to area.
  53297. * Default value is 0.000001
  53298. */
  53299. fallOff: number;
  53300. /**
  53301. * The base color of the SSAO post-process
  53302. * The final result is "base + ssao" between [0, 1]
  53303. */
  53304. base: number;
  53305. private _scene;
  53306. private _depthTexture;
  53307. private _randomTexture;
  53308. private _originalColorPostProcess;
  53309. private _ssaoPostProcess;
  53310. private _blurHPostProcess;
  53311. private _blurVPostProcess;
  53312. private _ssaoCombinePostProcess;
  53313. private _firstUpdate;
  53314. /**
  53315. * Gets active scene
  53316. */
  53317. readonly scene: Scene;
  53318. /**
  53319. * @constructor
  53320. * @param name - The rendering pipeline name
  53321. * @param scene - The scene linked to this pipeline
  53322. * @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 }
  53323. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53324. */
  53325. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53326. /**
  53327. * Get the class name
  53328. * @returns "SSAORenderingPipeline"
  53329. */
  53330. getClassName(): string;
  53331. /**
  53332. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53333. */
  53334. dispose(disableDepthRender?: boolean): void;
  53335. private _createBlurPostProcess;
  53336. /** @hidden */ rebuild(): void;
  53337. private _createSSAOPostProcess;
  53338. private _createSSAOCombinePostProcess;
  53339. private _createRandomTexture;
  53340. }
  53341. }
  53342. declare module BABYLON {
  53343. /** @hidden */
  53344. export var standardPixelShader: {
  53345. name: string;
  53346. shader: string;
  53347. };
  53348. }
  53349. declare module BABYLON {
  53350. /**
  53351. * Standard rendering pipeline
  53352. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53353. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53354. */
  53355. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53356. /**
  53357. * Public members
  53358. */
  53359. /**
  53360. * Post-process which contains the original scene color before the pipeline applies all the effects
  53361. */
  53362. originalPostProcess: Nullable<PostProcess>;
  53363. /**
  53364. * Post-process used to down scale an image x4
  53365. */
  53366. downSampleX4PostProcess: Nullable<PostProcess>;
  53367. /**
  53368. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53369. */
  53370. brightPassPostProcess: Nullable<PostProcess>;
  53371. /**
  53372. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53373. */
  53374. blurHPostProcesses: PostProcess[];
  53375. /**
  53376. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53377. */
  53378. blurVPostProcesses: PostProcess[];
  53379. /**
  53380. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53381. */
  53382. textureAdderPostProcess: Nullable<PostProcess>;
  53383. /**
  53384. * Post-process used to create volumetric lighting effect
  53385. */
  53386. volumetricLightPostProcess: Nullable<PostProcess>;
  53387. /**
  53388. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53389. */
  53390. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53391. /**
  53392. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53393. */
  53394. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53395. /**
  53396. * Post-process used to merge the volumetric light effect and the real scene color
  53397. */
  53398. volumetricLightMergePostProces: Nullable<PostProcess>;
  53399. /**
  53400. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53401. */
  53402. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53403. /**
  53404. * Base post-process used to calculate the average luminance of the final image for HDR
  53405. */
  53406. luminancePostProcess: Nullable<PostProcess>;
  53407. /**
  53408. * Post-processes used to create down sample post-processes in order to get
  53409. * the average luminance of the final image for HDR
  53410. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53411. */
  53412. luminanceDownSamplePostProcesses: PostProcess[];
  53413. /**
  53414. * Post-process used to create a HDR effect (light adaptation)
  53415. */
  53416. hdrPostProcess: Nullable<PostProcess>;
  53417. /**
  53418. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53419. */
  53420. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53421. /**
  53422. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53423. */
  53424. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53425. /**
  53426. * Post-process used to merge the final HDR post-process and the real scene color
  53427. */
  53428. hdrFinalPostProcess: Nullable<PostProcess>;
  53429. /**
  53430. * Post-process used to create a lens flare effect
  53431. */
  53432. lensFlarePostProcess: Nullable<PostProcess>;
  53433. /**
  53434. * Post-process that merges the result of the lens flare post-process and the real scene color
  53435. */
  53436. lensFlareComposePostProcess: Nullable<PostProcess>;
  53437. /**
  53438. * Post-process used to create a motion blur effect
  53439. */
  53440. motionBlurPostProcess: Nullable<PostProcess>;
  53441. /**
  53442. * Post-process used to create a depth of field effect
  53443. */
  53444. depthOfFieldPostProcess: Nullable<PostProcess>;
  53445. /**
  53446. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53447. */
  53448. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53449. /**
  53450. * Represents the brightness threshold in order to configure the illuminated surfaces
  53451. */
  53452. brightThreshold: number;
  53453. /**
  53454. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53455. */
  53456. blurWidth: number;
  53457. /**
  53458. * Sets if the blur for highlighted surfaces must be only horizontal
  53459. */
  53460. horizontalBlur: boolean;
  53461. /**
  53462. * Gets the overall exposure used by the pipeline
  53463. */
  53464. /**
  53465. * Sets the overall exposure used by the pipeline
  53466. */
  53467. exposure: number;
  53468. /**
  53469. * Texture used typically to simulate "dirty" on camera lens
  53470. */
  53471. lensTexture: Nullable<Texture>;
  53472. /**
  53473. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53474. */
  53475. volumetricLightCoefficient: number;
  53476. /**
  53477. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53478. */
  53479. volumetricLightPower: number;
  53480. /**
  53481. * Used the set the blur intensity to smooth the volumetric lights
  53482. */
  53483. volumetricLightBlurScale: number;
  53484. /**
  53485. * Light (spot or directional) used to generate the volumetric lights rays
  53486. * The source light must have a shadow generate so the pipeline can get its
  53487. * depth map
  53488. */
  53489. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53490. /**
  53491. * For eye adaptation, represents the minimum luminance the eye can see
  53492. */
  53493. hdrMinimumLuminance: number;
  53494. /**
  53495. * For eye adaptation, represents the decrease luminance speed
  53496. */
  53497. hdrDecreaseRate: number;
  53498. /**
  53499. * For eye adaptation, represents the increase luminance speed
  53500. */
  53501. hdrIncreaseRate: number;
  53502. /**
  53503. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53504. */
  53505. /**
  53506. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53507. */
  53508. hdrAutoExposure: boolean;
  53509. /**
  53510. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53511. */
  53512. lensColorTexture: Nullable<Texture>;
  53513. /**
  53514. * The overall strengh for the lens flare effect
  53515. */
  53516. lensFlareStrength: number;
  53517. /**
  53518. * Dispersion coefficient for lens flare ghosts
  53519. */
  53520. lensFlareGhostDispersal: number;
  53521. /**
  53522. * Main lens flare halo width
  53523. */
  53524. lensFlareHaloWidth: number;
  53525. /**
  53526. * Based on the lens distortion effect, defines how much the lens flare result
  53527. * is distorted
  53528. */
  53529. lensFlareDistortionStrength: number;
  53530. /**
  53531. * Lens star texture must be used to simulate rays on the flares and is available
  53532. * in the documentation
  53533. */
  53534. lensStarTexture: Nullable<Texture>;
  53535. /**
  53536. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53537. * flare effect by taking account of the dirt texture
  53538. */
  53539. lensFlareDirtTexture: Nullable<Texture>;
  53540. /**
  53541. * Represents the focal length for the depth of field effect
  53542. */
  53543. depthOfFieldDistance: number;
  53544. /**
  53545. * Represents the blur intensity for the blurred part of the depth of field effect
  53546. */
  53547. depthOfFieldBlurWidth: number;
  53548. /**
  53549. * For motion blur, defines how much the image is blurred by the movement
  53550. */
  53551. motionStrength: number;
  53552. /**
  53553. * List of animations for the pipeline (IAnimatable implementation)
  53554. */
  53555. animations: Animation[];
  53556. /**
  53557. * Private members
  53558. */
  53559. private _scene;
  53560. private _currentDepthOfFieldSource;
  53561. private _basePostProcess;
  53562. private _fixedExposure;
  53563. private _currentExposure;
  53564. private _hdrAutoExposure;
  53565. private _hdrCurrentLuminance;
  53566. private _floatTextureType;
  53567. private _ratio;
  53568. private _bloomEnabled;
  53569. private _depthOfFieldEnabled;
  53570. private _vlsEnabled;
  53571. private _lensFlareEnabled;
  53572. private _hdrEnabled;
  53573. private _motionBlurEnabled;
  53574. private _fxaaEnabled;
  53575. private _motionBlurSamples;
  53576. private _volumetricLightStepsCount;
  53577. private _samples;
  53578. /**
  53579. * @ignore
  53580. * Specifies if the bloom pipeline is enabled
  53581. */
  53582. BloomEnabled: boolean;
  53583. /**
  53584. * @ignore
  53585. * Specifies if the depth of field pipeline is enabed
  53586. */
  53587. DepthOfFieldEnabled: boolean;
  53588. /**
  53589. * @ignore
  53590. * Specifies if the lens flare pipeline is enabed
  53591. */
  53592. LensFlareEnabled: boolean;
  53593. /**
  53594. * @ignore
  53595. * Specifies if the HDR pipeline is enabled
  53596. */
  53597. HDREnabled: boolean;
  53598. /**
  53599. * @ignore
  53600. * Specifies if the volumetric lights scattering effect is enabled
  53601. */
  53602. VLSEnabled: boolean;
  53603. /**
  53604. * @ignore
  53605. * Specifies if the motion blur effect is enabled
  53606. */
  53607. MotionBlurEnabled: boolean;
  53608. /**
  53609. * Specifies if anti-aliasing is enabled
  53610. */
  53611. fxaaEnabled: boolean;
  53612. /**
  53613. * Specifies the number of steps used to calculate the volumetric lights
  53614. * Typically in interval [50, 200]
  53615. */
  53616. volumetricLightStepsCount: number;
  53617. /**
  53618. * Specifies the number of samples used for the motion blur effect
  53619. * Typically in interval [16, 64]
  53620. */
  53621. motionBlurSamples: number;
  53622. /**
  53623. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53624. */
  53625. samples: number;
  53626. /**
  53627. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53628. * @constructor
  53629. * @param name The rendering pipeline name
  53630. * @param scene The scene linked to this pipeline
  53631. * @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)
  53632. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53633. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53634. */
  53635. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53636. private _buildPipeline;
  53637. private _createDownSampleX4PostProcess;
  53638. private _createBrightPassPostProcess;
  53639. private _createBlurPostProcesses;
  53640. private _createTextureAdderPostProcess;
  53641. private _createVolumetricLightPostProcess;
  53642. private _createLuminancePostProcesses;
  53643. private _createHdrPostProcess;
  53644. private _createLensFlarePostProcess;
  53645. private _createDepthOfFieldPostProcess;
  53646. private _createMotionBlurPostProcess;
  53647. private _getDepthTexture;
  53648. private _disposePostProcesses;
  53649. /**
  53650. * Dispose of the pipeline and stop all post processes
  53651. */
  53652. dispose(): void;
  53653. /**
  53654. * Serialize the rendering pipeline (Used when exporting)
  53655. * @returns the serialized object
  53656. */
  53657. serialize(): any;
  53658. /**
  53659. * Parse the serialized pipeline
  53660. * @param source Source pipeline.
  53661. * @param scene The scene to load the pipeline to.
  53662. * @param rootUrl The URL of the serialized pipeline.
  53663. * @returns An instantiated pipeline from the serialized object.
  53664. */
  53665. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53666. /**
  53667. * Luminance steps
  53668. */
  53669. static LuminanceSteps: number;
  53670. }
  53671. }
  53672. declare module BABYLON {
  53673. /** @hidden */
  53674. export var tonemapPixelShader: {
  53675. name: string;
  53676. shader: string;
  53677. };
  53678. }
  53679. declare module BABYLON {
  53680. /** Defines operator used for tonemapping */
  53681. export enum TonemappingOperator {
  53682. /** Hable */
  53683. Hable = 0,
  53684. /** Reinhard */
  53685. Reinhard = 1,
  53686. /** HejiDawson */
  53687. HejiDawson = 2,
  53688. /** Photographic */
  53689. Photographic = 3
  53690. }
  53691. /**
  53692. * Defines a post process to apply tone mapping
  53693. */
  53694. export class TonemapPostProcess extends PostProcess {
  53695. private _operator;
  53696. /** Defines the required exposure adjustement */
  53697. exposureAdjustment: number;
  53698. /**
  53699. * Creates a new TonemapPostProcess
  53700. * @param name defines the name of the postprocess
  53701. * @param _operator defines the operator to use
  53702. * @param exposureAdjustment defines the required exposure adjustement
  53703. * @param camera defines the camera to use (can be null)
  53704. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53705. * @param engine defines the hosting engine (can be ignore if camera is set)
  53706. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53707. */
  53708. constructor(name: string, _operator: TonemappingOperator,
  53709. /** Defines the required exposure adjustement */
  53710. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53711. }
  53712. }
  53713. declare module BABYLON {
  53714. /** @hidden */
  53715. export var depthVertexShader: {
  53716. name: string;
  53717. shader: string;
  53718. };
  53719. }
  53720. declare module BABYLON {
  53721. /** @hidden */
  53722. export var volumetricLightScatteringPixelShader: {
  53723. name: string;
  53724. shader: string;
  53725. };
  53726. }
  53727. declare module BABYLON {
  53728. /** @hidden */
  53729. export var volumetricLightScatteringPassPixelShader: {
  53730. name: string;
  53731. shader: string;
  53732. };
  53733. }
  53734. declare module BABYLON {
  53735. /**
  53736. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53737. */
  53738. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53739. private _volumetricLightScatteringPass;
  53740. private _volumetricLightScatteringRTT;
  53741. private _viewPort;
  53742. private _screenCoordinates;
  53743. private _cachedDefines;
  53744. /**
  53745. * If not undefined, the mesh position is computed from the attached node position
  53746. */
  53747. attachedNode: {
  53748. position: Vector3;
  53749. };
  53750. /**
  53751. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53752. */
  53753. customMeshPosition: Vector3;
  53754. /**
  53755. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53756. */
  53757. useCustomMeshPosition: boolean;
  53758. /**
  53759. * If the post-process should inverse the light scattering direction
  53760. */
  53761. invert: boolean;
  53762. /**
  53763. * The internal mesh used by the post-process
  53764. */
  53765. mesh: Mesh;
  53766. /**
  53767. * @hidden
  53768. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53769. */
  53770. useDiffuseColor: boolean;
  53771. /**
  53772. * Array containing the excluded meshes not rendered in the internal pass
  53773. */
  53774. excludedMeshes: AbstractMesh[];
  53775. /**
  53776. * Controls the overall intensity of the post-process
  53777. */
  53778. exposure: number;
  53779. /**
  53780. * Dissipates each sample's contribution in range [0, 1]
  53781. */
  53782. decay: number;
  53783. /**
  53784. * Controls the overall intensity of each sample
  53785. */
  53786. weight: number;
  53787. /**
  53788. * Controls the density of each sample
  53789. */
  53790. density: number;
  53791. /**
  53792. * @constructor
  53793. * @param name The post-process name
  53794. * @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)
  53795. * @param camera The camera that the post-process will be attached to
  53796. * @param mesh The mesh used to create the light scattering
  53797. * @param samples The post-process quality, default 100
  53798. * @param samplingModeThe post-process filtering mode
  53799. * @param engine The babylon engine
  53800. * @param reusable If the post-process is reusable
  53801. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53802. */
  53803. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53804. /**
  53805. * Returns the string "VolumetricLightScatteringPostProcess"
  53806. * @returns "VolumetricLightScatteringPostProcess"
  53807. */
  53808. getClassName(): string;
  53809. private _isReady;
  53810. /**
  53811. * Sets the new light position for light scattering effect
  53812. * @param position The new custom light position
  53813. */
  53814. setCustomMeshPosition(position: Vector3): void;
  53815. /**
  53816. * Returns the light position for light scattering effect
  53817. * @return Vector3 The custom light position
  53818. */
  53819. getCustomMeshPosition(): Vector3;
  53820. /**
  53821. * Disposes the internal assets and detaches the post-process from the camera
  53822. */
  53823. dispose(camera: Camera): void;
  53824. /**
  53825. * Returns the render target texture used by the post-process
  53826. * @return the render target texture used by the post-process
  53827. */
  53828. getPass(): RenderTargetTexture;
  53829. private _meshExcluded;
  53830. private _createPass;
  53831. private _updateMeshScreenCoordinates;
  53832. /**
  53833. * Creates a default mesh for the Volumeric Light Scattering post-process
  53834. * @param name The mesh name
  53835. * @param scene The scene where to create the mesh
  53836. * @return the default mesh
  53837. */
  53838. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53839. }
  53840. }
  53841. declare module BABYLON {
  53842. interface Scene {
  53843. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53844. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53845. /**
  53846. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53847. */
  53848. forceShowBoundingBoxes: boolean;
  53849. /**
  53850. * Gets the bounding box renderer associated with the scene
  53851. * @returns a BoundingBoxRenderer
  53852. */
  53853. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53854. }
  53855. interface AbstractMesh {
  53856. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53857. /**
  53858. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53859. */
  53860. showBoundingBox: boolean;
  53861. }
  53862. /**
  53863. * Component responsible of rendering the bounding box of the meshes in a scene.
  53864. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53865. */
  53866. export class BoundingBoxRenderer implements ISceneComponent {
  53867. /**
  53868. * The component name helpfull to identify the component in the list of scene components.
  53869. */
  53870. readonly name: string;
  53871. /**
  53872. * The scene the component belongs to.
  53873. */
  53874. scene: Scene;
  53875. /**
  53876. * Color of the bounding box lines placed in front of an object
  53877. */
  53878. frontColor: Color3;
  53879. /**
  53880. * Color of the bounding box lines placed behind an object
  53881. */
  53882. backColor: Color3;
  53883. /**
  53884. * Defines if the renderer should show the back lines or not
  53885. */
  53886. showBackLines: boolean;
  53887. /**
  53888. * @hidden
  53889. */
  53890. renderList: SmartArray<BoundingBox>;
  53891. private _colorShader;
  53892. private _vertexBuffers;
  53893. private _indexBuffer;
  53894. /**
  53895. * Instantiates a new bounding box renderer in a scene.
  53896. * @param scene the scene the renderer renders in
  53897. */
  53898. constructor(scene: Scene);
  53899. /**
  53900. * Registers the component in a given scene
  53901. */
  53902. register(): void;
  53903. private _evaluateSubMesh;
  53904. private _activeMesh;
  53905. private _prepareRessources;
  53906. private _createIndexBuffer;
  53907. /**
  53908. * Rebuilds the elements related to this component in case of
  53909. * context lost for instance.
  53910. */
  53911. rebuild(): void;
  53912. /**
  53913. * @hidden
  53914. */
  53915. reset(): void;
  53916. /**
  53917. * Render the bounding boxes of a specific rendering group
  53918. * @param renderingGroupId defines the rendering group to render
  53919. */
  53920. render(renderingGroupId: number): void;
  53921. /**
  53922. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53923. * @param mesh Define the mesh to render the occlusion bounding box for
  53924. */
  53925. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53926. /**
  53927. * Dispose and release the resources attached to this renderer.
  53928. */
  53929. dispose(): void;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /** @hidden */
  53934. export var depthPixelShader: {
  53935. name: string;
  53936. shader: string;
  53937. };
  53938. }
  53939. declare module BABYLON {
  53940. /**
  53941. * This represents a depth renderer in Babylon.
  53942. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53943. */
  53944. export class DepthRenderer {
  53945. private _scene;
  53946. private _depthMap;
  53947. private _effect;
  53948. private _cachedDefines;
  53949. private _camera;
  53950. /**
  53951. * Specifiess that the depth renderer will only be used within
  53952. * the camera it is created for.
  53953. * This can help forcing its rendering during the camera processing.
  53954. */
  53955. useOnlyInActiveCamera: boolean;
  53956. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53957. /**
  53958. * Instantiates a depth renderer
  53959. * @param scene The scene the renderer belongs to
  53960. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53961. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53962. */
  53963. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53964. /**
  53965. * Creates the depth rendering effect and checks if the effect is ready.
  53966. * @param subMesh The submesh to be used to render the depth map of
  53967. * @param useInstances If multiple world instances should be used
  53968. * @returns if the depth renderer is ready to render the depth map
  53969. */
  53970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53971. /**
  53972. * Gets the texture which the depth map will be written to.
  53973. * @returns The depth map texture
  53974. */
  53975. getDepthMap(): RenderTargetTexture;
  53976. /**
  53977. * Disposes of the depth renderer.
  53978. */
  53979. dispose(): void;
  53980. }
  53981. }
  53982. declare module BABYLON {
  53983. interface Scene {
  53984. /** @hidden (Backing field) */ depthRenderer: {
  53985. [id: string]: DepthRenderer;
  53986. };
  53987. /**
  53988. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53989. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53990. * @returns the created depth renderer
  53991. */
  53992. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53993. /**
  53994. * Disables a depth renderer for a given camera
  53995. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53996. */
  53997. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53998. }
  53999. /**
  54000. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54001. * in several rendering techniques.
  54002. */
  54003. export class DepthRendererSceneComponent implements ISceneComponent {
  54004. /**
  54005. * The component name helpfull to identify the component in the list of scene components.
  54006. */
  54007. readonly name: string;
  54008. /**
  54009. * The scene the component belongs to.
  54010. */
  54011. scene: Scene;
  54012. /**
  54013. * Creates a new instance of the component for the given scene
  54014. * @param scene Defines the scene to register the component in
  54015. */
  54016. constructor(scene: Scene);
  54017. /**
  54018. * Registers the component in a given scene
  54019. */
  54020. register(): void;
  54021. /**
  54022. * Rebuilds the elements related to this component in case of
  54023. * context lost for instance.
  54024. */
  54025. rebuild(): void;
  54026. /**
  54027. * Disposes the component and the associated ressources
  54028. */
  54029. dispose(): void;
  54030. private _gatherRenderTargets;
  54031. private _gatherActiveCameraRenderTargets;
  54032. }
  54033. }
  54034. declare module BABYLON {
  54035. /** @hidden */
  54036. export var outlinePixelShader: {
  54037. name: string;
  54038. shader: string;
  54039. };
  54040. }
  54041. declare module BABYLON {
  54042. /** @hidden */
  54043. export var outlineVertexShader: {
  54044. name: string;
  54045. shader: string;
  54046. };
  54047. }
  54048. declare module BABYLON {
  54049. interface Scene {
  54050. /** @hidden */ outlineRenderer: OutlineRenderer;
  54051. /**
  54052. * Gets the outline renderer associated with the scene
  54053. * @returns a OutlineRenderer
  54054. */
  54055. getOutlineRenderer(): OutlineRenderer;
  54056. }
  54057. interface AbstractMesh {
  54058. /** @hidden (Backing field) */ renderOutline: boolean;
  54059. /**
  54060. * Gets or sets a boolean indicating if the outline must be rendered as well
  54061. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54062. */
  54063. renderOutline: boolean;
  54064. /** @hidden (Backing field) */ renderOverlay: boolean;
  54065. /**
  54066. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54067. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54068. */
  54069. renderOverlay: boolean;
  54070. }
  54071. /**
  54072. * This class is responsible to draw bothe outline/overlay of meshes.
  54073. * It should not be used directly but through the available method on mesh.
  54074. */
  54075. export class OutlineRenderer implements ISceneComponent {
  54076. /**
  54077. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54078. */
  54079. private static _StencilReference;
  54080. /**
  54081. * The name of the component. Each component must have a unique name.
  54082. */
  54083. name: string;
  54084. /**
  54085. * The scene the component belongs to.
  54086. */
  54087. scene: Scene;
  54088. /**
  54089. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54090. */
  54091. zOffset: number;
  54092. private _engine;
  54093. private _effect;
  54094. private _cachedDefines;
  54095. private _savedDepthWrite;
  54096. /**
  54097. * Instantiates a new outline renderer. (There could be only one per scene).
  54098. * @param scene Defines the scene it belongs to
  54099. */
  54100. constructor(scene: Scene);
  54101. /**
  54102. * Register the component to one instance of a scene.
  54103. */
  54104. register(): void;
  54105. /**
  54106. * Rebuilds the elements related to this component in case of
  54107. * context lost for instance.
  54108. */
  54109. rebuild(): void;
  54110. /**
  54111. * Disposes the component and the associated ressources.
  54112. */
  54113. dispose(): void;
  54114. /**
  54115. * Renders the outline in the canvas.
  54116. * @param subMesh Defines the sumesh to render
  54117. * @param batch Defines the batch of meshes in case of instances
  54118. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54119. */
  54120. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54121. /**
  54122. * Returns whether or not the outline renderer is ready for a given submesh.
  54123. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54124. * @param subMesh Defines the submesh to check readyness for
  54125. * @param useInstances Defines wheter wee are trying to render instances or not
  54126. * @returns true if ready otherwise false
  54127. */
  54128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54129. private _beforeRenderingMesh;
  54130. private _afterRenderingMesh;
  54131. }
  54132. }
  54133. declare module BABYLON {
  54134. /**
  54135. * Defines the list of states available for a task inside a AssetsManager
  54136. */
  54137. export enum AssetTaskState {
  54138. /**
  54139. * Initialization
  54140. */
  54141. INIT = 0,
  54142. /**
  54143. * Running
  54144. */
  54145. RUNNING = 1,
  54146. /**
  54147. * Done
  54148. */
  54149. DONE = 2,
  54150. /**
  54151. * Error
  54152. */
  54153. ERROR = 3
  54154. }
  54155. /**
  54156. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54157. */
  54158. export abstract class AbstractAssetTask {
  54159. /**
  54160. * Task name
  54161. */ name: string;
  54162. /**
  54163. * Callback called when the task is successful
  54164. */
  54165. onSuccess: (task: any) => void;
  54166. /**
  54167. * Callback called when the task is not successful
  54168. */
  54169. onError: (task: any, message?: string, exception?: any) => void;
  54170. /**
  54171. * Creates a new AssetsManager
  54172. * @param name defines the name of the task
  54173. */
  54174. constructor(
  54175. /**
  54176. * Task name
  54177. */ name: string);
  54178. private _isCompleted;
  54179. private _taskState;
  54180. private _errorObject;
  54181. /**
  54182. * Get if the task is completed
  54183. */
  54184. readonly isCompleted: boolean;
  54185. /**
  54186. * Gets the current state of the task
  54187. */
  54188. readonly taskState: AssetTaskState;
  54189. /**
  54190. * Gets the current error object (if task is in error)
  54191. */
  54192. readonly errorObject: {
  54193. message?: string;
  54194. exception?: any;
  54195. };
  54196. /**
  54197. * Internal only
  54198. * @hidden
  54199. */ setErrorObject(message?: string, exception?: any): void;
  54200. /**
  54201. * Execute the current task
  54202. * @param scene defines the scene where you want your assets to be loaded
  54203. * @param onSuccess is a callback called when the task is successfully executed
  54204. * @param onError is a callback called if an error occurs
  54205. */
  54206. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54207. /**
  54208. * Execute the current task
  54209. * @param scene defines the scene where you want your assets to be loaded
  54210. * @param onSuccess is a callback called when the task is successfully executed
  54211. * @param onError is a callback called if an error occurs
  54212. */
  54213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54214. /**
  54215. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54216. * This can be used with failed tasks that have the reason for failure fixed.
  54217. */
  54218. reset(): void;
  54219. private onErrorCallback;
  54220. private onDoneCallback;
  54221. }
  54222. /**
  54223. * Define the interface used by progress events raised during assets loading
  54224. */
  54225. export interface IAssetsProgressEvent {
  54226. /**
  54227. * Defines the number of remaining tasks to process
  54228. */
  54229. remainingCount: number;
  54230. /**
  54231. * Defines the total number of tasks
  54232. */
  54233. totalCount: number;
  54234. /**
  54235. * Defines the task that was just processed
  54236. */
  54237. task: AbstractAssetTask;
  54238. }
  54239. /**
  54240. * Class used to share progress information about assets loading
  54241. */
  54242. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54243. /**
  54244. * Defines the number of remaining tasks to process
  54245. */
  54246. remainingCount: number;
  54247. /**
  54248. * Defines the total number of tasks
  54249. */
  54250. totalCount: number;
  54251. /**
  54252. * Defines the task that was just processed
  54253. */
  54254. task: AbstractAssetTask;
  54255. /**
  54256. * Creates a AssetsProgressEvent
  54257. * @param remainingCount defines the number of remaining tasks to process
  54258. * @param totalCount defines the total number of tasks
  54259. * @param task defines the task that was just processed
  54260. */
  54261. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54262. }
  54263. /**
  54264. * Define a task used by AssetsManager to load meshes
  54265. */
  54266. export class MeshAssetTask extends AbstractAssetTask {
  54267. /**
  54268. * Defines the name of the task
  54269. */
  54270. name: string;
  54271. /**
  54272. * Defines the list of mesh's names you want to load
  54273. */
  54274. meshesNames: any;
  54275. /**
  54276. * Defines the root url to use as a base to load your meshes and associated resources
  54277. */
  54278. rootUrl: string;
  54279. /**
  54280. * Defines the filename of the scene to load from
  54281. */
  54282. sceneFilename: string;
  54283. /**
  54284. * Gets the list of loaded meshes
  54285. */
  54286. loadedMeshes: Array<AbstractMesh>;
  54287. /**
  54288. * Gets the list of loaded particle systems
  54289. */
  54290. loadedParticleSystems: Array<IParticleSystem>;
  54291. /**
  54292. * Gets the list of loaded skeletons
  54293. */
  54294. loadedSkeletons: Array<Skeleton>;
  54295. /**
  54296. * Gets the list of loaded animation groups
  54297. */
  54298. loadedAnimationGroups: Array<AnimationGroup>;
  54299. /**
  54300. * Callback called when the task is successful
  54301. */
  54302. onSuccess: (task: MeshAssetTask) => void;
  54303. /**
  54304. * Callback called when the task is successful
  54305. */
  54306. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54307. /**
  54308. * Creates a new MeshAssetTask
  54309. * @param name defines the name of the task
  54310. * @param meshesNames defines the list of mesh's names you want to load
  54311. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54312. * @param sceneFilename defines the filename of the scene to load from
  54313. */
  54314. constructor(
  54315. /**
  54316. * Defines the name of the task
  54317. */
  54318. name: string,
  54319. /**
  54320. * Defines the list of mesh's names you want to load
  54321. */
  54322. meshesNames: any,
  54323. /**
  54324. * Defines the root url to use as a base to load your meshes and associated resources
  54325. */
  54326. rootUrl: string,
  54327. /**
  54328. * Defines the filename of the scene to load from
  54329. */
  54330. sceneFilename: string);
  54331. /**
  54332. * Execute the current task
  54333. * @param scene defines the scene where you want your assets to be loaded
  54334. * @param onSuccess is a callback called when the task is successfully executed
  54335. * @param onError is a callback called if an error occurs
  54336. */
  54337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54338. }
  54339. /**
  54340. * Define a task used by AssetsManager to load text content
  54341. */
  54342. export class TextFileAssetTask extends AbstractAssetTask {
  54343. /**
  54344. * Defines the name of the task
  54345. */
  54346. name: string;
  54347. /**
  54348. * Defines the location of the file to load
  54349. */
  54350. url: string;
  54351. /**
  54352. * Gets the loaded text string
  54353. */
  54354. text: string;
  54355. /**
  54356. * Callback called when the task is successful
  54357. */
  54358. onSuccess: (task: TextFileAssetTask) => void;
  54359. /**
  54360. * Callback called when the task is successful
  54361. */
  54362. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54363. /**
  54364. * Creates a new TextFileAssetTask object
  54365. * @param name defines the name of the task
  54366. * @param url defines the location of the file to load
  54367. */
  54368. constructor(
  54369. /**
  54370. * Defines the name of the task
  54371. */
  54372. name: string,
  54373. /**
  54374. * Defines the location of the file to load
  54375. */
  54376. url: string);
  54377. /**
  54378. * Execute the current task
  54379. * @param scene defines the scene where you want your assets to be loaded
  54380. * @param onSuccess is a callback called when the task is successfully executed
  54381. * @param onError is a callback called if an error occurs
  54382. */
  54383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54384. }
  54385. /**
  54386. * Define a task used by AssetsManager to load binary data
  54387. */
  54388. export class BinaryFileAssetTask extends AbstractAssetTask {
  54389. /**
  54390. * Defines the name of the task
  54391. */
  54392. name: string;
  54393. /**
  54394. * Defines the location of the file to load
  54395. */
  54396. url: string;
  54397. /**
  54398. * Gets the lodaded data (as an array buffer)
  54399. */
  54400. data: ArrayBuffer;
  54401. /**
  54402. * Callback called when the task is successful
  54403. */
  54404. onSuccess: (task: BinaryFileAssetTask) => void;
  54405. /**
  54406. * Callback called when the task is successful
  54407. */
  54408. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54409. /**
  54410. * Creates a new BinaryFileAssetTask object
  54411. * @param name defines the name of the new task
  54412. * @param url defines the location of the file to load
  54413. */
  54414. constructor(
  54415. /**
  54416. * Defines the name of the task
  54417. */
  54418. name: string,
  54419. /**
  54420. * Defines the location of the file to load
  54421. */
  54422. url: string);
  54423. /**
  54424. * Execute the current task
  54425. * @param scene defines the scene where you want your assets to be loaded
  54426. * @param onSuccess is a callback called when the task is successfully executed
  54427. * @param onError is a callback called if an error occurs
  54428. */
  54429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54430. }
  54431. /**
  54432. * Define a task used by AssetsManager to load images
  54433. */
  54434. export class ImageAssetTask extends AbstractAssetTask {
  54435. /**
  54436. * Defines the name of the task
  54437. */
  54438. name: string;
  54439. /**
  54440. * Defines the location of the image to load
  54441. */
  54442. url: string;
  54443. /**
  54444. * Gets the loaded images
  54445. */
  54446. image: HTMLImageElement;
  54447. /**
  54448. * Callback called when the task is successful
  54449. */
  54450. onSuccess: (task: ImageAssetTask) => void;
  54451. /**
  54452. * Callback called when the task is successful
  54453. */
  54454. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54455. /**
  54456. * Creates a new ImageAssetTask
  54457. * @param name defines the name of the task
  54458. * @param url defines the location of the image to load
  54459. */
  54460. constructor(
  54461. /**
  54462. * Defines the name of the task
  54463. */
  54464. name: string,
  54465. /**
  54466. * Defines the location of the image to load
  54467. */
  54468. url: string);
  54469. /**
  54470. * Execute the current task
  54471. * @param scene defines the scene where you want your assets to be loaded
  54472. * @param onSuccess is a callback called when the task is successfully executed
  54473. * @param onError is a callback called if an error occurs
  54474. */
  54475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54476. }
  54477. /**
  54478. * Defines the interface used by texture loading tasks
  54479. */
  54480. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54481. /**
  54482. * Gets the loaded texture
  54483. */
  54484. texture: TEX;
  54485. }
  54486. /**
  54487. * Define a task used by AssetsManager to load 2D textures
  54488. */
  54489. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54490. /**
  54491. * Defines the name of the task
  54492. */
  54493. name: string;
  54494. /**
  54495. * Defines the location of the file to load
  54496. */
  54497. url: string;
  54498. /**
  54499. * Defines if mipmap should not be generated (default is false)
  54500. */
  54501. noMipmap?: boolean | undefined;
  54502. /**
  54503. * Defines if texture must be inverted on Y axis (default is false)
  54504. */
  54505. invertY?: boolean | undefined;
  54506. /**
  54507. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54508. */
  54509. samplingMode: number;
  54510. /**
  54511. * Gets the loaded texture
  54512. */
  54513. texture: Texture;
  54514. /**
  54515. * Callback called when the task is successful
  54516. */
  54517. onSuccess: (task: TextureAssetTask) => void;
  54518. /**
  54519. * Callback called when the task is successful
  54520. */
  54521. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54522. /**
  54523. * Creates a new TextureAssetTask object
  54524. * @param name defines the name of the task
  54525. * @param url defines the location of the file to load
  54526. * @param noMipmap defines if mipmap should not be generated (default is false)
  54527. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54528. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54529. */
  54530. constructor(
  54531. /**
  54532. * Defines the name of the task
  54533. */
  54534. name: string,
  54535. /**
  54536. * Defines the location of the file to load
  54537. */
  54538. url: string,
  54539. /**
  54540. * Defines if mipmap should not be generated (default is false)
  54541. */
  54542. noMipmap?: boolean | undefined,
  54543. /**
  54544. * Defines if texture must be inverted on Y axis (default is false)
  54545. */
  54546. invertY?: boolean | undefined,
  54547. /**
  54548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54549. */
  54550. samplingMode?: number);
  54551. /**
  54552. * Execute the current task
  54553. * @param scene defines the scene where you want your assets to be loaded
  54554. * @param onSuccess is a callback called when the task is successfully executed
  54555. * @param onError is a callback called if an error occurs
  54556. */
  54557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54558. }
  54559. /**
  54560. * Define a task used by AssetsManager to load cube textures
  54561. */
  54562. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54563. /**
  54564. * Defines the name of the task
  54565. */
  54566. name: string;
  54567. /**
  54568. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54569. */
  54570. url: string;
  54571. /**
  54572. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54573. */
  54574. extensions?: string[] | undefined;
  54575. /**
  54576. * Defines if mipmaps should not be generated (default is false)
  54577. */
  54578. noMipmap?: boolean | undefined;
  54579. /**
  54580. * Defines the explicit list of files (undefined by default)
  54581. */
  54582. files?: string[] | undefined;
  54583. /**
  54584. * Gets the loaded texture
  54585. */
  54586. texture: CubeTexture;
  54587. /**
  54588. * Callback called when the task is successful
  54589. */
  54590. onSuccess: (task: CubeTextureAssetTask) => void;
  54591. /**
  54592. * Callback called when the task is successful
  54593. */
  54594. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54595. /**
  54596. * Creates a new CubeTextureAssetTask
  54597. * @param name defines the name of the task
  54598. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54599. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54601. * @param files defines the explicit list of files (undefined by default)
  54602. */
  54603. constructor(
  54604. /**
  54605. * Defines the name of the task
  54606. */
  54607. name: string,
  54608. /**
  54609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54610. */
  54611. url: string,
  54612. /**
  54613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54614. */
  54615. extensions?: string[] | undefined,
  54616. /**
  54617. * Defines if mipmaps should not be generated (default is false)
  54618. */
  54619. noMipmap?: boolean | undefined,
  54620. /**
  54621. * Defines the explicit list of files (undefined by default)
  54622. */
  54623. files?: string[] | undefined);
  54624. /**
  54625. * Execute the current task
  54626. * @param scene defines the scene where you want your assets to be loaded
  54627. * @param onSuccess is a callback called when the task is successfully executed
  54628. * @param onError is a callback called if an error occurs
  54629. */
  54630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54631. }
  54632. /**
  54633. * Define a task used by AssetsManager to load HDR cube textures
  54634. */
  54635. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54636. /**
  54637. * Defines the name of the task
  54638. */
  54639. name: string;
  54640. /**
  54641. * Defines the location of the file to load
  54642. */
  54643. url: string;
  54644. /**
  54645. * Defines the desired size (the more it increases the longer the generation will be)
  54646. */
  54647. size: number;
  54648. /**
  54649. * Defines if mipmaps should not be generated (default is false)
  54650. */
  54651. noMipmap: boolean;
  54652. /**
  54653. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54654. */
  54655. generateHarmonics: boolean;
  54656. /**
  54657. * 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)
  54658. */
  54659. gammaSpace: boolean;
  54660. /**
  54661. * Internal Use Only
  54662. */
  54663. reserved: boolean;
  54664. /**
  54665. * Gets the loaded texture
  54666. */
  54667. texture: HDRCubeTexture;
  54668. /**
  54669. * Callback called when the task is successful
  54670. */
  54671. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54672. /**
  54673. * Callback called when the task is successful
  54674. */
  54675. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54676. /**
  54677. * Creates a new HDRCubeTextureAssetTask object
  54678. * @param name defines the name of the task
  54679. * @param url defines the location of the file to load
  54680. * @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.
  54681. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54682. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54683. * @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)
  54684. * @param reserved Internal use only
  54685. */
  54686. constructor(
  54687. /**
  54688. * Defines the name of the task
  54689. */
  54690. name: string,
  54691. /**
  54692. * Defines the location of the file to load
  54693. */
  54694. url: string,
  54695. /**
  54696. * Defines the desired size (the more it increases the longer the generation will be)
  54697. */
  54698. size: number,
  54699. /**
  54700. * Defines if mipmaps should not be generated (default is false)
  54701. */
  54702. noMipmap?: boolean,
  54703. /**
  54704. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54705. */
  54706. generateHarmonics?: boolean,
  54707. /**
  54708. * 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)
  54709. */
  54710. gammaSpace?: boolean,
  54711. /**
  54712. * Internal Use Only
  54713. */
  54714. reserved?: boolean);
  54715. /**
  54716. * Execute the current task
  54717. * @param scene defines the scene where you want your assets to be loaded
  54718. * @param onSuccess is a callback called when the task is successfully executed
  54719. * @param onError is a callback called if an error occurs
  54720. */
  54721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54722. }
  54723. /**
  54724. * Define a task used by AssetsManager to load Equirectangular cube textures
  54725. */
  54726. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54727. /**
  54728. * Defines the name of the task
  54729. */
  54730. name: string;
  54731. /**
  54732. * Defines the location of the file to load
  54733. */
  54734. url: string;
  54735. /**
  54736. * Defines the desired size (the more it increases the longer the generation will be)
  54737. */
  54738. size: number;
  54739. /**
  54740. * Defines if mipmaps should not be generated (default is false)
  54741. */
  54742. noMipmap: boolean;
  54743. /**
  54744. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54745. * but the standard material would require them in Gamma space) (default is true)
  54746. */
  54747. gammaSpace: boolean;
  54748. /**
  54749. * Gets the loaded texture
  54750. */
  54751. texture: EquiRectangularCubeTexture;
  54752. /**
  54753. * Callback called when the task is successful
  54754. */
  54755. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54756. /**
  54757. * Callback called when the task is successful
  54758. */
  54759. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54760. /**
  54761. * Creates a new EquiRectangularCubeTextureAssetTask object
  54762. * @param name defines the name of the task
  54763. * @param url defines the location of the file to load
  54764. * @param size defines the desired size (the more it increases the longer the generation will be)
  54765. * If the size is omitted this implies you are using a preprocessed cubemap.
  54766. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54767. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54768. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54769. * (default is true)
  54770. */
  54771. constructor(
  54772. /**
  54773. * Defines the name of the task
  54774. */
  54775. name: string,
  54776. /**
  54777. * Defines the location of the file to load
  54778. */
  54779. url: string,
  54780. /**
  54781. * Defines the desired size (the more it increases the longer the generation will be)
  54782. */
  54783. size: number,
  54784. /**
  54785. * Defines if mipmaps should not be generated (default is false)
  54786. */
  54787. noMipmap?: boolean,
  54788. /**
  54789. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54790. * but the standard material would require them in Gamma space) (default is true)
  54791. */
  54792. gammaSpace?: boolean);
  54793. /**
  54794. * Execute the current task
  54795. * @param scene defines the scene where you want your assets to be loaded
  54796. * @param onSuccess is a callback called when the task is successfully executed
  54797. * @param onError is a callback called if an error occurs
  54798. */
  54799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54800. }
  54801. /**
  54802. * This class can be used to easily import assets into a scene
  54803. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54804. */
  54805. export class AssetsManager {
  54806. private _scene;
  54807. private _isLoading;
  54808. protected _tasks: AbstractAssetTask[];
  54809. protected _waitingTasksCount: number;
  54810. protected _totalTasksCount: number;
  54811. /**
  54812. * Callback called when all tasks are processed
  54813. */
  54814. onFinish: (tasks: AbstractAssetTask[]) => void;
  54815. /**
  54816. * Callback called when a task is successful
  54817. */
  54818. onTaskSuccess: (task: AbstractAssetTask) => void;
  54819. /**
  54820. * Callback called when a task had an error
  54821. */
  54822. onTaskError: (task: AbstractAssetTask) => void;
  54823. /**
  54824. * Callback called when a task is done (whatever the result is)
  54825. */
  54826. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54827. /**
  54828. * Observable called when all tasks are processed
  54829. */
  54830. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54831. /**
  54832. * Observable called when a task had an error
  54833. */
  54834. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54835. /**
  54836. * Observable called when all tasks were executed
  54837. */
  54838. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54839. /**
  54840. * Observable called when a task is done (whatever the result is)
  54841. */
  54842. onProgressObservable: Observable<IAssetsProgressEvent>;
  54843. /**
  54844. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54846. */
  54847. useDefaultLoadingScreen: boolean;
  54848. /**
  54849. * Creates a new AssetsManager
  54850. * @param scene defines the scene to work on
  54851. */
  54852. constructor(scene: Scene);
  54853. /**
  54854. * Add a MeshAssetTask to the list of active tasks
  54855. * @param taskName defines the name of the new task
  54856. * @param meshesNames defines the name of meshes to load
  54857. * @param rootUrl defines the root url to use to locate files
  54858. * @param sceneFilename defines the filename of the scene file
  54859. * @returns a new MeshAssetTask object
  54860. */
  54861. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54862. /**
  54863. * Add a TextFileAssetTask to the list of active tasks
  54864. * @param taskName defines the name of the new task
  54865. * @param url defines the url of the file to load
  54866. * @returns a new TextFileAssetTask object
  54867. */
  54868. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54869. /**
  54870. * Add a BinaryFileAssetTask to the list of active tasks
  54871. * @param taskName defines the name of the new task
  54872. * @param url defines the url of the file to load
  54873. * @returns a new BinaryFileAssetTask object
  54874. */
  54875. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54876. /**
  54877. * Add a ImageAssetTask to the list of active tasks
  54878. * @param taskName defines the name of the new task
  54879. * @param url defines the url of the file to load
  54880. * @returns a new ImageAssetTask object
  54881. */
  54882. addImageTask(taskName: string, url: string): ImageAssetTask;
  54883. /**
  54884. * Add a TextureAssetTask to the list of active tasks
  54885. * @param taskName defines the name of the new task
  54886. * @param url defines the url of the file to load
  54887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54888. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54889. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54890. * @returns a new TextureAssetTask object
  54891. */
  54892. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54893. /**
  54894. * Add a CubeTextureAssetTask to the list of active tasks
  54895. * @param taskName defines the name of the new task
  54896. * @param url defines the url of the file to load
  54897. * @param extensions defines the extension to use to load the cube map (can be null)
  54898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54899. * @param files defines the list of files to load (can be null)
  54900. * @returns a new CubeTextureAssetTask object
  54901. */
  54902. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54903. /**
  54904. *
  54905. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54906. * @param taskName defines the name of the new task
  54907. * @param url defines the url of the file to load
  54908. * @param size defines the size you want for the cubemap (can be null)
  54909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54910. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54911. * @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)
  54912. * @param reserved Internal use only
  54913. * @returns a new HDRCubeTextureAssetTask object
  54914. */
  54915. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54916. /**
  54917. *
  54918. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54919. * @param taskName defines the name of the new task
  54920. * @param url defines the url of the file to load
  54921. * @param size defines the size you want for the cubemap (can be null)
  54922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54923. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54924. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54925. * @returns a new EquiRectangularCubeTextureAssetTask object
  54926. */
  54927. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54928. /**
  54929. * Remove a task from the assets manager.
  54930. * @param task the task to remove
  54931. */
  54932. removeTask(task: AbstractAssetTask): void;
  54933. private _decreaseWaitingTasksCount;
  54934. private _runTask;
  54935. /**
  54936. * Reset the AssetsManager and remove all tasks
  54937. * @return the current instance of the AssetsManager
  54938. */
  54939. reset(): AssetsManager;
  54940. /**
  54941. * Start the loading process
  54942. * @return the current instance of the AssetsManager
  54943. */
  54944. load(): AssetsManager;
  54945. /**
  54946. * Start the loading process as an async operation
  54947. * @return a promise returning the list of failed tasks
  54948. */
  54949. loadAsync(): Promise<void>;
  54950. }
  54951. }
  54952. declare module BABYLON {
  54953. /**
  54954. * Wrapper class for promise with external resolve and reject.
  54955. */
  54956. export class Deferred<T> {
  54957. /**
  54958. * The promise associated with this deferred object.
  54959. */
  54960. readonly promise: Promise<T>;
  54961. private _resolve;
  54962. private _reject;
  54963. /**
  54964. * The resolve method of the promise associated with this deferred object.
  54965. */
  54966. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54967. /**
  54968. * The reject method of the promise associated with this deferred object.
  54969. */
  54970. readonly reject: (reason?: any) => void;
  54971. /**
  54972. * Constructor for this deferred object.
  54973. */
  54974. constructor();
  54975. }
  54976. }
  54977. declare module BABYLON {
  54978. /**
  54979. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54980. */
  54981. export class MeshExploder {
  54982. private _centerMesh;
  54983. private _meshes;
  54984. private _meshesOrigins;
  54985. private _toCenterVectors;
  54986. private _scaledDirection;
  54987. private _newPosition;
  54988. private _centerPosition;
  54989. /**
  54990. * Explodes meshes from a center mesh.
  54991. * @param meshes The meshes to explode.
  54992. * @param centerMesh The mesh to be center of explosion.
  54993. */
  54994. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54995. private _setCenterMesh;
  54996. /**
  54997. * Get class name
  54998. * @returns "MeshExploder"
  54999. */
  55000. getClassName(): string;
  55001. /**
  55002. * "Exploded meshes"
  55003. * @returns Array of meshes with the centerMesh at index 0.
  55004. */
  55005. getMeshes(): Array<Mesh>;
  55006. /**
  55007. * Explodes meshes giving a specific direction
  55008. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55009. */
  55010. explode(direction?: number): void;
  55011. }
  55012. }
  55013. declare module BABYLON {
  55014. /**
  55015. * Class used to help managing file picking and drag'n'drop
  55016. */
  55017. export class FilesInput {
  55018. /**
  55019. * List of files ready to be loaded
  55020. */
  55021. static readonly FilesToLoad: {
  55022. [key: string]: File;
  55023. };
  55024. /**
  55025. * Callback called when a file is processed
  55026. */
  55027. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55028. private _engine;
  55029. private _currentScene;
  55030. private _sceneLoadedCallback;
  55031. private _progressCallback;
  55032. private _additionalRenderLoopLogicCallback;
  55033. private _textureLoadingCallback;
  55034. private _startingProcessingFilesCallback;
  55035. private _onReloadCallback;
  55036. private _errorCallback;
  55037. private _elementToMonitor;
  55038. private _sceneFileToLoad;
  55039. private _filesToLoad;
  55040. /**
  55041. * Creates a new FilesInput
  55042. * @param engine defines the rendering engine
  55043. * @param scene defines the hosting scene
  55044. * @param sceneLoadedCallback callback called when scene is loaded
  55045. * @param progressCallback callback called to track progress
  55046. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55047. * @param textureLoadingCallback callback called when a texture is loading
  55048. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55049. * @param onReloadCallback callback called when a reload is requested
  55050. * @param errorCallback callback call if an error occurs
  55051. */
  55052. 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);
  55053. private _dragEnterHandler;
  55054. private _dragOverHandler;
  55055. private _dropHandler;
  55056. /**
  55057. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55058. * @param elementToMonitor defines the DOM element to track
  55059. */
  55060. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55061. /**
  55062. * Release all associated resources
  55063. */
  55064. dispose(): void;
  55065. private renderFunction;
  55066. private drag;
  55067. private drop;
  55068. private _traverseFolder;
  55069. private _processFiles;
  55070. /**
  55071. * Load files from a drop event
  55072. * @param event defines the drop event to use as source
  55073. */
  55074. loadFiles(event: any): void;
  55075. private _processReload;
  55076. /**
  55077. * Reload the current scene from the loaded files
  55078. */
  55079. reload(): void;
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55086. */
  55087. export class SceneOptimization {
  55088. /**
  55089. * Defines the priority of this optimization (0 by default which means first in the list)
  55090. */
  55091. priority: number;
  55092. /**
  55093. * Gets a string describing the action executed by the current optimization
  55094. * @returns description string
  55095. */
  55096. getDescription(): string;
  55097. /**
  55098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55099. * @param scene defines the current scene where to apply this optimization
  55100. * @param optimizer defines the current optimizer
  55101. * @returns true if everything that can be done was applied
  55102. */
  55103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55104. /**
  55105. * Creates the SceneOptimization object
  55106. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55107. * @param desc defines the description associated with the optimization
  55108. */
  55109. constructor(
  55110. /**
  55111. * Defines the priority of this optimization (0 by default which means first in the list)
  55112. */
  55113. priority?: number);
  55114. }
  55115. /**
  55116. * Defines an optimization used to reduce the size of render target textures
  55117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55118. */
  55119. export class TextureOptimization extends SceneOptimization {
  55120. /**
  55121. * Defines the priority of this optimization (0 by default which means first in the list)
  55122. */
  55123. priority: number;
  55124. /**
  55125. * 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
  55126. */
  55127. maximumSize: number;
  55128. /**
  55129. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55130. */
  55131. step: number;
  55132. /**
  55133. * Gets a string describing the action executed by the current optimization
  55134. * @returns description string
  55135. */
  55136. getDescription(): string;
  55137. /**
  55138. * Creates the TextureOptimization object
  55139. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55140. * @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
  55141. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55142. */
  55143. constructor(
  55144. /**
  55145. * Defines the priority of this optimization (0 by default which means first in the list)
  55146. */
  55147. priority?: number,
  55148. /**
  55149. * 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
  55150. */
  55151. maximumSize?: number,
  55152. /**
  55153. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55154. */
  55155. step?: number);
  55156. /**
  55157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55158. * @param scene defines the current scene where to apply this optimization
  55159. * @param optimizer defines the current optimizer
  55160. * @returns true if everything that can be done was applied
  55161. */
  55162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55163. }
  55164. /**
  55165. * Defines an optimization used to increase or decrease the rendering resolution
  55166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55167. */
  55168. export class HardwareScalingOptimization extends SceneOptimization {
  55169. /**
  55170. * Defines the priority of this optimization (0 by default which means first in the list)
  55171. */
  55172. priority: number;
  55173. /**
  55174. * Defines the maximum scale to use (2 by default)
  55175. */
  55176. maximumScale: number;
  55177. /**
  55178. * Defines the step to use between two passes (0.5 by default)
  55179. */
  55180. step: number;
  55181. private _currentScale;
  55182. private _directionOffset;
  55183. /**
  55184. * Gets a string describing the action executed by the current optimization
  55185. * @return description string
  55186. */
  55187. getDescription(): string;
  55188. /**
  55189. * Creates the HardwareScalingOptimization object
  55190. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55191. * @param maximumScale defines the maximum scale to use (2 by default)
  55192. * @param step defines the step to use between two passes (0.5 by default)
  55193. */
  55194. constructor(
  55195. /**
  55196. * Defines the priority of this optimization (0 by default which means first in the list)
  55197. */
  55198. priority?: number,
  55199. /**
  55200. * Defines the maximum scale to use (2 by default)
  55201. */
  55202. maximumScale?: number,
  55203. /**
  55204. * Defines the step to use between two passes (0.5 by default)
  55205. */
  55206. step?: number);
  55207. /**
  55208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55209. * @param scene defines the current scene where to apply this optimization
  55210. * @param optimizer defines the current optimizer
  55211. * @returns true if everything that can be done was applied
  55212. */
  55213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55214. }
  55215. /**
  55216. * Defines an optimization used to remove shadows
  55217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55218. */
  55219. export class ShadowsOptimization extends SceneOptimization {
  55220. /**
  55221. * Gets a string describing the action executed by the current optimization
  55222. * @return description string
  55223. */
  55224. getDescription(): string;
  55225. /**
  55226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55227. * @param scene defines the current scene where to apply this optimization
  55228. * @param optimizer defines the current optimizer
  55229. * @returns true if everything that can be done was applied
  55230. */
  55231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55232. }
  55233. /**
  55234. * Defines an optimization used to turn post-processes off
  55235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55236. */
  55237. export class PostProcessesOptimization extends SceneOptimization {
  55238. /**
  55239. * Gets a string describing the action executed by the current optimization
  55240. * @return description string
  55241. */
  55242. getDescription(): string;
  55243. /**
  55244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55245. * @param scene defines the current scene where to apply this optimization
  55246. * @param optimizer defines the current optimizer
  55247. * @returns true if everything that can be done was applied
  55248. */
  55249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55250. }
  55251. /**
  55252. * Defines an optimization used to turn lens flares off
  55253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55254. */
  55255. export class LensFlaresOptimization extends SceneOptimization {
  55256. /**
  55257. * Gets a string describing the action executed by the current optimization
  55258. * @return description string
  55259. */
  55260. getDescription(): string;
  55261. /**
  55262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55263. * @param scene defines the current scene where to apply this optimization
  55264. * @param optimizer defines the current optimizer
  55265. * @returns true if everything that can be done was applied
  55266. */
  55267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55268. }
  55269. /**
  55270. * Defines an optimization based on user defined callback.
  55271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55272. */
  55273. export class CustomOptimization extends SceneOptimization {
  55274. /**
  55275. * Callback called to apply the custom optimization.
  55276. */
  55277. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55278. /**
  55279. * Callback called to get custom description
  55280. */
  55281. onGetDescription: () => string;
  55282. /**
  55283. * Gets a string describing the action executed by the current optimization
  55284. * @returns description string
  55285. */
  55286. getDescription(): string;
  55287. /**
  55288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55289. * @param scene defines the current scene where to apply this optimization
  55290. * @param optimizer defines the current optimizer
  55291. * @returns true if everything that can be done was applied
  55292. */
  55293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55294. }
  55295. /**
  55296. * Defines an optimization used to turn particles off
  55297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55298. */
  55299. export class ParticlesOptimization extends SceneOptimization {
  55300. /**
  55301. * Gets a string describing the action executed by the current optimization
  55302. * @return description string
  55303. */
  55304. getDescription(): string;
  55305. /**
  55306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55307. * @param scene defines the current scene where to apply this optimization
  55308. * @param optimizer defines the current optimizer
  55309. * @returns true if everything that can be done was applied
  55310. */
  55311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55312. }
  55313. /**
  55314. * Defines an optimization used to turn render targets off
  55315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55316. */
  55317. export class RenderTargetsOptimization extends SceneOptimization {
  55318. /**
  55319. * Gets a string describing the action executed by the current optimization
  55320. * @return description string
  55321. */
  55322. getDescription(): string;
  55323. /**
  55324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55325. * @param scene defines the current scene where to apply this optimization
  55326. * @param optimizer defines the current optimizer
  55327. * @returns true if everything that can be done was applied
  55328. */
  55329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55330. }
  55331. /**
  55332. * Defines an optimization used to merge meshes with compatible materials
  55333. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55334. */
  55335. export class MergeMeshesOptimization extends SceneOptimization {
  55336. private static _UpdateSelectionTree;
  55337. /**
  55338. * Gets or sets a boolean which defines if optimization octree has to be updated
  55339. */
  55340. /**
  55341. * Gets or sets a boolean which defines if optimization octree has to be updated
  55342. */
  55343. static UpdateSelectionTree: boolean;
  55344. /**
  55345. * Gets a string describing the action executed by the current optimization
  55346. * @return description string
  55347. */
  55348. getDescription(): string;
  55349. private _canBeMerged;
  55350. /**
  55351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55352. * @param scene defines the current scene where to apply this optimization
  55353. * @param optimizer defines the current optimizer
  55354. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55355. * @returns true if everything that can be done was applied
  55356. */
  55357. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55358. }
  55359. /**
  55360. * Defines a list of options used by SceneOptimizer
  55361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55362. */
  55363. export class SceneOptimizerOptions {
  55364. /**
  55365. * Defines the target frame rate to reach (60 by default)
  55366. */
  55367. targetFrameRate: number;
  55368. /**
  55369. * Defines the interval between two checkes (2000ms by default)
  55370. */
  55371. trackerDuration: number;
  55372. /**
  55373. * Gets the list of optimizations to apply
  55374. */
  55375. optimizations: SceneOptimization[];
  55376. /**
  55377. * Creates a new list of options used by SceneOptimizer
  55378. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55379. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55380. */
  55381. constructor(
  55382. /**
  55383. * Defines the target frame rate to reach (60 by default)
  55384. */
  55385. targetFrameRate?: number,
  55386. /**
  55387. * Defines the interval between two checkes (2000ms by default)
  55388. */
  55389. trackerDuration?: number);
  55390. /**
  55391. * Add a new optimization
  55392. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55393. * @returns the current SceneOptimizerOptions
  55394. */
  55395. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55396. /**
  55397. * Add a new custom optimization
  55398. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55399. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55400. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55401. * @returns the current SceneOptimizerOptions
  55402. */
  55403. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55404. /**
  55405. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55406. * @param targetFrameRate defines the target frame rate (60 by default)
  55407. * @returns a SceneOptimizerOptions object
  55408. */
  55409. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55410. /**
  55411. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55412. * @param targetFrameRate defines the target frame rate (60 by default)
  55413. * @returns a SceneOptimizerOptions object
  55414. */
  55415. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55416. /**
  55417. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55418. * @param targetFrameRate defines the target frame rate (60 by default)
  55419. * @returns a SceneOptimizerOptions object
  55420. */
  55421. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55422. }
  55423. /**
  55424. * Class used to run optimizations in order to reach a target frame rate
  55425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55426. */
  55427. export class SceneOptimizer implements IDisposable {
  55428. private _isRunning;
  55429. private _options;
  55430. private _scene;
  55431. private _currentPriorityLevel;
  55432. private _targetFrameRate;
  55433. private _trackerDuration;
  55434. private _currentFrameRate;
  55435. private _sceneDisposeObserver;
  55436. private _improvementMode;
  55437. /**
  55438. * Defines an observable called when the optimizer reaches the target frame rate
  55439. */
  55440. onSuccessObservable: Observable<SceneOptimizer>;
  55441. /**
  55442. * Defines an observable called when the optimizer enables an optimization
  55443. */
  55444. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55445. /**
  55446. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55447. */
  55448. onFailureObservable: Observable<SceneOptimizer>;
  55449. /**
  55450. * Gets a boolean indicating if the optimizer is in improvement mode
  55451. */
  55452. readonly isInImprovementMode: boolean;
  55453. /**
  55454. * Gets the current priority level (0 at start)
  55455. */
  55456. readonly currentPriorityLevel: number;
  55457. /**
  55458. * Gets the current frame rate checked by the SceneOptimizer
  55459. */
  55460. readonly currentFrameRate: number;
  55461. /**
  55462. * Gets or sets the current target frame rate (60 by default)
  55463. */
  55464. /**
  55465. * Gets or sets the current target frame rate (60 by default)
  55466. */
  55467. targetFrameRate: number;
  55468. /**
  55469. * Gets or sets the current interval between two checks (every 2000ms by default)
  55470. */
  55471. /**
  55472. * Gets or sets the current interval between two checks (every 2000ms by default)
  55473. */
  55474. trackerDuration: number;
  55475. /**
  55476. * Gets the list of active optimizations
  55477. */
  55478. readonly optimizations: SceneOptimization[];
  55479. /**
  55480. * Creates a new SceneOptimizer
  55481. * @param scene defines the scene to work on
  55482. * @param options defines the options to use with the SceneOptimizer
  55483. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55484. * @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)
  55485. */
  55486. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55487. /**
  55488. * Stops the current optimizer
  55489. */
  55490. stop(): void;
  55491. /**
  55492. * Reset the optimizer to initial step (current priority level = 0)
  55493. */
  55494. reset(): void;
  55495. /**
  55496. * Start the optimizer. By default it will try to reach a specific framerate
  55497. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55498. */
  55499. start(): void;
  55500. private _checkCurrentState;
  55501. /**
  55502. * Release all resources
  55503. */
  55504. dispose(): void;
  55505. /**
  55506. * Helper function to create a SceneOptimizer with one single line of code
  55507. * @param scene defines the scene to work on
  55508. * @param options defines the options to use with the SceneOptimizer
  55509. * @param onSuccess defines a callback to call on success
  55510. * @param onFailure defines a callback to call on failure
  55511. * @returns the new SceneOptimizer object
  55512. */
  55513. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55514. }
  55515. }
  55516. declare module BABYLON {
  55517. /**
  55518. * Class used to serialize a scene into a string
  55519. */
  55520. export class SceneSerializer {
  55521. /**
  55522. * Clear cache used by a previous serialization
  55523. */
  55524. static ClearCache(): void;
  55525. /**
  55526. * Serialize a scene into a JSON compatible object
  55527. * @param scene defines the scene to serialize
  55528. * @returns a JSON compatible object
  55529. */
  55530. static Serialize(scene: Scene): any;
  55531. /**
  55532. * Serialize a mesh into a JSON compatible object
  55533. * @param toSerialize defines the mesh to serialize
  55534. * @param withParents defines if parents must be serialized as well
  55535. * @param withChildren defines if children must be serialized as well
  55536. * @returns a JSON compatible object
  55537. */
  55538. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55539. }
  55540. }
  55541. declare module BABYLON {
  55542. /**
  55543. * Class used to host texture specific utilities
  55544. */
  55545. export class TextureTools {
  55546. /**
  55547. * Uses the GPU to create a copy texture rescaled at a given size
  55548. * @param texture Texture to copy from
  55549. * @param width defines the desired width
  55550. * @param height defines the desired height
  55551. * @param useBilinearMode defines if bilinear mode has to be used
  55552. * @return the generated texture
  55553. */
  55554. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55555. }
  55556. }
  55557. declare module BABYLON {
  55558. /**
  55559. * This represents the different options avilable for the video capture.
  55560. */
  55561. export interface VideoRecorderOptions {
  55562. /** Defines the mime type of the video */
  55563. mimeType: string;
  55564. /** Defines the video the video should be recorded at */
  55565. fps: number;
  55566. /** Defines the chunk size for the recording data */
  55567. recordChunckSize: number;
  55568. /** The audio tracks to attach to the record */
  55569. audioTracks?: MediaStreamTrack[];
  55570. }
  55571. /**
  55572. * This can helps recording videos from BabylonJS.
  55573. * This is based on the available WebRTC functionalities of the browser.
  55574. *
  55575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55576. */
  55577. export class VideoRecorder {
  55578. private static readonly _defaultOptions;
  55579. /**
  55580. * Returns wehther or not the VideoRecorder is available in your browser.
  55581. * @param engine Defines the Babylon Engine to check the support for
  55582. * @returns true if supported otherwise false
  55583. */
  55584. static IsSupported(engine: Engine): boolean;
  55585. private readonly _options;
  55586. private _canvas;
  55587. private _mediaRecorder;
  55588. private _recordedChunks;
  55589. private _fileName;
  55590. private _resolve;
  55591. private _reject;
  55592. /**
  55593. * True wether a recording is already in progress.
  55594. */
  55595. readonly isRecording: boolean;
  55596. /**
  55597. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55598. * a video file.
  55599. * @param engine Defines the BabylonJS Engine you wish to record
  55600. * @param options Defines options that can be used to customized the capture
  55601. */
  55602. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55603. /**
  55604. * Stops the current recording before the default capture timeout passed in the startRecording
  55605. * functions.
  55606. */
  55607. stopRecording(): void;
  55608. /**
  55609. * Starts recording the canvas for a max duration specified in parameters.
  55610. * @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.
  55611. * @param maxDuration Defines the maximum recording time in seconds.
  55612. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55613. * @return a promise callback at the end of the recording with the video data in Blob.
  55614. */
  55615. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55616. /**
  55617. * Releases internal resources used during the recording.
  55618. */
  55619. dispose(): void;
  55620. private _handleDataAvailable;
  55621. private _handleError;
  55622. private _handleStop;
  55623. }
  55624. }
  55625. declare module BABYLON {
  55626. /**
  55627. * Class containing a set of static utilities functions for screenshots
  55628. */
  55629. export class ScreenshotTools {
  55630. /**
  55631. * Captures a screenshot of the current rendering
  55632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55633. * @param engine defines the rendering engine
  55634. * @param camera defines the source camera
  55635. * @param size This parameter can be set to a single number or to an object with the
  55636. * following (optional) properties: precision, width, height. If a single number is passed,
  55637. * it will be used for both width and height. If an object is passed, the screenshot size
  55638. * will be derived from the parameters. The precision property is a multiplier allowing
  55639. * rendering at a higher or lower resolution
  55640. * @param successCallback defines the callback receives a single parameter which contains the
  55641. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55642. * src parameter of an <img> to display it
  55643. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55644. * Check your browser for supported MIME types
  55645. */
  55646. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55647. /**
  55648. * Generates an image screenshot from the specified camera.
  55649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55650. * @param engine The engine to use for rendering
  55651. * @param camera The camera to use for rendering
  55652. * @param size This parameter can be set to a single number or to an object with the
  55653. * following (optional) properties: precision, width, height. If a single number is passed,
  55654. * it will be used for both width and height. If an object is passed, the screenshot size
  55655. * will be derived from the parameters. The precision property is a multiplier allowing
  55656. * rendering at a higher or lower resolution
  55657. * @param successCallback The callback receives a single parameter which contains the
  55658. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55659. * src parameter of an <img> to display it
  55660. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55661. * Check your browser for supported MIME types
  55662. * @param samples Texture samples (default: 1)
  55663. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55664. * @param fileName A name for for the downloaded file.
  55665. */
  55666. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /**
  55671. * A cursor which tracks a point on a path
  55672. */
  55673. export class PathCursor {
  55674. private path;
  55675. /**
  55676. * Stores path cursor callbacks for when an onchange event is triggered
  55677. */
  55678. private _onchange;
  55679. /**
  55680. * The value of the path cursor
  55681. */
  55682. value: number;
  55683. /**
  55684. * The animation array of the path cursor
  55685. */
  55686. animations: Animation[];
  55687. /**
  55688. * Initializes the path cursor
  55689. * @param path The path to track
  55690. */
  55691. constructor(path: Path2);
  55692. /**
  55693. * Gets the cursor point on the path
  55694. * @returns A point on the path cursor at the cursor location
  55695. */
  55696. getPoint(): Vector3;
  55697. /**
  55698. * Moves the cursor ahead by the step amount
  55699. * @param step The amount to move the cursor forward
  55700. * @returns This path cursor
  55701. */
  55702. moveAhead(step?: number): PathCursor;
  55703. /**
  55704. * Moves the cursor behind by the step amount
  55705. * @param step The amount to move the cursor back
  55706. * @returns This path cursor
  55707. */
  55708. moveBack(step?: number): PathCursor;
  55709. /**
  55710. * Moves the cursor by the step amount
  55711. * If the step amount is greater than one, an exception is thrown
  55712. * @param step The amount to move the cursor
  55713. * @returns This path cursor
  55714. */
  55715. move(step: number): PathCursor;
  55716. /**
  55717. * Ensures that the value is limited between zero and one
  55718. * @returns This path cursor
  55719. */
  55720. private ensureLimits;
  55721. /**
  55722. * Runs onchange callbacks on change (used by the animation engine)
  55723. * @returns This path cursor
  55724. */
  55725. private raiseOnChange;
  55726. /**
  55727. * Executes a function on change
  55728. * @param f A path cursor onchange callback
  55729. * @returns This path cursor
  55730. */
  55731. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55732. }
  55733. }
  55734. declare module BABYLON {
  55735. /** @hidden */
  55736. export var blurPixelShader: {
  55737. name: string;
  55738. shader: string;
  55739. };
  55740. }
  55741. declare module BABYLON {
  55742. /** @hidden */
  55743. export var bones300Declaration: {
  55744. name: string;
  55745. shader: string;
  55746. };
  55747. }
  55748. declare module BABYLON {
  55749. /** @hidden */
  55750. export var instances300Declaration: {
  55751. name: string;
  55752. shader: string;
  55753. };
  55754. }
  55755. declare module BABYLON {
  55756. /** @hidden */
  55757. export var pointCloudVertexDeclaration: {
  55758. name: string;
  55759. shader: string;
  55760. };
  55761. }
  55762. // Mixins
  55763. interface Window {
  55764. mozIndexedDB: IDBFactory;
  55765. webkitIndexedDB: IDBFactory;
  55766. msIndexedDB: IDBFactory;
  55767. webkitURL: typeof URL;
  55768. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55769. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55770. WebGLRenderingContext: WebGLRenderingContext;
  55771. MSGesture: MSGesture;
  55772. CANNON: any;
  55773. AudioContext: AudioContext;
  55774. webkitAudioContext: AudioContext;
  55775. PointerEvent: any;
  55776. Math: Math;
  55777. Uint8Array: Uint8ArrayConstructor;
  55778. Float32Array: Float32ArrayConstructor;
  55779. mozURL: typeof URL;
  55780. msURL: typeof URL;
  55781. VRFrameData: any; // WebVR, from specs 1.1
  55782. DracoDecoderModule: any;
  55783. setImmediate(handler: (...args: any[]) => void): number;
  55784. }
  55785. interface HTMLCanvasElement {
  55786. requestPointerLock(): void;
  55787. msRequestPointerLock?(): void;
  55788. mozRequestPointerLock?(): void;
  55789. webkitRequestPointerLock?(): void;
  55790. /** Track wether a record is in progress */
  55791. isRecording: boolean;
  55792. /** Capture Stream method defined by some browsers */
  55793. captureStream(fps?: number): MediaStream;
  55794. }
  55795. interface CanvasRenderingContext2D {
  55796. msImageSmoothingEnabled: boolean;
  55797. }
  55798. interface MouseEvent {
  55799. mozMovementX: number;
  55800. mozMovementY: number;
  55801. webkitMovementX: number;
  55802. webkitMovementY: number;
  55803. msMovementX: number;
  55804. msMovementY: number;
  55805. }
  55806. interface Navigator {
  55807. mozGetVRDevices: (any: any) => any;
  55808. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55809. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55810. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55811. webkitGetGamepads(): Gamepad[];
  55812. msGetGamepads(): Gamepad[];
  55813. webkitGamepads(): Gamepad[];
  55814. }
  55815. interface HTMLVideoElement {
  55816. mozSrcObject: any;
  55817. }
  55818. interface Math {
  55819. fround(x: number): number;
  55820. imul(a: number, b: number): number;
  55821. }
  55822. interface WebGLRenderingContext {
  55823. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55824. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55825. vertexAttribDivisor(index: number, divisor: number): void;
  55826. createVertexArray(): any;
  55827. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55828. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55829. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55830. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55831. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55832. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55833. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55834. // Queries
  55835. createQuery(): WebGLQuery;
  55836. deleteQuery(query: WebGLQuery): void;
  55837. beginQuery(target: number, query: WebGLQuery): void;
  55838. endQuery(target: number): void;
  55839. getQueryParameter(query: WebGLQuery, pname: number): any;
  55840. getQuery(target: number, pname: number): any;
  55841. MAX_SAMPLES: number;
  55842. RGBA8: number;
  55843. READ_FRAMEBUFFER: number;
  55844. DRAW_FRAMEBUFFER: number;
  55845. UNIFORM_BUFFER: number;
  55846. HALF_FLOAT_OES: number;
  55847. RGBA16F: number;
  55848. RGBA32F: number;
  55849. R32F: number;
  55850. RG32F: number;
  55851. RGB32F: number;
  55852. R16F: number;
  55853. RG16F: number;
  55854. RGB16F: number;
  55855. RED: number;
  55856. RG: number;
  55857. R8: number;
  55858. RG8: number;
  55859. UNSIGNED_INT_24_8: number;
  55860. DEPTH24_STENCIL8: number;
  55861. /* Multiple Render Targets */
  55862. drawBuffers(buffers: number[]): void;
  55863. readBuffer(src: number): void;
  55864. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55865. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55866. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55867. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55868. // Occlusion Query
  55869. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55870. ANY_SAMPLES_PASSED: number;
  55871. QUERY_RESULT_AVAILABLE: number;
  55872. QUERY_RESULT: number;
  55873. }
  55874. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55875. }
  55876. interface EXT_disjoint_timer_query {
  55877. QUERY_COUNTER_BITS_EXT: number;
  55878. TIME_ELAPSED_EXT: number;
  55879. TIMESTAMP_EXT: number;
  55880. GPU_DISJOINT_EXT: number;
  55881. QUERY_RESULT_EXT: number;
  55882. QUERY_RESULT_AVAILABLE_EXT: number;
  55883. queryCounterEXT(query: WebGLQuery, target: number): void;
  55884. createQueryEXT(): WebGLQuery;
  55885. beginQueryEXT(target: number, query: WebGLQuery): void;
  55886. endQueryEXT(target: number): void;
  55887. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55888. deleteQueryEXT(query: WebGLQuery): void;
  55889. }
  55890. interface WebGLUniformLocation { currentState: any;
  55891. }
  55892. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55893. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55894. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55895. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55896. interface WebGLRenderingContext {
  55897. readonly RASTERIZER_DISCARD: number;
  55898. readonly DEPTH_COMPONENT24: number;
  55899. readonly TEXTURE_3D: number;
  55900. readonly TEXTURE_2D_ARRAY: number;
  55901. readonly TEXTURE_COMPARE_FUNC: number;
  55902. readonly TEXTURE_COMPARE_MODE: number;
  55903. readonly COMPARE_REF_TO_TEXTURE: number;
  55904. readonly TEXTURE_WRAP_R: number;
  55905. readonly HALF_FLOAT: number;
  55906. readonly RGB8: number;
  55907. readonly RED_INTEGER: number;
  55908. readonly RG_INTEGER: number;
  55909. readonly RGB_INTEGER: number;
  55910. readonly RGBA_INTEGER: number;
  55911. readonly R8_SNORM: number;
  55912. readonly RG8_SNORM: number;
  55913. readonly RGB8_SNORM: number;
  55914. readonly RGBA8_SNORM: number;
  55915. readonly R8I: number;
  55916. readonly RG8I: number;
  55917. readonly RGB8I: number;
  55918. readonly RGBA8I: number;
  55919. readonly R8UI: number;
  55920. readonly RG8UI: number;
  55921. readonly RGB8UI: number;
  55922. readonly RGBA8UI: number;
  55923. readonly R16I: number;
  55924. readonly RG16I: number;
  55925. readonly RGB16I: number;
  55926. readonly RGBA16I: number;
  55927. readonly R16UI: number;
  55928. readonly RG16UI: number;
  55929. readonly RGB16UI: number;
  55930. readonly RGBA16UI: number;
  55931. readonly R32I: number;
  55932. readonly RG32I: number;
  55933. readonly RGB32I: number;
  55934. readonly RGBA32I: number;
  55935. readonly R32UI: number;
  55936. readonly RG32UI: number;
  55937. readonly RGB32UI: number;
  55938. readonly RGBA32UI: number;
  55939. readonly RGB10_A2UI: number;
  55940. readonly R11F_G11F_B10F: number;
  55941. readonly RGB9_E5: number;
  55942. readonly RGB10_A2: number;
  55943. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55944. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55945. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55946. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55947. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55948. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55949. 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;
  55950. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55951. readonly TRANSFORM_FEEDBACK: number;
  55952. readonly INTERLEAVED_ATTRIBS: number;
  55953. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55954. createTransformFeedback(): WebGLTransformFeedback;
  55955. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55956. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55957. beginTransformFeedback(primitiveMode: number): void;
  55958. endTransformFeedback(): void;
  55959. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55960. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55961. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55962. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55963. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55964. }
  55965. interface ImageBitmap {
  55966. readonly width: number;
  55967. readonly height: number;
  55968. close(): void;
  55969. }
  55970. interface WebGLQuery extends WebGLObject {
  55971. }
  55972. declare var WebGLQuery: {
  55973. prototype: WebGLQuery;
  55974. new(): WebGLQuery;
  55975. };
  55976. interface WebGLSampler extends WebGLObject {
  55977. }
  55978. declare var WebGLSampler: {
  55979. prototype: WebGLSampler;
  55980. new(): WebGLSampler;
  55981. };
  55982. interface WebGLSync extends WebGLObject {
  55983. }
  55984. declare var WebGLSync: {
  55985. prototype: WebGLSync;
  55986. new(): WebGLSync;
  55987. };
  55988. interface WebGLTransformFeedback extends WebGLObject {
  55989. }
  55990. declare var WebGLTransformFeedback: {
  55991. prototype: WebGLTransformFeedback;
  55992. new(): WebGLTransformFeedback;
  55993. };
  55994. interface WebGLVertexArrayObject extends WebGLObject {
  55995. }
  55996. declare var WebGLVertexArrayObject: {
  55997. prototype: WebGLVertexArrayObject;
  55998. new(): WebGLVertexArrayObject;
  55999. };
  56000. // Type definitions for WebVR API
  56001. // Project: https://w3c.github.io/webvr/
  56002. // Definitions by: six a <https://github.com/lostfictions>
  56003. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56004. interface VRDisplay extends EventTarget {
  56005. /**
  56006. * Dictionary of capabilities describing the VRDisplay.
  56007. */
  56008. readonly capabilities: VRDisplayCapabilities;
  56009. /**
  56010. * z-depth defining the far plane of the eye view frustum
  56011. * enables mapping of values in the render target depth
  56012. * attachment to scene coordinates. Initially set to 10000.0.
  56013. */
  56014. depthFar: number;
  56015. /**
  56016. * z-depth defining the near plane of the eye view frustum
  56017. * enables mapping of values in the render target depth
  56018. * attachment to scene coordinates. Initially set to 0.01.
  56019. */
  56020. depthNear: number;
  56021. /**
  56022. * An identifier for this distinct VRDisplay. Used as an
  56023. * association point in the Gamepad API.
  56024. */
  56025. readonly displayId: number;
  56026. /**
  56027. * A display name, a user-readable name identifying it.
  56028. */
  56029. readonly displayName: string;
  56030. readonly isConnected: boolean;
  56031. readonly isPresenting: boolean;
  56032. /**
  56033. * If this VRDisplay supports room-scale experiences, the optional
  56034. * stage attribute contains details on the room-scale parameters.
  56035. */
  56036. readonly stageParameters: VRStageParameters | null;
  56037. /**
  56038. * Passing the value returned by `requestAnimationFrame` to
  56039. * `cancelAnimationFrame` will unregister the callback.
  56040. * @param handle Define the hanle of the request to cancel
  56041. */
  56042. cancelAnimationFrame(handle: number): void;
  56043. /**
  56044. * Stops presenting to the VRDisplay.
  56045. * @returns a promise to know when it stopped
  56046. */
  56047. exitPresent(): Promise<void>;
  56048. /**
  56049. * Return the current VREyeParameters for the given eye.
  56050. * @param whichEye Define the eye we want the parameter for
  56051. * @returns the eye parameters
  56052. */
  56053. getEyeParameters(whichEye: string): VREyeParameters;
  56054. /**
  56055. * Populates the passed VRFrameData with the information required to render
  56056. * the current frame.
  56057. * @param frameData Define the data structure to populate
  56058. * @returns true if ok otherwise false
  56059. */
  56060. getFrameData(frameData: VRFrameData): boolean;
  56061. /**
  56062. * Get the layers currently being presented.
  56063. * @returns the list of VR layers
  56064. */
  56065. getLayers(): VRLayer[];
  56066. /**
  56067. * Return a VRPose containing the future predicted pose of the VRDisplay
  56068. * when the current frame will be presented. The value returned will not
  56069. * change until JavaScript has returned control to the browser.
  56070. *
  56071. * The VRPose will contain the position, orientation, velocity,
  56072. * and acceleration of each of these properties.
  56073. * @returns the pose object
  56074. */
  56075. getPose(): VRPose;
  56076. /**
  56077. * Return the current instantaneous pose of the VRDisplay, with no
  56078. * prediction applied.
  56079. * @returns the current instantaneous pose
  56080. */
  56081. getImmediatePose(): VRPose;
  56082. /**
  56083. * The callback passed to `requestAnimationFrame` will be called
  56084. * any time a new frame should be rendered. When the VRDisplay is
  56085. * presenting the callback will be called at the native refresh
  56086. * rate of the HMD. When not presenting this function acts
  56087. * identically to how window.requestAnimationFrame acts. Content should
  56088. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56089. * asynchronously from other displays and at differing refresh rates.
  56090. * @param callback Define the eaction to run next frame
  56091. * @returns the request handle it
  56092. */
  56093. requestAnimationFrame(callback: FrameRequestCallback): number;
  56094. /**
  56095. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56096. * Repeat calls while already presenting will update the VRLayers being displayed.
  56097. * @param layers Define the list of layer to present
  56098. * @returns a promise to know when the request has been fulfilled
  56099. */
  56100. requestPresent(layers: VRLayer[]): Promise<void>;
  56101. /**
  56102. * Reset the pose for this display, treating its current position and
  56103. * orientation as the "origin/zero" values. VRPose.position,
  56104. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56105. * updated when calling resetPose(). This should be called in only
  56106. * sitting-space experiences.
  56107. */
  56108. resetPose(): void;
  56109. /**
  56110. * The VRLayer provided to the VRDisplay will be captured and presented
  56111. * in the HMD. Calling this function has the same effect on the source
  56112. * canvas as any other operation that uses its source image, and canvases
  56113. * created without preserveDrawingBuffer set to true will be cleared.
  56114. * @param pose Define the pose to submit
  56115. */
  56116. submitFrame(pose?: VRPose): void;
  56117. }
  56118. declare var VRDisplay: {
  56119. prototype: VRDisplay;
  56120. new(): VRDisplay;
  56121. };
  56122. interface VRLayer {
  56123. leftBounds?: number[] | Float32Array | null;
  56124. rightBounds?: number[] | Float32Array | null;
  56125. source?: HTMLCanvasElement | null;
  56126. }
  56127. interface VRDisplayCapabilities {
  56128. readonly canPresent: boolean;
  56129. readonly hasExternalDisplay: boolean;
  56130. readonly hasOrientation: boolean;
  56131. readonly hasPosition: boolean;
  56132. readonly maxLayers: number;
  56133. }
  56134. interface VREyeParameters {
  56135. /** @deprecated */
  56136. readonly fieldOfView: VRFieldOfView;
  56137. readonly offset: Float32Array;
  56138. readonly renderHeight: number;
  56139. readonly renderWidth: number;
  56140. }
  56141. interface VRFieldOfView {
  56142. readonly downDegrees: number;
  56143. readonly leftDegrees: number;
  56144. readonly rightDegrees: number;
  56145. readonly upDegrees: number;
  56146. }
  56147. interface VRFrameData {
  56148. readonly leftProjectionMatrix: Float32Array;
  56149. readonly leftViewMatrix: Float32Array;
  56150. readonly pose: VRPose;
  56151. readonly rightProjectionMatrix: Float32Array;
  56152. readonly rightViewMatrix: Float32Array;
  56153. readonly timestamp: number;
  56154. }
  56155. interface VRPose {
  56156. readonly angularAcceleration: Float32Array | null;
  56157. readonly angularVelocity: Float32Array | null;
  56158. readonly linearAcceleration: Float32Array | null;
  56159. readonly linearVelocity: Float32Array | null;
  56160. readonly orientation: Float32Array | null;
  56161. readonly position: Float32Array | null;
  56162. readonly timestamp: number;
  56163. }
  56164. interface VRStageParameters {
  56165. sittingToStandingTransform?: Float32Array;
  56166. sizeX?: number;
  56167. sizeY?: number;
  56168. }
  56169. interface Navigator {
  56170. getVRDisplays(): Promise<VRDisplay[]>;
  56171. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56172. }
  56173. interface Window {
  56174. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56175. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56176. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56177. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56178. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56179. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56180. }
  56181. interface Gamepad {
  56182. readonly displayId: number;
  56183. }
  56184. interface XRDevice {
  56185. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56186. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56187. }
  56188. interface XRSession {
  56189. getInputSources(): Array<any>;
  56190. baseLayer: XRWebGLLayer;
  56191. requestFrameOfReference(type: string): Promise<void>;
  56192. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56193. end(): Promise<void>;
  56194. requestAnimationFrame: Function;
  56195. addEventListener: Function;
  56196. }
  56197. interface XRSessionCreationOptions {
  56198. outputContext?: WebGLRenderingContext | null;
  56199. immersive?: boolean;
  56200. environmentIntegration?: boolean;
  56201. }
  56202. interface XRLayer {
  56203. getViewport: Function;
  56204. framebufferWidth: number;
  56205. framebufferHeight: number;
  56206. }
  56207. interface XRView {
  56208. projectionMatrix: Float32Array;
  56209. }
  56210. interface XRFrame {
  56211. getDevicePose: Function;
  56212. getInputPose: Function;
  56213. views: Array<XRView>;
  56214. baseLayer: XRLayer;
  56215. }
  56216. interface XRFrameOfReference {
  56217. }
  56218. interface XRWebGLLayer extends XRLayer {
  56219. framebuffer: WebGLFramebuffer;
  56220. }
  56221. declare var XRWebGLLayer: {
  56222. prototype: XRWebGLLayer;
  56223. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56224. };
  56225. declare module BABYLON.GUI {
  56226. /**
  56227. * Class used to specific a value and its associated unit
  56228. */
  56229. export class ValueAndUnit {
  56230. /** defines the unit to store */
  56231. unit: number;
  56232. /** defines a boolean indicating if the value can be negative */
  56233. negativeValueAllowed: boolean;
  56234. private _value;
  56235. private _originalUnit;
  56236. /**
  56237. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56238. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56239. */
  56240. ignoreAdaptiveScaling: boolean;
  56241. /**
  56242. * Creates a new ValueAndUnit
  56243. * @param value defines the value to store
  56244. * @param unit defines the unit to store
  56245. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56246. */
  56247. constructor(value: number,
  56248. /** defines the unit to store */
  56249. unit?: number,
  56250. /** defines a boolean indicating if the value can be negative */
  56251. negativeValueAllowed?: boolean);
  56252. /** Gets a boolean indicating if the value is a percentage */
  56253. readonly isPercentage: boolean;
  56254. /** Gets a boolean indicating if the value is store as pixel */
  56255. readonly isPixel: boolean;
  56256. /** Gets direct internal value */
  56257. readonly internalValue: number;
  56258. /**
  56259. * Gets value as pixel
  56260. * @param host defines the root host
  56261. * @param refValue defines the reference value for percentages
  56262. * @returns the value as pixel
  56263. */
  56264. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56265. /**
  56266. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56267. * @param value defines the value to store
  56268. * @param unit defines the unit to store
  56269. * @returns the current ValueAndUnit
  56270. */
  56271. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56272. /**
  56273. * Gets the value accordingly to its unit
  56274. * @param host defines the root host
  56275. * @returns the value
  56276. */
  56277. getValue(host: AdvancedDynamicTexture): number;
  56278. /**
  56279. * Gets a string representation of the value
  56280. * @param host defines the root host
  56281. * @param decimals defines an optional number of decimals to display
  56282. * @returns a string
  56283. */
  56284. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56285. /**
  56286. * Store a value parsed from a string
  56287. * @param source defines the source string
  56288. * @returns true if the value was successfully parsed
  56289. */
  56290. fromString(source: string | number): boolean;
  56291. private static _Regex;
  56292. private static _UNITMODE_PERCENTAGE;
  56293. private static _UNITMODE_PIXEL;
  56294. /** UNITMODE_PERCENTAGE */
  56295. static readonly UNITMODE_PERCENTAGE: number;
  56296. /** UNITMODE_PIXEL */
  56297. static readonly UNITMODE_PIXEL: number;
  56298. }
  56299. }
  56300. declare module BABYLON.GUI {
  56301. /**
  56302. * Define a style used by control to automatically setup properties based on a template.
  56303. * Only support font related properties so far
  56304. */
  56305. export class Style implements BABYLON.IDisposable {
  56306. private _fontFamily;
  56307. private _fontStyle;
  56308. private _fontWeight;
  56309. /** @hidden */ host: AdvancedDynamicTexture;
  56310. /** @hidden */ fontSize: ValueAndUnit;
  56311. /**
  56312. * BABYLON.Observable raised when the style values are changed
  56313. */
  56314. onChangedObservable: BABYLON.Observable<Style>;
  56315. /**
  56316. * Creates a new style object
  56317. * @param host defines the AdvancedDynamicTexture which hosts this style
  56318. */
  56319. constructor(host: AdvancedDynamicTexture);
  56320. /**
  56321. * Gets or sets the font size
  56322. */
  56323. fontSize: string | number;
  56324. /**
  56325. * Gets or sets the font family
  56326. */
  56327. fontFamily: string;
  56328. /**
  56329. * Gets or sets the font style
  56330. */
  56331. fontStyle: string;
  56332. /** Gets or sets font weight */
  56333. fontWeight: string;
  56334. /** Dispose all associated resources */
  56335. dispose(): void;
  56336. }
  56337. }
  56338. declare module BABYLON.GUI {
  56339. /**
  56340. * Class used to transport BABYLON.Vector2 information for pointer events
  56341. */
  56342. export class Vector2WithInfo extends BABYLON.Vector2 {
  56343. /** defines the current mouse button index */
  56344. buttonIndex: number;
  56345. /**
  56346. * Creates a new Vector2WithInfo
  56347. * @param source defines the vector2 data to transport
  56348. * @param buttonIndex defines the current mouse button index
  56349. */
  56350. constructor(source: BABYLON.Vector2,
  56351. /** defines the current mouse button index */
  56352. buttonIndex?: number);
  56353. }
  56354. /** Class used to provide 2D matrix features */
  56355. export class Matrix2D {
  56356. /** Gets the internal array of 6 floats used to store matrix data */
  56357. m: Float32Array;
  56358. /**
  56359. * Creates a new matrix
  56360. * @param m00 defines value for (0, 0)
  56361. * @param m01 defines value for (0, 1)
  56362. * @param m10 defines value for (1, 0)
  56363. * @param m11 defines value for (1, 1)
  56364. * @param m20 defines value for (2, 0)
  56365. * @param m21 defines value for (2, 1)
  56366. */
  56367. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56368. /**
  56369. * Fills the matrix from direct values
  56370. * @param m00 defines value for (0, 0)
  56371. * @param m01 defines value for (0, 1)
  56372. * @param m10 defines value for (1, 0)
  56373. * @param m11 defines value for (1, 1)
  56374. * @param m20 defines value for (2, 0)
  56375. * @param m21 defines value for (2, 1)
  56376. * @returns the current modified matrix
  56377. */
  56378. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56379. /**
  56380. * Gets matrix determinant
  56381. * @returns the determinant
  56382. */
  56383. determinant(): number;
  56384. /**
  56385. * Inverses the matrix and stores it in a target matrix
  56386. * @param result defines the target matrix
  56387. * @returns the current matrix
  56388. */
  56389. invertToRef(result: Matrix2D): Matrix2D;
  56390. /**
  56391. * Multiplies the current matrix with another one
  56392. * @param other defines the second operand
  56393. * @param result defines the target matrix
  56394. * @returns the current matrix
  56395. */
  56396. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56397. /**
  56398. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56399. * @param x defines the x coordinate to transform
  56400. * @param y defines the x coordinate to transform
  56401. * @param result defines the target vector2
  56402. * @returns the current matrix
  56403. */
  56404. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56405. /**
  56406. * Creates an identity matrix
  56407. * @returns a new matrix
  56408. */
  56409. static Identity(): Matrix2D;
  56410. /**
  56411. * Creates a translation matrix and stores it in a target matrix
  56412. * @param x defines the x coordinate of the translation
  56413. * @param y defines the y coordinate of the translation
  56414. * @param result defines the target matrix
  56415. */
  56416. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56417. /**
  56418. * Creates a scaling matrix and stores it in a target matrix
  56419. * @param x defines the x coordinate of the scaling
  56420. * @param y defines the y coordinate of the scaling
  56421. * @param result defines the target matrix
  56422. */
  56423. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56424. /**
  56425. * Creates a rotation matrix and stores it in a target matrix
  56426. * @param angle defines the rotation angle
  56427. * @param result defines the target matrix
  56428. */
  56429. static RotationToRef(angle: number, result: Matrix2D): void;
  56430. private static _TempPreTranslationMatrix;
  56431. private static _TempPostTranslationMatrix;
  56432. private static _TempRotationMatrix;
  56433. private static _TempScalingMatrix;
  56434. private static _TempCompose0;
  56435. private static _TempCompose1;
  56436. private static _TempCompose2;
  56437. /**
  56438. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56439. * @param tx defines the x coordinate of the translation
  56440. * @param ty defines the y coordinate of the translation
  56441. * @param angle defines the rotation angle
  56442. * @param scaleX defines the x coordinate of the scaling
  56443. * @param scaleY defines the y coordinate of the scaling
  56444. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56445. * @param result defines the target matrix
  56446. */
  56447. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56448. }
  56449. }
  56450. declare module BABYLON.GUI {
  56451. /**
  56452. * Class used to store 2D control sizes
  56453. */
  56454. export class Measure {
  56455. /** defines left coordinate */
  56456. left: number;
  56457. /** defines top coordinate */
  56458. top: number;
  56459. /** defines width dimension */
  56460. width: number;
  56461. /** defines height dimension */
  56462. height: number;
  56463. /**
  56464. * Creates a new measure
  56465. * @param left defines left coordinate
  56466. * @param top defines top coordinate
  56467. * @param width defines width dimension
  56468. * @param height defines height dimension
  56469. */
  56470. constructor(
  56471. /** defines left coordinate */
  56472. left: number,
  56473. /** defines top coordinate */
  56474. top: number,
  56475. /** defines width dimension */
  56476. width: number,
  56477. /** defines height dimension */
  56478. height: number);
  56479. /**
  56480. * Copy from another measure
  56481. * @param other defines the other measure to copy from
  56482. */
  56483. copyFrom(other: Measure): void;
  56484. /**
  56485. * Copy from a group of 4 floats
  56486. * @param left defines left coordinate
  56487. * @param top defines top coordinate
  56488. * @param width defines width dimension
  56489. * @param height defines height dimension
  56490. */
  56491. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56492. /**
  56493. * Computes the axis aligned bounding box measure for two given measures
  56494. * @param a Input measure
  56495. * @param b Input measure
  56496. * @param result the resulting bounding measure
  56497. */
  56498. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56499. /**
  56500. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56501. * @param transform the matrix to transform the measure before computing the AABB
  56502. * @param result the resulting AABB
  56503. */
  56504. transformToRef(transform: Matrix2D, result: Measure): void;
  56505. /**
  56506. * Check equality between this measure and another one
  56507. * @param other defines the other measures
  56508. * @returns true if both measures are equals
  56509. */
  56510. isEqualsTo(other: Measure): boolean;
  56511. /**
  56512. * Creates an empty measure
  56513. * @returns a new measure
  56514. */
  56515. static Empty(): Measure;
  56516. }
  56517. }
  56518. declare module BABYLON.GUI {
  56519. /**
  56520. * Interface used to define a control that can receive focus
  56521. */
  56522. export interface IFocusableControl {
  56523. /**
  56524. * Function called when the control receives the focus
  56525. */
  56526. onFocus(): void;
  56527. /**
  56528. * Function called when the control loses the focus
  56529. */
  56530. onBlur(): void;
  56531. /**
  56532. * Function called to let the control handle keyboard events
  56533. * @param evt defines the current keyboard event
  56534. */
  56535. processKeyboard(evt: KeyboardEvent): void;
  56536. /**
  56537. * Function called to get the list of controls that should not steal the focus from this control
  56538. * @returns an array of controls
  56539. */
  56540. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56541. }
  56542. /**
  56543. * Class used to create texture to support 2D GUI elements
  56544. * @see http://doc.babylonjs.com/how_to/gui
  56545. */
  56546. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56547. private _isDirty;
  56548. private _renderObserver;
  56549. private _resizeObserver;
  56550. private _preKeyboardObserver;
  56551. private _pointerMoveObserver;
  56552. private _pointerObserver;
  56553. private _canvasPointerOutObserver;
  56554. private _background;
  56555. /** @hidden */ rootContainer: Container;
  56556. /** @hidden */ lastPickedControl: Control;
  56557. /** @hidden */ lastControlOver: {
  56558. [pointerId: number]: Control;
  56559. };
  56560. /** @hidden */ lastControlDown: {
  56561. [pointerId: number]: Control;
  56562. };
  56563. /** @hidden */ capturingControl: {
  56564. [pointerId: number]: Control;
  56565. };
  56566. /** @hidden */ shouldBlockPointer: boolean;
  56567. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56568. /** @hidden */ linkedControls: Control[];
  56569. private _isFullscreen;
  56570. private _fullscreenViewport;
  56571. private _idealWidth;
  56572. private _idealHeight;
  56573. private _useSmallestIdeal;
  56574. private _renderAtIdealSize;
  56575. private _focusedControl;
  56576. private _blockNextFocusCheck;
  56577. private _renderScale;
  56578. private _rootCanvas;
  56579. private _cursorChanged;
  56580. /**
  56581. * Define type to string to ensure compatibility across browsers
  56582. * Safari doesn't support DataTransfer constructor
  56583. */
  56584. private _clipboardData;
  56585. /**
  56586. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56587. */
  56588. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56589. /**
  56590. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56591. */
  56592. onControlPickedObservable: BABYLON.Observable<Control>;
  56593. /**
  56594. * BABYLON.Observable event triggered before layout is evaluated
  56595. */
  56596. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56597. /**
  56598. * BABYLON.Observable event triggered after the layout was evaluated
  56599. */
  56600. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56601. /**
  56602. * BABYLON.Observable event triggered before the texture is rendered
  56603. */
  56604. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56605. /**
  56606. * BABYLON.Observable event triggered after the texture was rendered
  56607. */
  56608. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56609. /**
  56610. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56611. */
  56612. premulAlpha: boolean;
  56613. /**
  56614. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56615. * Useful when you want more antialiasing
  56616. */
  56617. renderScale: number;
  56618. /** Gets or sets the background color */
  56619. background: string;
  56620. /**
  56621. * Gets or sets the ideal width used to design controls.
  56622. * The GUI will then rescale everything accordingly
  56623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56624. */
  56625. idealWidth: number;
  56626. /**
  56627. * Gets or sets the ideal height used to design controls.
  56628. * The GUI will then rescale everything accordingly
  56629. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56630. */
  56631. idealHeight: number;
  56632. /**
  56633. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56635. */
  56636. useSmallestIdeal: boolean;
  56637. /**
  56638. * Gets or sets a boolean indicating if adaptive scaling must be used
  56639. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56640. */
  56641. renderAtIdealSize: boolean;
  56642. /**
  56643. * Gets the underlying layer used to render the texture when in fullscreen mode
  56644. */
  56645. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56646. /**
  56647. * Gets the root container control
  56648. */
  56649. readonly rootContainer: Container;
  56650. /**
  56651. * Returns an array containing the root container.
  56652. * This is mostly used to let the Inspector introspects the ADT
  56653. * @returns an array containing the rootContainer
  56654. */
  56655. getChildren(): Array<Container>;
  56656. /**
  56657. * Will return all controls that are inside this texture
  56658. * @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
  56659. * @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
  56660. * @return all child controls
  56661. */
  56662. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56663. /**
  56664. * Gets or sets the current focused control
  56665. */
  56666. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56667. /**
  56668. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56669. */
  56670. isForeground: boolean;
  56671. /**
  56672. * Gets or set information about clipboardData
  56673. */
  56674. clipboardData: string;
  56675. /**
  56676. * Creates a new AdvancedDynamicTexture
  56677. * @param name defines the name of the texture
  56678. * @param width defines the width of the texture
  56679. * @param height defines the height of the texture
  56680. * @param scene defines the hosting scene
  56681. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56682. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56683. */
  56684. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56685. /**
  56686. * Get the current class name of the texture useful for serialization or dynamic coding.
  56687. * @returns "AdvancedDynamicTexture"
  56688. */
  56689. getClassName(): string;
  56690. /**
  56691. * Function used to execute a function on all controls
  56692. * @param func defines the function to execute
  56693. * @param container defines the container where controls belong. If null the root container will be used
  56694. */
  56695. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56696. private _useInvalidateRectOptimization;
  56697. /**
  56698. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56699. */
  56700. useInvalidateRectOptimization: boolean;
  56701. private _invalidatedRectangle;
  56702. /**
  56703. * Invalidates a rectangle area on the gui texture
  56704. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56705. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56706. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56707. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56708. */
  56709. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56710. /**
  56711. * Marks the texture as dirty forcing a complete update
  56712. */
  56713. markAsDirty(): void;
  56714. /**
  56715. * Helper function used to create a new style
  56716. * @returns a new style
  56717. * @see http://doc.babylonjs.com/how_to/gui#styles
  56718. */
  56719. createStyle(): Style;
  56720. /**
  56721. * Adds a new control to the root container
  56722. * @param control defines the control to add
  56723. * @returns the current texture
  56724. */
  56725. addControl(control: Control): AdvancedDynamicTexture;
  56726. /**
  56727. * Removes a control from the root container
  56728. * @param control defines the control to remove
  56729. * @returns the current texture
  56730. */
  56731. removeControl(control: Control): AdvancedDynamicTexture;
  56732. /**
  56733. * Release all resources
  56734. */
  56735. dispose(): void;
  56736. private _onResize;
  56737. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56738. /**
  56739. * Get screen coordinates for a vector3
  56740. * @param position defines the position to project
  56741. * @param worldMatrix defines the world matrix to use
  56742. * @returns the projected position
  56743. */
  56744. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56745. private _checkUpdate;
  56746. private _clearMeasure;
  56747. private _render;
  56748. /** @hidden */ changeCursor(cursor: string): void;
  56749. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56750. private _doPicking;
  56751. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56752. [pointerId: number]: Control;
  56753. }, control: Control): void;
  56754. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56755. /** Attach to all scene events required to support pointer events */
  56756. attach(): void;
  56757. /** @hidden */
  56758. private onClipboardCopy;
  56759. /** @hidden */
  56760. private onClipboardCut;
  56761. /** @hidden */
  56762. private onClipboardPaste;
  56763. /**
  56764. * Register the clipboard Events onto the canvas
  56765. */
  56766. registerClipboardEvents(): void;
  56767. /**
  56768. * Unregister the clipboard Events from the canvas
  56769. */
  56770. unRegisterClipboardEvents(): void;
  56771. /**
  56772. * Connect the texture to a hosting mesh to enable interactions
  56773. * @param mesh defines the mesh to attach to
  56774. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56775. */
  56776. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56777. /**
  56778. * Move the focus to a specific control
  56779. * @param control defines the control which will receive the focus
  56780. */
  56781. moveFocusToControl(control: IFocusableControl): void;
  56782. private _manageFocus;
  56783. private _attachToOnPointerOut;
  56784. /**
  56785. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56786. * @param mesh defines the mesh which will receive the texture
  56787. * @param width defines the texture width (1024 by default)
  56788. * @param height defines the texture height (1024 by default)
  56789. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56790. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56791. * @returns a new AdvancedDynamicTexture
  56792. */
  56793. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56794. /**
  56795. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56796. * In this mode the texture will rely on a layer for its rendering.
  56797. * This allows it to be treated like any other layer.
  56798. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56799. * LayerMask is set through advancedTexture.layer.layerMask
  56800. * @param name defines name for the texture
  56801. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56802. * @param scene defines the hsoting scene
  56803. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56804. * @returns a new AdvancedDynamicTexture
  56805. */
  56806. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56807. }
  56808. }
  56809. declare module BABYLON.GUI {
  56810. /**
  56811. * Root class used for all 2D controls
  56812. * @see http://doc.babylonjs.com/how_to/gui#controls
  56813. */
  56814. export class Control {
  56815. /** defines the name of the control */
  56816. name?: string | undefined;
  56817. /**
  56818. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56819. */
  56820. static AllowAlphaInheritance: boolean;
  56821. private _alpha;
  56822. private _alphaSet;
  56823. private _zIndex;
  56824. /** @hidden */ host: AdvancedDynamicTexture;
  56825. /** Gets or sets the control parent */
  56826. parent: BABYLON.Nullable<Container>;
  56827. /** @hidden */ currentMeasure: Measure;
  56828. private _fontFamily;
  56829. private _fontStyle;
  56830. private _fontWeight;
  56831. private _fontSize;
  56832. private _font;
  56833. /** @hidden */ width: ValueAndUnit;
  56834. /** @hidden */ height: ValueAndUnit;
  56835. /** @hidden */
  56836. protected _fontOffset: {
  56837. ascent: number;
  56838. height: number;
  56839. descent: number;
  56840. };
  56841. private _color;
  56842. private _style;
  56843. private _styleObserver;
  56844. /** @hidden */
  56845. protected _horizontalAlignment: number;
  56846. /** @hidden */
  56847. protected _verticalAlignment: number;
  56848. /** @hidden */
  56849. protected _isDirty: boolean;
  56850. /** @hidden */
  56851. protected _wasDirty: boolean;
  56852. /** @hidden */ tempParentMeasure: Measure;
  56853. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56854. /** @hidden */
  56855. protected _cachedParentMeasure: Measure;
  56856. private _paddingLeft;
  56857. private _paddingRight;
  56858. private _paddingTop;
  56859. private _paddingBottom;
  56860. /** @hidden */ left: ValueAndUnit;
  56861. /** @hidden */ top: ValueAndUnit;
  56862. private _scaleX;
  56863. private _scaleY;
  56864. private _rotation;
  56865. private _transformCenterX;
  56866. private _transformCenterY;
  56867. /** @hidden */ transformMatrix: Matrix2D;
  56868. /** @hidden */
  56869. protected _invertTransformMatrix: Matrix2D;
  56870. /** @hidden */
  56871. protected _transformedPosition: BABYLON.Vector2;
  56872. private _isMatrixDirty;
  56873. private _cachedOffsetX;
  56874. private _cachedOffsetY;
  56875. private _isVisible;
  56876. private _isHighlighted;
  56877. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56878. private _fontSet;
  56879. private _dummyVector2;
  56880. private _downCount;
  56881. private _enterCount;
  56882. private _doNotRender;
  56883. private _downPointerIds;
  56884. protected _isEnabled: boolean;
  56885. protected _disabledColor: string;
  56886. /** @hidden */
  56887. protected _rebuildLayout: boolean;
  56888. /** @hidden */ isClipped: boolean;
  56889. /** @hidden */ tag: any;
  56890. /**
  56891. * 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
  56892. */
  56893. uniqueId: number;
  56894. /**
  56895. * Gets or sets an object used to store user defined information for the node
  56896. */
  56897. metadata: any;
  56898. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56899. isHitTestVisible: boolean;
  56900. /** Gets or sets a boolean indicating if the control can block pointer events */
  56901. isPointerBlocker: boolean;
  56902. /** Gets or sets a boolean indicating if the control can be focusable */
  56903. isFocusInvisible: boolean;
  56904. /**
  56905. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56906. * 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
  56907. */
  56908. clipChildren: boolean;
  56909. /**
  56910. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56911. */
  56912. useBitmapCache: boolean;
  56913. private _cacheData;
  56914. private _shadowOffsetX;
  56915. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56916. shadowOffsetX: number;
  56917. private _shadowOffsetY;
  56918. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56919. shadowOffsetY: number;
  56920. private _shadowBlur;
  56921. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56922. shadowBlur: number;
  56923. private _shadowColor;
  56924. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56925. shadowColor: string;
  56926. /** Gets or sets the cursor to use when the control is hovered */
  56927. hoverCursor: string;
  56928. /** @hidden */
  56929. protected _linkOffsetX: ValueAndUnit;
  56930. /** @hidden */
  56931. protected _linkOffsetY: ValueAndUnit;
  56932. /** Gets the control type name */
  56933. readonly typeName: string;
  56934. /**
  56935. * Get the current class name of the control.
  56936. * @returns current class name
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * An event triggered when the pointer move over the control.
  56941. */
  56942. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56943. /**
  56944. * An event triggered when the pointer move out of the control.
  56945. */
  56946. onPointerOutObservable: BABYLON.Observable<Control>;
  56947. /**
  56948. * An event triggered when the pointer taps the control
  56949. */
  56950. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56951. /**
  56952. * An event triggered when pointer up
  56953. */
  56954. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56955. /**
  56956. * An event triggered when a control is clicked on
  56957. */
  56958. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56959. /**
  56960. * An event triggered when pointer enters the control
  56961. */
  56962. onPointerEnterObservable: BABYLON.Observable<Control>;
  56963. /**
  56964. * An event triggered when the control is marked as dirty
  56965. */
  56966. onDirtyObservable: BABYLON.Observable<Control>;
  56967. /**
  56968. * An event triggered before drawing the control
  56969. */
  56970. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56971. /**
  56972. * An event triggered after the control was drawn
  56973. */
  56974. onAfterDrawObservable: BABYLON.Observable<Control>;
  56975. /**
  56976. * Get the hosting AdvancedDynamicTexture
  56977. */
  56978. readonly host: AdvancedDynamicTexture;
  56979. /** Gets or set information about font offsets (used to render and align text) */
  56980. fontOffset: {
  56981. ascent: number;
  56982. height: number;
  56983. descent: number;
  56984. };
  56985. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56986. alpha: number;
  56987. /**
  56988. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56989. */
  56990. isHighlighted: boolean;
  56991. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56992. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56993. */
  56994. scaleX: number;
  56995. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56996. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56997. */
  56998. scaleY: number;
  56999. /** Gets or sets the rotation angle (0 by default)
  57000. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57001. */
  57002. rotation: number;
  57003. /** Gets or sets the transformation center on Y axis (0 by default)
  57004. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57005. */
  57006. transformCenterY: number;
  57007. /** Gets or sets the transformation center on X axis (0 by default)
  57008. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57009. */
  57010. transformCenterX: number;
  57011. /**
  57012. * Gets or sets the horizontal alignment
  57013. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57014. */
  57015. horizontalAlignment: number;
  57016. /**
  57017. * Gets or sets the vertical alignment
  57018. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57019. */
  57020. verticalAlignment: number;
  57021. /**
  57022. * Gets or sets control width
  57023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57024. */
  57025. width: string | number;
  57026. /**
  57027. * Gets control width in pixel
  57028. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57029. */
  57030. readonly widthInPixels: number;
  57031. /**
  57032. * Gets or sets control height
  57033. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57034. */
  57035. height: string | number;
  57036. /**
  57037. * Gets control height in pixel
  57038. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57039. */
  57040. readonly heightInPixels: number;
  57041. /** Gets or set font family */
  57042. fontFamily: string;
  57043. /** Gets or sets font style */
  57044. fontStyle: string;
  57045. /** Gets or sets font weight */
  57046. fontWeight: string;
  57047. /**
  57048. * Gets or sets style
  57049. * @see http://doc.babylonjs.com/how_to/gui#styles
  57050. */
  57051. style: BABYLON.Nullable<Style>;
  57052. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  57053. /** Gets font size in pixels */
  57054. readonly fontSizeInPixels: number;
  57055. /** Gets or sets font size */
  57056. fontSize: string | number;
  57057. /** Gets or sets foreground color */
  57058. color: string;
  57059. /** Gets or sets z index which is used to reorder controls on the z axis */
  57060. zIndex: number;
  57061. /** Gets or sets a boolean indicating if the control can be rendered */
  57062. notRenderable: boolean;
  57063. /** Gets or sets a boolean indicating if the control is visible */
  57064. isVisible: boolean;
  57065. /** Gets a boolean indicating that the control needs to update its rendering */
  57066. readonly isDirty: boolean;
  57067. /**
  57068. * Gets the current linked mesh (or null if none)
  57069. */
  57070. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57071. /**
  57072. * Gets or sets a value indicating the padding to use on the left of the control
  57073. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57074. */
  57075. paddingLeft: string | number;
  57076. /**
  57077. * Gets a value indicating the padding in pixels to use on the left of the control
  57078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57079. */
  57080. readonly paddingLeftInPixels: number;
  57081. /**
  57082. * Gets or sets a value indicating the padding to use on the right of the control
  57083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57084. */
  57085. paddingRight: string | number;
  57086. /**
  57087. * Gets a value indicating the padding in pixels to use on the right of the control
  57088. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57089. */
  57090. readonly paddingRightInPixels: number;
  57091. /**
  57092. * Gets or sets a value indicating the padding to use on the top of the control
  57093. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57094. */
  57095. paddingTop: string | number;
  57096. /**
  57097. * Gets a value indicating the padding in pixels to use on the top of the control
  57098. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57099. */
  57100. readonly paddingTopInPixels: number;
  57101. /**
  57102. * Gets or sets a value indicating the padding to use on the bottom of the control
  57103. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57104. */
  57105. paddingBottom: string | number;
  57106. /**
  57107. * Gets a value indicating the padding in pixels to use on the bottom of the control
  57108. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57109. */
  57110. readonly paddingBottomInPixels: number;
  57111. /**
  57112. * Gets or sets a value indicating the left coordinate of the control
  57113. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57114. */
  57115. left: string | number;
  57116. /**
  57117. * Gets a value indicating the left coordinate in pixels of the control
  57118. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57119. */
  57120. readonly leftInPixels: number;
  57121. /**
  57122. * Gets or sets a value indicating the top coordinate of the control
  57123. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57124. */
  57125. top: string | number;
  57126. /**
  57127. * Gets a value indicating the top coordinate in pixels of the control
  57128. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57129. */
  57130. readonly topInPixels: number;
  57131. /**
  57132. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57133. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57134. */
  57135. linkOffsetX: string | number;
  57136. /**
  57137. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57138. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57139. */
  57140. readonly linkOffsetXInPixels: number;
  57141. /**
  57142. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57143. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57144. */
  57145. linkOffsetY: string | number;
  57146. /**
  57147. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57148. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57149. */
  57150. readonly linkOffsetYInPixels: number;
  57151. /** Gets the center coordinate on X axis */
  57152. readonly centerX: number;
  57153. /** Gets the center coordinate on Y axis */
  57154. readonly centerY: number;
  57155. /** Gets or sets if control is Enabled*/
  57156. isEnabled: boolean;
  57157. /** Gets or sets background color of control if it's disabled*/
  57158. disabledColor: string;
  57159. /**
  57160. * Creates a new control
  57161. * @param name defines the name of the control
  57162. */
  57163. constructor(
  57164. /** defines the name of the control */
  57165. name?: string | undefined);
  57166. /** @hidden */
  57167. protected _getTypeName(): string;
  57168. /**
  57169. * Gets the first ascendant in the hierarchy of the given type
  57170. * @param className defines the required type
  57171. * @returns the ascendant or null if not found
  57172. */
  57173. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57174. /** @hidden */ resetFontCache(): void;
  57175. /**
  57176. * Determines if a container is an ascendant of the current control
  57177. * @param container defines the container to look for
  57178. * @returns true if the container is one of the ascendant of the control
  57179. */
  57180. isAscendant(container: Control): boolean;
  57181. /**
  57182. * Gets coordinates in local control space
  57183. * @param globalCoordinates defines the coordinates to transform
  57184. * @returns the new coordinates in local space
  57185. */
  57186. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57187. /**
  57188. * Gets coordinates in local control space
  57189. * @param globalCoordinates defines the coordinates to transform
  57190. * @param result defines the target vector2 where to store the result
  57191. * @returns the current control
  57192. */
  57193. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57194. /**
  57195. * Gets coordinates in parent local control space
  57196. * @param globalCoordinates defines the coordinates to transform
  57197. * @returns the new coordinates in parent local space
  57198. */
  57199. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57200. /**
  57201. * Move the current control to a vector3 position projected onto the screen.
  57202. * @param position defines the target position
  57203. * @param scene defines the hosting scene
  57204. */
  57205. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57206. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57207. /**
  57208. * Will return all controls that have this control as ascendant
  57209. * @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
  57210. * @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
  57211. * @return all child controls
  57212. */
  57213. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57214. /**
  57215. * Link current control with a target mesh
  57216. * @param mesh defines the mesh to link with
  57217. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57218. */
  57219. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57220. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57221. /** @hidden */ offsetLeft(offset: number): void;
  57222. /** @hidden */ offsetTop(offset: number): void;
  57223. /** @hidden */ markMatrixAsDirty(): void;
  57224. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57225. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57226. /** @hidden */
  57227. protected invalidateRect(): void;
  57228. /** @hidden */ markAsDirty(force?: boolean): void;
  57229. /** @hidden */ markAllAsDirty(): void;
  57230. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57231. /** @hidden */
  57232. protected _transform(context?: CanvasRenderingContext2D): void;
  57233. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57234. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57235. /** @hidden */
  57236. protected _applyStates(context: CanvasRenderingContext2D): void;
  57237. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57238. /** @hidden */
  57239. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57240. protected _evaluateClippingState(parentMeasure: Measure): void;
  57241. /** @hidden */ measure(): void;
  57242. /** @hidden */
  57243. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57244. /** @hidden */
  57245. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57246. /** @hidden */
  57247. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57248. /** @hidden */
  57249. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57250. private static _ClipMeasure;
  57251. private _tmpMeasureA;
  57252. private _clip;
  57253. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57254. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57255. /**
  57256. * Tests if a given coordinates belong to the current control
  57257. * @param x defines x coordinate to test
  57258. * @param y defines y coordinate to test
  57259. * @returns true if the coordinates are inside the control
  57260. */
  57261. contains(x: number, y: number): boolean;
  57262. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57263. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  57264. /** @hidden */ onPointerEnter(target: Control): boolean;
  57265. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57266. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57267. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57268. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57269. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57270. private _prepareFont;
  57271. /** Releases associated resources */
  57272. dispose(): void;
  57273. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57274. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57275. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57276. private static _VERTICAL_ALIGNMENT_TOP;
  57277. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57278. private static _VERTICAL_ALIGNMENT_CENTER;
  57279. /** HORIZONTAL_ALIGNMENT_LEFT */
  57280. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57281. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57282. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57283. /** HORIZONTAL_ALIGNMENT_CENTER */
  57284. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57285. /** VERTICAL_ALIGNMENT_TOP */
  57286. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57287. /** VERTICAL_ALIGNMENT_BOTTOM */
  57288. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57289. /** VERTICAL_ALIGNMENT_CENTER */
  57290. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57291. private static _FontHeightSizes;
  57292. /** @hidden */ private static _GetFontOffset(font: string): {
  57293. ascent: number;
  57294. height: number;
  57295. descent: number;
  57296. };
  57297. /**
  57298. * Creates a stack panel that can be used to render headers
  57299. * @param control defines the control to associate with the header
  57300. * @param text defines the text of the header
  57301. * @param size defines the size of the header
  57302. * @param options defines options used to configure the header
  57303. * @returns a new StackPanel
  57304. * @ignore
  57305. * @hidden
  57306. */
  57307. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57308. isHorizontal: boolean;
  57309. controlFirst: boolean;
  57310. }) => any;
  57311. /** @hidden */
  57312. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57313. }
  57314. }
  57315. declare module BABYLON.GUI {
  57316. /**
  57317. * Root class for 2D containers
  57318. * @see http://doc.babylonjs.com/how_to/gui#containers
  57319. */
  57320. export class Container extends Control {
  57321. name?: string | undefined;
  57322. /** @hidden */
  57323. protected _children: Control[];
  57324. /** @hidden */
  57325. protected _measureForChildren: Measure;
  57326. /** @hidden */
  57327. protected _background: string;
  57328. /** @hidden */
  57329. protected _adaptWidthToChildren: boolean;
  57330. /** @hidden */
  57331. protected _adaptHeightToChildren: boolean;
  57332. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57333. adaptHeightToChildren: boolean;
  57334. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57335. adaptWidthToChildren: boolean;
  57336. /** Gets or sets background color */
  57337. background: string;
  57338. /** Gets the list of children */
  57339. readonly children: Control[];
  57340. /**
  57341. * Creates a new Container
  57342. * @param name defines the name of the container
  57343. */
  57344. constructor(name?: string | undefined);
  57345. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57346. /**
  57347. * Gets a child using its name
  57348. * @param name defines the child name to look for
  57349. * @returns the child control if found
  57350. */
  57351. getChildByName(name: string): BABYLON.Nullable<Control>;
  57352. /**
  57353. * Gets a child using its type and its name
  57354. * @param name defines the child name to look for
  57355. * @param type defines the child type to look for
  57356. * @returns the child control if found
  57357. */
  57358. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57359. /**
  57360. * Search for a specific control in children
  57361. * @param control defines the control to look for
  57362. * @returns true if the control is in child list
  57363. */
  57364. containsControl(control: Control): boolean;
  57365. /**
  57366. * Adds a new control to the current container
  57367. * @param control defines the control to add
  57368. * @returns the current container
  57369. */
  57370. addControl(control: BABYLON.Nullable<Control>): Container;
  57371. /**
  57372. * Removes all controls from the current container
  57373. * @returns the current container
  57374. */
  57375. clearControls(): Container;
  57376. /**
  57377. * Removes a control from the current container
  57378. * @param control defines the control to remove
  57379. * @returns the current container
  57380. */
  57381. removeControl(control: Control): Container;
  57382. /** @hidden */ reOrderControl(control: Control): void;
  57383. /** @hidden */ offsetLeft(offset: number): void;
  57384. /** @hidden */ offsetTop(offset: number): void;
  57385. /** @hidden */ markAllAsDirty(): void;
  57386. /** @hidden */
  57387. protected _localDraw(context: CanvasRenderingContext2D): void;
  57388. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57389. /** @hidden */
  57390. protected _beforeLayout(): void;
  57391. /** @hidden */
  57392. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57393. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57394. protected _postMeasure(): void;
  57395. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57396. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57397. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57398. /** @hidden */
  57399. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57400. /** Releases associated resources */
  57401. dispose(): void;
  57402. }
  57403. }
  57404. declare module BABYLON.GUI {
  57405. /** Class used to create rectangle container */
  57406. export class Rectangle extends Container {
  57407. name?: string | undefined;
  57408. private _thickness;
  57409. private _cornerRadius;
  57410. /** Gets or sets border thickness */
  57411. thickness: number;
  57412. /** Gets or sets the corner radius angle */
  57413. cornerRadius: number;
  57414. /**
  57415. * Creates a new Rectangle
  57416. * @param name defines the control name
  57417. */
  57418. constructor(name?: string | undefined);
  57419. protected _getTypeName(): string;
  57420. protected _localDraw(context: CanvasRenderingContext2D): void;
  57421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57422. private _drawRoundedRect;
  57423. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57424. }
  57425. }
  57426. declare module BABYLON.GUI {
  57427. /**
  57428. * Enum that determines the text-wrapping mode to use.
  57429. */
  57430. export enum TextWrapping {
  57431. /**
  57432. * Clip the text when it's larger than Control.width; this is the default mode.
  57433. */
  57434. Clip = 0,
  57435. /**
  57436. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57437. */
  57438. WordWrap = 1,
  57439. /**
  57440. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57441. */
  57442. Ellipsis = 2
  57443. }
  57444. /**
  57445. * Class used to create text block control
  57446. */
  57447. export class TextBlock extends Control {
  57448. /**
  57449. * Defines the name of the control
  57450. */
  57451. name?: string | undefined;
  57452. private _text;
  57453. private _textWrapping;
  57454. private _textHorizontalAlignment;
  57455. private _textVerticalAlignment;
  57456. private _lines;
  57457. private _resizeToFit;
  57458. private _lineSpacing;
  57459. private _outlineWidth;
  57460. private _outlineColor;
  57461. /**
  57462. * An event triggered after the text is changed
  57463. */
  57464. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57465. /**
  57466. * An event triggered after the text was broken up into lines
  57467. */
  57468. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57469. /**
  57470. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57471. */
  57472. readonly lines: any[];
  57473. /**
  57474. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57475. */
  57476. /**
  57477. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57478. */
  57479. resizeToFit: boolean;
  57480. /**
  57481. * Gets or sets a boolean indicating if text must be wrapped
  57482. */
  57483. /**
  57484. * Gets or sets a boolean indicating if text must be wrapped
  57485. */
  57486. textWrapping: TextWrapping | boolean;
  57487. /**
  57488. * Gets or sets text to display
  57489. */
  57490. /**
  57491. * Gets or sets text to display
  57492. */
  57493. text: string;
  57494. /**
  57495. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57496. */
  57497. /**
  57498. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57499. */
  57500. textHorizontalAlignment: number;
  57501. /**
  57502. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57503. */
  57504. /**
  57505. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57506. */
  57507. textVerticalAlignment: number;
  57508. /**
  57509. * Gets or sets line spacing value
  57510. */
  57511. /**
  57512. * Gets or sets line spacing value
  57513. */
  57514. lineSpacing: string | number;
  57515. /**
  57516. * Gets or sets outlineWidth of the text to display
  57517. */
  57518. /**
  57519. * Gets or sets outlineWidth of the text to display
  57520. */
  57521. outlineWidth: number;
  57522. /**
  57523. * Gets or sets outlineColor of the text to display
  57524. */
  57525. /**
  57526. * Gets or sets outlineColor of the text to display
  57527. */
  57528. outlineColor: string;
  57529. /**
  57530. * Creates a new TextBlock object
  57531. * @param name defines the name of the control
  57532. * @param text defines the text to display (emptry string by default)
  57533. */
  57534. constructor(
  57535. /**
  57536. * Defines the name of the control
  57537. */
  57538. name?: string | undefined, text?: string);
  57539. protected _getTypeName(): string;
  57540. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57541. private _drawText;
  57542. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57543. protected _applyStates(context: CanvasRenderingContext2D): void;
  57544. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57545. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57546. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57547. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57548. protected _renderLines(context: CanvasRenderingContext2D): void;
  57549. /**
  57550. * Given a width constraint applied on the text block, find the expected height
  57551. * @returns expected height
  57552. */
  57553. computeExpectedHeight(): number;
  57554. dispose(): void;
  57555. }
  57556. }
  57557. declare module BABYLON.GUI {
  57558. /**
  57559. * Class used to create 2D images
  57560. */
  57561. export class Image extends Control {
  57562. name?: string | undefined;
  57563. private static _WorkingCanvas;
  57564. private _domImage;
  57565. private _imageWidth;
  57566. private _imageHeight;
  57567. private _loaded;
  57568. private _stretch;
  57569. private _source;
  57570. private _autoScale;
  57571. private _sourceLeft;
  57572. private _sourceTop;
  57573. private _sourceWidth;
  57574. private _sourceHeight;
  57575. private _cellWidth;
  57576. private _cellHeight;
  57577. private _cellId;
  57578. private _populateNinePatchSlicesFromImage;
  57579. private _sliceLeft;
  57580. private _sliceRight;
  57581. private _sliceTop;
  57582. private _sliceBottom;
  57583. private _detectPointerOnOpaqueOnly;
  57584. /**
  57585. * BABYLON.Observable notified when the content is loaded
  57586. */
  57587. onImageLoadedObservable: BABYLON.Observable<Image>;
  57588. /**
  57589. * Gets a boolean indicating that the content is loaded
  57590. */
  57591. readonly isLoaded: boolean;
  57592. /**
  57593. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57594. */
  57595. populateNinePatchSlicesFromImage: boolean;
  57596. /**
  57597. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57598. * Beware using this as this will comsume more memory as the image has to be stored twice
  57599. */
  57600. detectPointerOnOpaqueOnly: boolean;
  57601. /**
  57602. * Gets or sets the left value for slicing (9-patch)
  57603. */
  57604. sliceLeft: number;
  57605. /**
  57606. * Gets or sets the right value for slicing (9-patch)
  57607. */
  57608. sliceRight: number;
  57609. /**
  57610. * Gets or sets the top value for slicing (9-patch)
  57611. */
  57612. sliceTop: number;
  57613. /**
  57614. * Gets or sets the bottom value for slicing (9-patch)
  57615. */
  57616. sliceBottom: number;
  57617. /**
  57618. * Gets or sets the left coordinate in the source image
  57619. */
  57620. sourceLeft: number;
  57621. /**
  57622. * Gets or sets the top coordinate in the source image
  57623. */
  57624. sourceTop: number;
  57625. /**
  57626. * Gets or sets the width to capture in the source image
  57627. */
  57628. sourceWidth: number;
  57629. /**
  57630. * Gets or sets the height to capture in the source image
  57631. */
  57632. sourceHeight: number;
  57633. /**
  57634. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57635. * @see http://doc.babylonjs.com/how_to/gui#image
  57636. */
  57637. autoScale: boolean;
  57638. /** Gets or sets the streching mode used by the image */
  57639. stretch: number;
  57640. /**
  57641. * Gets or sets the internal DOM image used to render the control
  57642. */
  57643. domImage: HTMLImageElement;
  57644. private _onImageLoaded;
  57645. private _extractNinePatchSliceDataFromImage;
  57646. /**
  57647. * Gets or sets image source url
  57648. */
  57649. source: BABYLON.Nullable<string>;
  57650. /**
  57651. * Gets or sets the cell width to use when animation sheet is enabled
  57652. * @see http://doc.babylonjs.com/how_to/gui#image
  57653. */
  57654. cellWidth: number;
  57655. /**
  57656. * Gets or sets the cell height to use when animation sheet is enabled
  57657. * @see http://doc.babylonjs.com/how_to/gui#image
  57658. */
  57659. cellHeight: number;
  57660. /**
  57661. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57662. * @see http://doc.babylonjs.com/how_to/gui#image
  57663. */
  57664. cellId: number;
  57665. /**
  57666. * Creates a new Image
  57667. * @param name defines the control name
  57668. * @param url defines the image url
  57669. */
  57670. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57671. /**
  57672. * Tests if a given coordinates belong to the current control
  57673. * @param x defines x coordinate to test
  57674. * @param y defines y coordinate to test
  57675. * @returns true if the coordinates are inside the control
  57676. */
  57677. contains(x: number, y: number): boolean;
  57678. protected _getTypeName(): string;
  57679. /** Force the control to synchronize with its content */
  57680. synchronizeSizeWithContent(): void;
  57681. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57682. private _prepareWorkingCanvasForOpaqueDetection;
  57683. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57684. private _renderCornerPatch;
  57685. private _renderNinePatch;
  57686. dispose(): void;
  57687. /** STRETCH_NONE */
  57688. static readonly STRETCH_NONE: number;
  57689. /** STRETCH_FILL */
  57690. static readonly STRETCH_FILL: number;
  57691. /** STRETCH_UNIFORM */
  57692. static readonly STRETCH_UNIFORM: number;
  57693. /** STRETCH_EXTEND */
  57694. static readonly STRETCH_EXTEND: number;
  57695. /** NINE_PATCH */
  57696. static readonly STRETCH_NINE_PATCH: number;
  57697. }
  57698. }
  57699. declare module BABYLON.GUI {
  57700. /**
  57701. * Class used to create 2D buttons
  57702. */
  57703. export class Button extends Rectangle {
  57704. name?: string | undefined;
  57705. /**
  57706. * Function called to generate a pointer enter animation
  57707. */
  57708. pointerEnterAnimation: () => void;
  57709. /**
  57710. * Function called to generate a pointer out animation
  57711. */
  57712. pointerOutAnimation: () => void;
  57713. /**
  57714. * Function called to generate a pointer down animation
  57715. */
  57716. pointerDownAnimation: () => void;
  57717. /**
  57718. * Function called to generate a pointer up animation
  57719. */
  57720. pointerUpAnimation: () => void;
  57721. private _image;
  57722. /**
  57723. * Returns the image part of the button (if any)
  57724. */
  57725. readonly image: BABYLON.Nullable<Image>;
  57726. private _textBlock;
  57727. /**
  57728. * Returns the image part of the button (if any)
  57729. */
  57730. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57731. /**
  57732. * Creates a new Button
  57733. * @param name defines the name of the button
  57734. */
  57735. constructor(name?: string | undefined);
  57736. protected _getTypeName(): string;
  57737. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57738. /** @hidden */ onPointerEnter(target: Control): boolean;
  57739. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57740. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57741. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57742. /**
  57743. * Creates a new button made with an image and a text
  57744. * @param name defines the name of the button
  57745. * @param text defines the text of the button
  57746. * @param imageUrl defines the url of the image
  57747. * @returns a new Button
  57748. */
  57749. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57750. /**
  57751. * Creates a new button made with an image
  57752. * @param name defines the name of the button
  57753. * @param imageUrl defines the url of the image
  57754. * @returns a new Button
  57755. */
  57756. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57757. /**
  57758. * Creates a new button made with a text
  57759. * @param name defines the name of the button
  57760. * @param text defines the text of the button
  57761. * @returns a new Button
  57762. */
  57763. static CreateSimpleButton(name: string, text: string): Button;
  57764. /**
  57765. * Creates a new button made with an image and a centered text
  57766. * @param name defines the name of the button
  57767. * @param text defines the text of the button
  57768. * @param imageUrl defines the url of the image
  57769. * @returns a new Button
  57770. */
  57771. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57772. }
  57773. }
  57774. declare module BABYLON.GUI {
  57775. /**
  57776. * Class used to create a 2D stack panel container
  57777. */
  57778. export class StackPanel extends Container {
  57779. name?: string | undefined;
  57780. private _isVertical;
  57781. private _manualWidth;
  57782. private _manualHeight;
  57783. private _doNotTrackManualChanges;
  57784. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57785. isVertical: boolean;
  57786. /**
  57787. * Gets or sets panel width.
  57788. * This value should not be set when in horizontal mode as it will be computed automatically
  57789. */
  57790. width: string | number;
  57791. /**
  57792. * Gets or sets panel height.
  57793. * This value should not be set when in vertical mode as it will be computed automatically
  57794. */
  57795. height: string | number;
  57796. /**
  57797. * Creates a new StackPanel
  57798. * @param name defines control name
  57799. */
  57800. constructor(name?: string | undefined);
  57801. protected _getTypeName(): string;
  57802. /** @hidden */
  57803. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57804. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57805. protected _postMeasure(): void;
  57806. }
  57807. }
  57808. declare module BABYLON.GUI {
  57809. /**
  57810. * Class used to represent a 2D checkbox
  57811. */
  57812. export class Checkbox extends Control {
  57813. name?: string | undefined;
  57814. private _isChecked;
  57815. private _background;
  57816. private _checkSizeRatio;
  57817. private _thickness;
  57818. /** Gets or sets border thickness */
  57819. thickness: number;
  57820. /**
  57821. * BABYLON.Observable raised when isChecked property changes
  57822. */
  57823. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57824. /** Gets or sets a value indicating the ratio between overall size and check size */
  57825. checkSizeRatio: number;
  57826. /** Gets or sets background color */
  57827. background: string;
  57828. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57829. isChecked: boolean;
  57830. /**
  57831. * Creates a new CheckBox
  57832. * @param name defines the control name
  57833. */
  57834. constructor(name?: string | undefined);
  57835. protected _getTypeName(): string;
  57836. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57837. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57838. /**
  57839. * Utility function to easily create a checkbox with a header
  57840. * @param title defines the label to use for the header
  57841. * @param onValueChanged defines the callback to call when value changes
  57842. * @returns a StackPanel containing the checkbox and a textBlock
  57843. */
  57844. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57845. }
  57846. }
  57847. declare module BABYLON.GUI {
  57848. /**
  57849. * Class used to store key control properties
  57850. */
  57851. export class KeyPropertySet {
  57852. /** Width */
  57853. width?: string;
  57854. /** Height */
  57855. height?: string;
  57856. /** Left padding */
  57857. paddingLeft?: string;
  57858. /** Right padding */
  57859. paddingRight?: string;
  57860. /** Top padding */
  57861. paddingTop?: string;
  57862. /** Bottom padding */
  57863. paddingBottom?: string;
  57864. /** Foreground color */
  57865. color?: string;
  57866. /** Background color */
  57867. background?: string;
  57868. }
  57869. /**
  57870. * Class used to create virtual keyboard
  57871. */
  57872. export class VirtualKeyboard extends StackPanel {
  57873. /** BABYLON.Observable raised when a key is pressed */
  57874. onKeyPressObservable: BABYLON.Observable<string>;
  57875. /** Gets or sets default key button width */
  57876. defaultButtonWidth: string;
  57877. /** Gets or sets default key button height */
  57878. defaultButtonHeight: string;
  57879. /** Gets or sets default key button left padding */
  57880. defaultButtonPaddingLeft: string;
  57881. /** Gets or sets default key button right padding */
  57882. defaultButtonPaddingRight: string;
  57883. /** Gets or sets default key button top padding */
  57884. defaultButtonPaddingTop: string;
  57885. /** Gets or sets default key button bottom padding */
  57886. defaultButtonPaddingBottom: string;
  57887. /** Gets or sets default key button foreground color */
  57888. defaultButtonColor: string;
  57889. /** Gets or sets default key button background color */
  57890. defaultButtonBackground: string;
  57891. /** Gets or sets shift button foreground color */
  57892. shiftButtonColor: string;
  57893. /** Gets or sets shift button thickness*/
  57894. selectedShiftThickness: number;
  57895. /** Gets shift key state */
  57896. shiftState: number;
  57897. protected _getTypeName(): string;
  57898. private _createKey;
  57899. /**
  57900. * Adds a new row of keys
  57901. * @param keys defines the list of keys to add
  57902. * @param propertySets defines the associated property sets
  57903. */
  57904. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57905. /**
  57906. * Set the shift key to a specific state
  57907. * @param shiftState defines the new shift state
  57908. */
  57909. applyShiftState(shiftState: number): void;
  57910. private _currentlyConnectedInputText;
  57911. private _connectedInputTexts;
  57912. private _onKeyPressObserver;
  57913. /** Gets the input text control currently attached to the keyboard */
  57914. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57915. /**
  57916. * Connects the keyboard with an input text control
  57917. *
  57918. * @param input defines the target control
  57919. */
  57920. connect(input: InputText): void;
  57921. /**
  57922. * Disconnects the keyboard from connected InputText controls
  57923. *
  57924. * @param input optionally defines a target control, otherwise all are disconnected
  57925. */
  57926. disconnect(input?: InputText): void;
  57927. private _removeConnectedInputObservables;
  57928. /**
  57929. * Release all resources
  57930. */
  57931. dispose(): void;
  57932. /**
  57933. * Creates a new keyboard using a default layout
  57934. *
  57935. * @param name defines control name
  57936. * @returns a new VirtualKeyboard
  57937. */
  57938. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57939. }
  57940. }
  57941. declare module BABYLON.GUI {
  57942. /**
  57943. * Class used to create input text control
  57944. */
  57945. export class InputText extends Control implements IFocusableControl {
  57946. name?: string | undefined;
  57947. private _text;
  57948. private _placeholderText;
  57949. private _background;
  57950. private _focusedBackground;
  57951. private _focusedColor;
  57952. private _placeholderColor;
  57953. private _thickness;
  57954. private _margin;
  57955. private _autoStretchWidth;
  57956. private _maxWidth;
  57957. private _isFocused;
  57958. private _blinkTimeout;
  57959. private _blinkIsEven;
  57960. private _cursorOffset;
  57961. private _scrollLeft;
  57962. private _textWidth;
  57963. private _clickedCoordinate;
  57964. private _deadKey;
  57965. private _addKey;
  57966. private _currentKey;
  57967. private _isTextHighlightOn;
  57968. private _textHighlightColor;
  57969. private _highligherOpacity;
  57970. private _highlightedText;
  57971. private _startHighlightIndex;
  57972. private _endHighlightIndex;
  57973. private _cursorIndex;
  57974. private _onFocusSelectAll;
  57975. private _isPointerDown;
  57976. private _onClipboardObserver;
  57977. private _onPointerDblTapObserver;
  57978. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57979. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57980. promptMessage: string;
  57981. /** BABYLON.Observable raised when the text changes */
  57982. onTextChangedObservable: BABYLON.Observable<InputText>;
  57983. /** BABYLON.Observable raised just before an entered character is to be added */
  57984. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57985. /** BABYLON.Observable raised when the control gets the focus */
  57986. onFocusObservable: BABYLON.Observable<InputText>;
  57987. /** BABYLON.Observable raised when the control loses the focus */
  57988. onBlurObservable: BABYLON.Observable<InputText>;
  57989. /**Observable raised when the text is highlighted */
  57990. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57991. /**Observable raised when copy event is triggered */
  57992. onTextCopyObservable: BABYLON.Observable<InputText>;
  57993. /** BABYLON.Observable raised when cut event is triggered */
  57994. onTextCutObservable: BABYLON.Observable<InputText>;
  57995. /** BABYLON.Observable raised when paste event is triggered */
  57996. onTextPasteObservable: BABYLON.Observable<InputText>;
  57997. /** BABYLON.Observable raised when a key event was processed */
  57998. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57999. /** Gets or sets the maximum width allowed by the control */
  58000. maxWidth: string | number;
  58001. /** Gets the maximum width allowed by the control in pixels */
  58002. readonly maxWidthInPixels: number;
  58003. /** Gets or sets the text highlighter transparency; default: 0.4 */
  58004. highligherOpacity: number;
  58005. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  58006. onFocusSelectAll: boolean;
  58007. /** Gets or sets the text hightlight color */
  58008. textHighlightColor: string;
  58009. /** Gets or sets control margin */
  58010. margin: string;
  58011. /** Gets control margin in pixels */
  58012. readonly marginInPixels: number;
  58013. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  58014. autoStretchWidth: boolean;
  58015. /** Gets or sets border thickness */
  58016. thickness: number;
  58017. /** Gets or sets the background color when focused */
  58018. focusedBackground: string;
  58019. /** Gets or sets the background color when focused */
  58020. focusedColor: string;
  58021. /** Gets or sets the background color */
  58022. background: string;
  58023. /** Gets or sets the placeholder color */
  58024. placeholderColor: string;
  58025. /** Gets or sets the text displayed when the control is empty */
  58026. placeholderText: string;
  58027. /** Gets or sets the dead key flag */
  58028. deadKey: boolean;
  58029. /** Gets or sets the highlight text */
  58030. highlightedText: string;
  58031. /** Gets or sets if the current key should be added */
  58032. addKey: boolean;
  58033. /** Gets or sets the value of the current key being entered */
  58034. currentKey: string;
  58035. /** Gets or sets the text displayed in the control */
  58036. text: string;
  58037. /** Gets or sets control width */
  58038. width: string | number;
  58039. /**
  58040. * Creates a new InputText
  58041. * @param name defines the control name
  58042. * @param text defines the text of the control
  58043. */
  58044. constructor(name?: string | undefined, text?: string);
  58045. /** @hidden */
  58046. onBlur(): void;
  58047. /** @hidden */
  58048. onFocus(): void;
  58049. protected _getTypeName(): string;
  58050. /**
  58051. * Function called to get the list of controls that should not steal the focus from this control
  58052. * @returns an array of controls
  58053. */
  58054. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58055. /** @hidden */
  58056. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  58057. /** @hidden */
  58058. private _updateValueFromCursorIndex;
  58059. /** @hidden */
  58060. private _processDblClick;
  58061. /** @hidden */
  58062. private _selectAllText;
  58063. /**
  58064. * Handles the keyboard event
  58065. * @param evt Defines the KeyboardEvent
  58066. */
  58067. processKeyboard(evt: KeyboardEvent): void;
  58068. /** @hidden */
  58069. private _onCopyText;
  58070. /** @hidden */
  58071. private _onCutText;
  58072. /** @hidden */
  58073. 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;
  58074. protected _beforeRenderText(text: string): string;
  58075. dispose(): void;
  58076. }
  58077. }
  58078. declare module BABYLON.GUI {
  58079. /**
  58080. * Class used to create a 2D grid container
  58081. */
  58082. export class Grid extends Container {
  58083. name?: string | undefined;
  58084. private _rowDefinitions;
  58085. private _columnDefinitions;
  58086. private _cells;
  58087. private _childControls;
  58088. /**
  58089. * Gets the number of columns
  58090. */
  58091. readonly columnCount: number;
  58092. /**
  58093. * Gets the number of rows
  58094. */
  58095. readonly rowCount: number;
  58096. /** Gets the list of children */
  58097. readonly children: Control[];
  58098. /**
  58099. * Gets the definition of a specific row
  58100. * @param index defines the index of the row
  58101. * @returns the row definition
  58102. */
  58103. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58104. /**
  58105. * Gets the definition of a specific column
  58106. * @param index defines the index of the column
  58107. * @returns the column definition
  58108. */
  58109. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58110. /**
  58111. * Adds a new row to the grid
  58112. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58113. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58114. * @returns the current grid
  58115. */
  58116. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58117. /**
  58118. * Adds a new column to the grid
  58119. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58120. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58121. * @returns the current grid
  58122. */
  58123. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58124. /**
  58125. * Update a row definition
  58126. * @param index defines the index of the row to update
  58127. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58128. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58129. * @returns the current grid
  58130. */
  58131. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58132. /**
  58133. * Update a column definition
  58134. * @param index defines the index of the column to update
  58135. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58136. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58137. * @returns the current grid
  58138. */
  58139. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58140. /**
  58141. * Gets the list of children stored in a specific cell
  58142. * @param row defines the row to check
  58143. * @param column defines the column to check
  58144. * @returns the list of controls
  58145. */
  58146. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58147. /**
  58148. * Gets a string representing the child cell info (row x column)
  58149. * @param child defines the control to get info from
  58150. * @returns a string containing the child cell info (row x column)
  58151. */
  58152. getChildCellInfo(child: Control): string;
  58153. private _removeCell;
  58154. private _offsetCell;
  58155. /**
  58156. * Remove a column definition at specified index
  58157. * @param index defines the index of the column to remove
  58158. * @returns the current grid
  58159. */
  58160. removeColumnDefinition(index: number): Grid;
  58161. /**
  58162. * Remove a row definition at specified index
  58163. * @param index defines the index of the row to remove
  58164. * @returns the current grid
  58165. */
  58166. removeRowDefinition(index: number): Grid;
  58167. /**
  58168. * Adds a new control to the current grid
  58169. * @param control defines the control to add
  58170. * @param row defines the row where to add the control (0 by default)
  58171. * @param column defines the column where to add the control (0 by default)
  58172. * @returns the current grid
  58173. */
  58174. addControl(control: Control, row?: number, column?: number): Grid;
  58175. /**
  58176. * Removes a control from the current container
  58177. * @param control defines the control to remove
  58178. * @returns the current container
  58179. */
  58180. removeControl(control: Control): Container;
  58181. /**
  58182. * Creates a new Grid
  58183. * @param name defines control name
  58184. */
  58185. constructor(name?: string | undefined);
  58186. protected _getTypeName(): string;
  58187. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58188. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58189. /** Releases associated resources */
  58190. dispose(): void;
  58191. }
  58192. }
  58193. declare module BABYLON.GUI {
  58194. /** Class used to create color pickers */
  58195. export class ColorPicker extends Control {
  58196. name?: string | undefined;
  58197. private static _Epsilon;
  58198. private _colorWheelCanvas;
  58199. private _value;
  58200. private _tmpColor;
  58201. private _pointerStartedOnSquare;
  58202. private _pointerStartedOnWheel;
  58203. private _squareLeft;
  58204. private _squareTop;
  58205. private _squareSize;
  58206. private _h;
  58207. private _s;
  58208. private _v;
  58209. /**
  58210. * BABYLON.Observable raised when the value changes
  58211. */
  58212. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58213. /** Gets or sets the color of the color picker */
  58214. value: BABYLON.Color3;
  58215. /**
  58216. * Gets or sets control width
  58217. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58218. */
  58219. width: string | number;
  58220. /**
  58221. * Gets or sets control height
  58222. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58223. */
  58224. /** Gets or sets control height */
  58225. height: string | number;
  58226. /** Gets or sets control size */
  58227. size: string | number;
  58228. /**
  58229. * Creates a new ColorPicker
  58230. * @param name defines the control name
  58231. */
  58232. constructor(name?: string | undefined);
  58233. protected _getTypeName(): string;
  58234. /** @hidden */
  58235. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58236. private _updateSquareProps;
  58237. private _drawGradientSquare;
  58238. private _drawCircle;
  58239. private _createColorWheelCanvas;
  58240. private _RGBtoHSV;
  58241. private _HSVtoRGB;
  58242. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58243. private _pointerIsDown;
  58244. private _updateValueFromPointer;
  58245. private _isPointOnSquare;
  58246. 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;
  58247. /**
  58248. * This function expands the color picker by creating a color picker dialog with manual
  58249. * color value input and the ability to save colors into an array to be used later in
  58250. * subsequent launches of the dialogue.
  58251. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58252. * @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.
  58253. * @returns picked color as a hex string and the saved colors array as hex strings.
  58254. */
  58255. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58256. pickerWidth?: string;
  58257. pickerHeight?: string;
  58258. headerHeight?: string;
  58259. lastColor?: string;
  58260. swatchLimit?: number;
  58261. numSwatchesPerLine?: number;
  58262. savedColors?: Array<string>;
  58263. }): Promise<{
  58264. savedColors?: string[];
  58265. pickedColor: string;
  58266. }>;
  58267. }
  58268. }
  58269. declare module BABYLON.GUI {
  58270. /** Class used to create 2D ellipse containers */
  58271. export class Ellipse extends Container {
  58272. name?: string | undefined;
  58273. private _thickness;
  58274. /** Gets or sets border thickness */
  58275. thickness: number;
  58276. /**
  58277. * Creates a new Ellipse
  58278. * @param name defines the control name
  58279. */
  58280. constructor(name?: string | undefined);
  58281. protected _getTypeName(): string;
  58282. protected _localDraw(context: CanvasRenderingContext2D): void;
  58283. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58284. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58285. }
  58286. }
  58287. declare module BABYLON.GUI {
  58288. /**
  58289. * Class used to create a password control
  58290. */
  58291. export class InputPassword extends InputText {
  58292. protected _beforeRenderText(text: string): string;
  58293. }
  58294. }
  58295. declare module BABYLON.GUI {
  58296. /** Class used to render 2D lines */
  58297. export class Line extends Control {
  58298. name?: string | undefined;
  58299. private _lineWidth;
  58300. private _x1;
  58301. private _y1;
  58302. private _x2;
  58303. private _y2;
  58304. private _dash;
  58305. private _connectedControl;
  58306. private _connectedControlDirtyObserver;
  58307. /** Gets or sets the dash pattern */
  58308. dash: Array<number>;
  58309. /** Gets or sets the control connected with the line end */
  58310. connectedControl: Control;
  58311. /** Gets or sets start coordinates on X axis */
  58312. x1: string | number;
  58313. /** Gets or sets start coordinates on Y axis */
  58314. y1: string | number;
  58315. /** Gets or sets end coordinates on X axis */
  58316. x2: string | number;
  58317. /** Gets or sets end coordinates on Y axis */
  58318. y2: string | number;
  58319. /** Gets or sets line width */
  58320. lineWidth: number;
  58321. /** Gets or sets horizontal alignment */
  58322. horizontalAlignment: number;
  58323. /** Gets or sets vertical alignment */
  58324. verticalAlignment: number;
  58325. private readonly _effectiveX2;
  58326. private readonly _effectiveY2;
  58327. /**
  58328. * Creates a new Line
  58329. * @param name defines the control name
  58330. */
  58331. constructor(name?: string | undefined);
  58332. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58333. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58334. /**
  58335. * Move one end of the line given 3D cartesian coordinates.
  58336. * @param position Targeted world position
  58337. * @param scene BABYLON.Scene
  58338. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58339. */
  58340. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58341. /**
  58342. * Move one end of the line to a position in screen absolute space.
  58343. * @param projectedPosition Position in screen absolute space (X, Y)
  58344. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58345. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58346. }
  58347. }
  58348. declare module BABYLON.GUI {
  58349. /**
  58350. * Class used to store a point for a MultiLine object.
  58351. * The point can be pure 2D coordinates, a mesh or a control
  58352. */
  58353. export class MultiLinePoint {
  58354. private _multiLine;
  58355. private _x;
  58356. private _y;
  58357. private _control;
  58358. private _mesh;
  58359. private _controlObserver;
  58360. private _meshObserver;
  58361. /** @hidden */ point: BABYLON.Vector2;
  58362. /**
  58363. * Creates a new MultiLinePoint
  58364. * @param multiLine defines the source MultiLine object
  58365. */
  58366. constructor(multiLine: MultiLine);
  58367. /** Gets or sets x coordinate */
  58368. x: string | number;
  58369. /** Gets or sets y coordinate */
  58370. y: string | number;
  58371. /** Gets or sets the control associated with this point */
  58372. control: BABYLON.Nullable<Control>;
  58373. /** Gets or sets the mesh associated with this point */
  58374. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58375. /** Resets links */
  58376. resetLinks(): void;
  58377. /**
  58378. * Gets a translation vector
  58379. * @returns the translation vector
  58380. */
  58381. translate(): BABYLON.Vector2;
  58382. private _translatePoint;
  58383. /** Release associated resources */
  58384. dispose(): void;
  58385. }
  58386. }
  58387. declare module BABYLON.GUI {
  58388. /**
  58389. * Class used to create multi line control
  58390. */
  58391. export class MultiLine extends Control {
  58392. name?: string | undefined;
  58393. private _lineWidth;
  58394. private _dash;
  58395. private _points;
  58396. private _minX;
  58397. private _minY;
  58398. private _maxX;
  58399. private _maxY;
  58400. /**
  58401. * Creates a new MultiLine
  58402. * @param name defines the control name
  58403. */
  58404. constructor(name?: string | undefined);
  58405. /** Gets or sets dash pattern */
  58406. dash: Array<number>;
  58407. /**
  58408. * Gets point stored at specified index
  58409. * @param index defines the index to look for
  58410. * @returns the requested point if found
  58411. */
  58412. getAt(index: number): MultiLinePoint;
  58413. /** Function called when a point is updated */
  58414. onPointUpdate: () => void;
  58415. /**
  58416. * Adds new points to the point collection
  58417. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58418. * @returns the list of created MultiLinePoint
  58419. */
  58420. add(...items: (AbstractMesh | Control | {
  58421. x: string | number;
  58422. y: string | number;
  58423. })[]): MultiLinePoint[];
  58424. /**
  58425. * Adds a new point to the point collection
  58426. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58427. * @returns the created MultiLinePoint
  58428. */
  58429. push(item?: (AbstractMesh | Control | {
  58430. x: string | number;
  58431. y: string | number;
  58432. })): MultiLinePoint;
  58433. /**
  58434. * Remove a specific value or point from the active point collection
  58435. * @param value defines the value or point to remove
  58436. */
  58437. remove(value: number | MultiLinePoint): void;
  58438. /**
  58439. * Resets this object to initial state (no point)
  58440. */
  58441. reset(): void;
  58442. /**
  58443. * Resets all links
  58444. */
  58445. resetLinks(): void;
  58446. /** Gets or sets line width */
  58447. lineWidth: number;
  58448. horizontalAlignment: number;
  58449. verticalAlignment: number;
  58450. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58452. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58453. dispose(): void;
  58454. }
  58455. }
  58456. declare module BABYLON.GUI {
  58457. /**
  58458. * Class used to create radio button controls
  58459. */
  58460. export class RadioButton extends Control {
  58461. name?: string | undefined;
  58462. private _isChecked;
  58463. private _background;
  58464. private _checkSizeRatio;
  58465. private _thickness;
  58466. /** Gets or sets border thickness */
  58467. thickness: number;
  58468. /** Gets or sets group name */
  58469. group: string;
  58470. /** BABYLON.Observable raised when isChecked is changed */
  58471. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58472. /** Gets or sets a value indicating the ratio between overall size and check size */
  58473. checkSizeRatio: number;
  58474. /** Gets or sets background color */
  58475. background: string;
  58476. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58477. isChecked: boolean;
  58478. /**
  58479. * Creates a new RadioButton
  58480. * @param name defines the control name
  58481. */
  58482. constructor(name?: string | undefined);
  58483. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58484. /**
  58485. * Utility function to easily create a radio button with a header
  58486. * @param title defines the label to use for the header
  58487. * @param group defines the group to use for the radio button
  58488. * @param isChecked defines the initial state of the radio button
  58489. * @param onValueChanged defines the callback to call when value changes
  58490. * @returns a StackPanel containing the radio button and a textBlock
  58491. */
  58492. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58493. }
  58494. }
  58495. declare module BABYLON.GUI {
  58496. /**
  58497. * Class used to create slider controls
  58498. */
  58499. export class BaseSlider extends Control {
  58500. name?: string | undefined;
  58501. protected _thumbWidth: ValueAndUnit;
  58502. private _minimum;
  58503. private _maximum;
  58504. private _value;
  58505. private _isVertical;
  58506. protected _barOffset: ValueAndUnit;
  58507. private _isThumbClamped;
  58508. protected _displayThumb: boolean;
  58509. private _step;
  58510. protected _effectiveBarOffset: number;
  58511. protected _renderLeft: number;
  58512. protected _renderTop: number;
  58513. protected _renderWidth: number;
  58514. protected _renderHeight: number;
  58515. protected _backgroundBoxLength: number;
  58516. protected _backgroundBoxThickness: number;
  58517. protected _effectiveThumbThickness: number;
  58518. /** BABYLON.Observable raised when the sldier value changes */
  58519. onValueChangedObservable: BABYLON.Observable<number>;
  58520. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58521. displayThumb: boolean;
  58522. /** Gets or sets a step to apply to values (0 by default) */
  58523. step: number;
  58524. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58525. barOffset: string | number;
  58526. /** Gets main bar offset in pixels*/
  58527. readonly barOffsetInPixels: number;
  58528. /** Gets or sets thumb width */
  58529. thumbWidth: string | number;
  58530. /** Gets thumb width in pixels */
  58531. readonly thumbWidthInPixels: number;
  58532. /** Gets or sets minimum value */
  58533. minimum: number;
  58534. /** Gets or sets maximum value */
  58535. maximum: number;
  58536. /** Gets or sets current value */
  58537. value: number;
  58538. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58539. isVertical: boolean;
  58540. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58541. isThumbClamped: boolean;
  58542. /**
  58543. * Creates a new BaseSlider
  58544. * @param name defines the control name
  58545. */
  58546. constructor(name?: string | undefined);
  58547. protected _getTypeName(): string;
  58548. protected _getThumbPosition(): number;
  58549. protected _getThumbThickness(type: string): number;
  58550. protected _prepareRenderingData(type: string): void;
  58551. private _pointerIsDown;
  58552. /** @hidden */
  58553. 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;
  58554. }
  58555. }
  58556. declare module BABYLON.GUI {
  58557. /**
  58558. * Class used to create slider controls
  58559. */
  58560. export class Slider extends BaseSlider {
  58561. name?: string | undefined;
  58562. private _background;
  58563. private _borderColor;
  58564. private _isThumbCircle;
  58565. protected _displayValueBar: boolean;
  58566. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58567. displayValueBar: boolean;
  58568. /** Gets or sets border color */
  58569. borderColor: string;
  58570. /** Gets or sets background color */
  58571. background: string;
  58572. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58573. isThumbCircle: boolean;
  58574. /**
  58575. * Creates a new Slider
  58576. * @param name defines the control name
  58577. */
  58578. constructor(name?: string | undefined);
  58579. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58580. }
  58581. }
  58582. declare module BABYLON.GUI {
  58583. /** Class used to create a RadioGroup
  58584. * which contains groups of radio buttons
  58585. */
  58586. export class SelectorGroup {
  58587. /** name of SelectorGroup */
  58588. name: string;
  58589. private _groupPanel;
  58590. private _selectors;
  58591. private _groupHeader;
  58592. /**
  58593. * Creates a new SelectorGroup
  58594. * @param name of group, used as a group heading
  58595. */
  58596. constructor(
  58597. /** name of SelectorGroup */
  58598. name: string);
  58599. /** Gets the groupPanel of the SelectorGroup */
  58600. readonly groupPanel: StackPanel;
  58601. /** Gets the selectors array */
  58602. readonly selectors: StackPanel[];
  58603. /** Gets and sets the group header */
  58604. header: string;
  58605. /** @hidden */
  58606. private _addGroupHeader;
  58607. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58608. /** Removes the selector at the given position
  58609. * @param selectorNb the position of the selector within the group
  58610. */
  58611. removeSelector(selectorNb: number): void;
  58612. }
  58613. /** Class used to create a CheckboxGroup
  58614. * which contains groups of checkbox buttons
  58615. */
  58616. export class CheckboxGroup extends SelectorGroup {
  58617. /** Adds a checkbox as a control
  58618. * @param text is the label for the selector
  58619. * @param func is the function called when the Selector is checked
  58620. * @param checked is true when Selector is checked
  58621. */
  58622. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58623. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58624. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58625. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58626. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58627. }
  58628. /** Class used to create a RadioGroup
  58629. * which contains groups of radio buttons
  58630. */
  58631. export class RadioGroup extends SelectorGroup {
  58632. private _selectNb;
  58633. /** Adds a radio button as a control
  58634. * @param label is the label for the selector
  58635. * @param func is the function called when the Selector is checked
  58636. * @param checked is true when Selector is checked
  58637. */
  58638. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58639. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58640. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58641. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58642. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58643. }
  58644. /** Class used to create a SliderGroup
  58645. * which contains groups of slider buttons
  58646. */
  58647. export class SliderGroup extends SelectorGroup {
  58648. /**
  58649. * Adds a slider to the SelectorGroup
  58650. * @param label is the label for the SliderBar
  58651. * @param func is the function called when the Slider moves
  58652. * @param unit is a string describing the units used, eg degrees or metres
  58653. * @param min is the minimum value for the Slider
  58654. * @param max is the maximum value for the Slider
  58655. * @param value is the start value for the Slider between min and max
  58656. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58657. */
  58658. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58659. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58660. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58661. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58662. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58663. }
  58664. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58665. * @see http://doc.babylonjs.com/how_to/selector
  58666. */
  58667. export class SelectionPanel extends Rectangle {
  58668. /** name of SelectionPanel */
  58669. name: string;
  58670. /** an array of SelectionGroups */
  58671. groups: SelectorGroup[];
  58672. private _panel;
  58673. private _buttonColor;
  58674. private _buttonBackground;
  58675. private _headerColor;
  58676. private _barColor;
  58677. private _barHeight;
  58678. private _spacerHeight;
  58679. private _labelColor;
  58680. private _groups;
  58681. private _bars;
  58682. /**
  58683. * Creates a new SelectionPanel
  58684. * @param name of SelectionPanel
  58685. * @param groups is an array of SelectionGroups
  58686. */
  58687. constructor(
  58688. /** name of SelectionPanel */
  58689. name: string,
  58690. /** an array of SelectionGroups */
  58691. groups?: SelectorGroup[]);
  58692. protected _getTypeName(): string;
  58693. /** Gets or sets the headerColor */
  58694. headerColor: string;
  58695. private _setHeaderColor;
  58696. /** Gets or sets the button color */
  58697. buttonColor: string;
  58698. private _setbuttonColor;
  58699. /** Gets or sets the label color */
  58700. labelColor: string;
  58701. private _setLabelColor;
  58702. /** Gets or sets the button background */
  58703. buttonBackground: string;
  58704. private _setButtonBackground;
  58705. /** Gets or sets the color of separator bar */
  58706. barColor: string;
  58707. private _setBarColor;
  58708. /** Gets or sets the height of separator bar */
  58709. barHeight: string;
  58710. private _setBarHeight;
  58711. /** Gets or sets the height of spacers*/
  58712. spacerHeight: string;
  58713. private _setSpacerHeight;
  58714. /** Adds a bar between groups */
  58715. private _addSpacer;
  58716. /** Add a group to the selection panel
  58717. * @param group is the selector group to add
  58718. */
  58719. addGroup(group: SelectorGroup): void;
  58720. /** Remove the group from the given position
  58721. * @param groupNb is the position of the group in the list
  58722. */
  58723. removeGroup(groupNb: number): void;
  58724. /** Change a group header label
  58725. * @param label is the new group header label
  58726. * @param groupNb is the number of the group to relabel
  58727. * */
  58728. setHeaderName(label: string, groupNb: number): void;
  58729. /** Change selector label to the one given
  58730. * @param label is the new selector label
  58731. * @param groupNb is the number of the groupcontaining the selector
  58732. * @param selectorNb is the number of the selector within a group to relabel
  58733. * */
  58734. relabel(label: string, groupNb: number, selectorNb: number): void;
  58735. /** For a given group position remove the selector at the given position
  58736. * @param groupNb is the number of the group to remove the selector from
  58737. * @param selectorNb is the number of the selector within the group
  58738. */
  58739. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58740. /** For a given group position of correct type add a checkbox button
  58741. * @param groupNb is the number of the group to remove the selector from
  58742. * @param label is the label for the selector
  58743. * @param func is the function called when the Selector is checked
  58744. * @param checked is true when Selector is checked
  58745. */
  58746. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58747. /** For a given group position of correct type add a radio button
  58748. * @param groupNb is the number of the group to remove the selector from
  58749. * @param label is the label for the selector
  58750. * @param func is the function called when the Selector is checked
  58751. * @param checked is true when Selector is checked
  58752. */
  58753. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58754. /**
  58755. * For a given slider group add a slider
  58756. * @param groupNb is the number of the group to add the slider to
  58757. * @param label is the label for the Slider
  58758. * @param func is the function called when the Slider moves
  58759. * @param unit is a string describing the units used, eg degrees or metres
  58760. * @param min is the minimum value for the Slider
  58761. * @param max is the maximum value for the Slider
  58762. * @param value is the start value for the Slider between min and max
  58763. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58764. */
  58765. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58766. }
  58767. }
  58768. declare module BABYLON.GUI {
  58769. /**
  58770. * Class used to hold a the container for ScrollViewer
  58771. * @hidden
  58772. */
  58773. export class _ScrollViewerWindow extends Container {
  58774. parentClientWidth: number;
  58775. parentClientHeight: number;
  58776. /**
  58777. * Creates a new ScrollViewerWindow
  58778. * @param name of ScrollViewerWindow
  58779. */
  58780. constructor(name?: string);
  58781. protected _getTypeName(): string;
  58782. /** @hidden */
  58783. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58784. protected _postMeasure(): void;
  58785. }
  58786. }
  58787. declare module BABYLON.GUI {
  58788. /**
  58789. * Class used to create slider controls
  58790. */
  58791. export class ScrollBar extends BaseSlider {
  58792. name?: string | undefined;
  58793. private _background;
  58794. private _borderColor;
  58795. private _thumbMeasure;
  58796. /** Gets or sets border color */
  58797. borderColor: string;
  58798. /** Gets or sets background color */
  58799. background: string;
  58800. /**
  58801. * Creates a new Slider
  58802. * @param name defines the control name
  58803. */
  58804. constructor(name?: string | undefined);
  58805. protected _getTypeName(): string;
  58806. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58807. private _first;
  58808. private _originX;
  58809. private _originY;
  58810. /** @hidden */
  58811. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58812. }
  58813. }
  58814. declare module BABYLON.GUI {
  58815. /**
  58816. * Class used to hold a viewer window and sliders in a grid
  58817. */
  58818. export class ScrollViewer extends Rectangle {
  58819. private _grid;
  58820. private _horizontalBarSpace;
  58821. private _verticalBarSpace;
  58822. private _dragSpace;
  58823. private _horizontalBar;
  58824. private _verticalBar;
  58825. private _barColor;
  58826. private _barBackground;
  58827. private _barSize;
  58828. private _endLeft;
  58829. private _endTop;
  58830. private _window;
  58831. private _pointerIsOver;
  58832. private _wheelPrecision;
  58833. private _onPointerObserver;
  58834. private _clientWidth;
  58835. private _clientHeight;
  58836. /**
  58837. * Gets the horizontal scrollbar
  58838. */
  58839. readonly horizontalBar: ScrollBar;
  58840. /**
  58841. * Gets the vertical scrollbar
  58842. */
  58843. readonly verticalBar: ScrollBar;
  58844. /**
  58845. * Adds a new control to the current container
  58846. * @param control defines the control to add
  58847. * @returns the current container
  58848. */
  58849. addControl(control: BABYLON.Nullable<Control>): Container;
  58850. /**
  58851. * Removes a control from the current container
  58852. * @param control defines the control to remove
  58853. * @returns the current container
  58854. */
  58855. removeControl(control: Control): Container;
  58856. /** Gets the list of children */
  58857. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58858. /**
  58859. * Creates a new ScrollViewer
  58860. * @param name of ScrollViewer
  58861. */
  58862. constructor(name?: string);
  58863. /** Reset the scroll viewer window to initial size */
  58864. resetWindow(): void;
  58865. protected _getTypeName(): string;
  58866. private _buildClientSizes;
  58867. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58868. protected _postMeasure(): void;
  58869. /**
  58870. * Gets or sets the mouse wheel precision
  58871. * from 0 to 1 with a default value of 0.05
  58872. * */
  58873. wheelPrecision: number;
  58874. /** Gets or sets the bar color */
  58875. barColor: string;
  58876. /** Gets or sets the size of the bar */
  58877. barSize: number;
  58878. /** Gets or sets the bar background */
  58879. barBackground: string;
  58880. /** @hidden */
  58881. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58882. /** @hidden */
  58883. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58884. /** Releases associated resources */
  58885. dispose(): void;
  58886. }
  58887. }
  58888. declare module BABYLON.GUI {
  58889. /** Class used to render a grid */
  58890. export class DisplayGrid extends Control {
  58891. name?: string | undefined;
  58892. private _cellWidth;
  58893. private _cellHeight;
  58894. private _minorLineTickness;
  58895. private _minorLineColor;
  58896. private _majorLineTickness;
  58897. private _majorLineColor;
  58898. private _majorLineFrequency;
  58899. private _background;
  58900. private _displayMajorLines;
  58901. private _displayMinorLines;
  58902. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58903. displayMinorLines: boolean;
  58904. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58905. displayMajorLines: boolean;
  58906. /** Gets or sets background color (Black by default) */
  58907. background: string;
  58908. /** Gets or sets the width of each cell (20 by default) */
  58909. cellWidth: number;
  58910. /** Gets or sets the height of each cell (20 by default) */
  58911. cellHeight: number;
  58912. /** Gets or sets the tickness of minor lines (1 by default) */
  58913. minorLineTickness: number;
  58914. /** Gets or sets the color of minor lines (DarkGray by default) */
  58915. minorLineColor: string;
  58916. /** Gets or sets the tickness of major lines (2 by default) */
  58917. majorLineTickness: number;
  58918. /** Gets or sets the color of major lines (White by default) */
  58919. majorLineColor: string;
  58920. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58921. majorLineFrequency: number;
  58922. /**
  58923. * Creates a new GridDisplayRectangle
  58924. * @param name defines the control name
  58925. */
  58926. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58927. protected _getTypeName(): string;
  58928. }
  58929. }
  58930. declare module BABYLON.GUI {
  58931. /**
  58932. * Class used to create slider controls based on images
  58933. */
  58934. export class ImageBasedSlider extends BaseSlider {
  58935. name?: string | undefined;
  58936. private _backgroundImage;
  58937. private _thumbImage;
  58938. private _valueBarImage;
  58939. private _tempMeasure;
  58940. displayThumb: boolean;
  58941. /**
  58942. * Gets or sets the image used to render the background
  58943. */
  58944. backgroundImage: Image;
  58945. /**
  58946. * Gets or sets the image used to render the value bar
  58947. */
  58948. valueBarImage: Image;
  58949. /**
  58950. * Gets or sets the image used to render the thumb
  58951. */
  58952. thumbImage: Image;
  58953. /**
  58954. * Creates a new ImageBasedSlider
  58955. * @param name defines the control name
  58956. */
  58957. constructor(name?: string | undefined);
  58958. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58959. }
  58960. }
  58961. declare module BABYLON.GUI {
  58962. /**
  58963. * Forcing an export so that this code will execute
  58964. * @hidden
  58965. */
  58966. const name = "Statics";
  58967. }
  58968. declare module BABYLON.GUI {
  58969. /**
  58970. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58971. */
  58972. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58973. /**
  58974. * Define the instrumented AdvancedDynamicTexture.
  58975. */
  58976. texture: AdvancedDynamicTexture;
  58977. private _captureRenderTime;
  58978. private _renderTime;
  58979. private _captureLayoutTime;
  58980. private _layoutTime;
  58981. private _onBeginRenderObserver;
  58982. private _onEndRenderObserver;
  58983. private _onBeginLayoutObserver;
  58984. private _onEndLayoutObserver;
  58985. /**
  58986. * Gets the perf counter used to capture render time
  58987. */
  58988. readonly renderTimeCounter: BABYLON.PerfCounter;
  58989. /**
  58990. * Gets the perf counter used to capture layout time
  58991. */
  58992. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58993. /**
  58994. * Enable or disable the render time capture
  58995. */
  58996. captureRenderTime: boolean;
  58997. /**
  58998. * Enable or disable the layout time capture
  58999. */
  59000. captureLayoutTime: boolean;
  59001. /**
  59002. * Instantiates a new advanced dynamic texture instrumentation.
  59003. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  59004. * @param texture Defines the AdvancedDynamicTexture to instrument
  59005. */
  59006. constructor(
  59007. /**
  59008. * Define the instrumented AdvancedDynamicTexture.
  59009. */
  59010. texture: AdvancedDynamicTexture);
  59011. /**
  59012. * Dispose and release associated resources.
  59013. */
  59014. dispose(): void;
  59015. }
  59016. }
  59017. declare module BABYLON.GUI {
  59018. /**
  59019. * Class used to create containers for controls
  59020. */
  59021. export class Container3D extends Control3D {
  59022. private _blockLayout;
  59023. /**
  59024. * Gets the list of child controls
  59025. */
  59026. protected _children: Control3D[];
  59027. /**
  59028. * Gets the list of child controls
  59029. */
  59030. readonly children: Array<Control3D>;
  59031. /**
  59032. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  59033. * This is helpful to optimize layout operation when adding multiple children in a row
  59034. */
  59035. blockLayout: boolean;
  59036. /**
  59037. * Creates a new container
  59038. * @param name defines the container name
  59039. */
  59040. constructor(name?: string);
  59041. /**
  59042. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  59043. * @returns the current container
  59044. */
  59045. updateLayout(): Container3D;
  59046. /**
  59047. * Gets a boolean indicating if the given control is in the children of this control
  59048. * @param control defines the control to check
  59049. * @returns true if the control is in the child list
  59050. */
  59051. containsControl(control: Control3D): boolean;
  59052. /**
  59053. * Adds a control to the children of this control
  59054. * @param control defines the control to add
  59055. * @returns the current container
  59056. */
  59057. addControl(control: Control3D): Container3D;
  59058. /**
  59059. * This function will be called everytime a new control is added
  59060. */
  59061. protected _arrangeChildren(): void;
  59062. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59063. /**
  59064. * Removes a control from the children of this control
  59065. * @param control defines the control to remove
  59066. * @returns the current container
  59067. */
  59068. removeControl(control: Control3D): Container3D;
  59069. protected _getTypeName(): string;
  59070. /**
  59071. * Releases all associated resources
  59072. */
  59073. dispose(): void;
  59074. /** Control rotation will remain unchanged */
  59075. static readonly UNSET_ORIENTATION: number;
  59076. /** Control will rotate to make it look at sphere central axis */
  59077. static readonly FACEORIGIN_ORIENTATION: number;
  59078. /** Control will rotate to make it look back at sphere central axis */
  59079. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  59080. /** Control will rotate to look at z axis (0, 0, 1) */
  59081. static readonly FACEFORWARD_ORIENTATION: number;
  59082. /** Control will rotate to look at negative z axis (0, 0, -1) */
  59083. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  59084. }
  59085. }
  59086. declare module BABYLON.GUI {
  59087. /**
  59088. * Class used to manage 3D user interface
  59089. * @see http://doc.babylonjs.com/how_to/gui3d
  59090. */
  59091. export class GUI3DManager implements BABYLON.IDisposable {
  59092. private _scene;
  59093. private _sceneDisposeObserver;
  59094. private _utilityLayer;
  59095. private _rootContainer;
  59096. private _pointerObserver;
  59097. private _pointerOutObserver;
  59098. /** @hidden */ lastPickedControl: Control3D;
  59099. /** @hidden */ lastControlOver: {
  59100. [pointerId: number]: Control3D;
  59101. };
  59102. /** @hidden */ lastControlDown: {
  59103. [pointerId: number]: Control3D;
  59104. };
  59105. /**
  59106. * BABYLON.Observable raised when the point picked by the pointer events changed
  59107. */
  59108. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  59109. /** @hidden */ sharedMaterials: {
  59110. [key: string]: BABYLON.Material;
  59111. };
  59112. /** Gets the hosting scene */
  59113. readonly scene: BABYLON.Scene;
  59114. /** Gets associated utility layer */
  59115. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59116. /**
  59117. * Creates a new GUI3DManager
  59118. * @param scene
  59119. */
  59120. constructor(scene?: BABYLON.Scene);
  59121. private _handlePointerOut;
  59122. private _doPicking;
  59123. /**
  59124. * Gets the root container
  59125. */
  59126. readonly rootContainer: Container3D;
  59127. /**
  59128. * Gets a boolean indicating if the given control is in the root child list
  59129. * @param control defines the control to check
  59130. * @returns true if the control is in the root child list
  59131. */
  59132. containsControl(control: Control3D): boolean;
  59133. /**
  59134. * Adds a control to the root child list
  59135. * @param control defines the control to add
  59136. * @returns the current manager
  59137. */
  59138. addControl(control: Control3D): GUI3DManager;
  59139. /**
  59140. * Removes a control from the root child list
  59141. * @param control defines the control to remove
  59142. * @returns the current container
  59143. */
  59144. removeControl(control: Control3D): GUI3DManager;
  59145. /**
  59146. * Releases all associated resources
  59147. */
  59148. dispose(): void;
  59149. }
  59150. }
  59151. declare module BABYLON.GUI {
  59152. /**
  59153. * Class used to transport BABYLON.Vector3 information for pointer events
  59154. */
  59155. export class Vector3WithInfo extends BABYLON.Vector3 {
  59156. /** defines the current mouse button index */
  59157. buttonIndex: number;
  59158. /**
  59159. * Creates a new Vector3WithInfo
  59160. * @param source defines the vector3 data to transport
  59161. * @param buttonIndex defines the current mouse button index
  59162. */
  59163. constructor(source: BABYLON.Vector3,
  59164. /** defines the current mouse button index */
  59165. buttonIndex?: number);
  59166. }
  59167. }
  59168. declare module BABYLON.GUI {
  59169. /**
  59170. * Class used as base class for controls
  59171. */
  59172. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59173. /** Defines the control name */
  59174. name?: string | undefined;
  59175. /** @hidden */ host: GUI3DManager;
  59176. private _node;
  59177. private _downCount;
  59178. private _enterCount;
  59179. private _downPointerIds;
  59180. private _isVisible;
  59181. /** Gets or sets the control position in world space */
  59182. position: BABYLON.Vector3;
  59183. /** Gets or sets the control scaling in world space */
  59184. scaling: BABYLON.Vector3;
  59185. /** Callback used to start pointer enter animation */
  59186. pointerEnterAnimation: () => void;
  59187. /** Callback used to start pointer out animation */
  59188. pointerOutAnimation: () => void;
  59189. /** Callback used to start pointer down animation */
  59190. pointerDownAnimation: () => void;
  59191. /** Callback used to start pointer up animation */
  59192. pointerUpAnimation: () => void;
  59193. /**
  59194. * An event triggered when the pointer move over the control
  59195. */
  59196. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59197. /**
  59198. * An event triggered when the pointer move out of the control
  59199. */
  59200. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59201. /**
  59202. * An event triggered when the pointer taps the control
  59203. */
  59204. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59205. /**
  59206. * An event triggered when pointer is up
  59207. */
  59208. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59209. /**
  59210. * An event triggered when a control is clicked on (with a mouse)
  59211. */
  59212. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59213. /**
  59214. * An event triggered when pointer enters the control
  59215. */
  59216. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59217. /**
  59218. * Gets or sets the parent container
  59219. */
  59220. parent: BABYLON.Nullable<Container3D>;
  59221. private _behaviors;
  59222. /**
  59223. * Gets the list of attached behaviors
  59224. * @see http://doc.babylonjs.com/features/behaviour
  59225. */
  59226. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59227. /**
  59228. * Attach a behavior to the control
  59229. * @see http://doc.babylonjs.com/features/behaviour
  59230. * @param behavior defines the behavior to attach
  59231. * @returns the current control
  59232. */
  59233. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59234. /**
  59235. * Remove an attached behavior
  59236. * @see http://doc.babylonjs.com/features/behaviour
  59237. * @param behavior defines the behavior to attach
  59238. * @returns the current control
  59239. */
  59240. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59241. /**
  59242. * Gets an attached behavior by name
  59243. * @param name defines the name of the behavior to look for
  59244. * @see http://doc.babylonjs.com/features/behaviour
  59245. * @returns null if behavior was not found else the requested behavior
  59246. */
  59247. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59248. /** Gets or sets a boolean indicating if the control is visible */
  59249. isVisible: boolean;
  59250. /**
  59251. * Creates a new control
  59252. * @param name defines the control name
  59253. */
  59254. constructor(
  59255. /** Defines the control name */
  59256. name?: string | undefined);
  59257. /**
  59258. * Gets a string representing the class name
  59259. */
  59260. readonly typeName: string;
  59261. /**
  59262. * Get the current class name of the control.
  59263. * @returns current class name
  59264. */
  59265. getClassName(): string;
  59266. protected _getTypeName(): string;
  59267. /**
  59268. * Gets the transform node used by this control
  59269. */
  59270. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59271. /**
  59272. * Gets the mesh used to render this control
  59273. */
  59274. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59275. /**
  59276. * Link the control as child of the given node
  59277. * @param node defines the node to link to. Use null to unlink the control
  59278. * @returns the current control
  59279. */
  59280. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59281. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59282. /**
  59283. * Node creation.
  59284. * Can be overriden by children
  59285. * @param scene defines the scene where the node must be attached
  59286. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59287. */
  59288. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59289. /**
  59290. * Affect a material to the given mesh
  59291. * @param mesh defines the mesh which will represent the control
  59292. */
  59293. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59294. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59295. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59296. /** @hidden */ onPointerOut(target: Control3D): void;
  59297. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59298. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59299. /** @hidden */
  59300. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59301. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59302. /** @hidden */ disposeNode(): void;
  59303. /**
  59304. * Releases all associated resources
  59305. */
  59306. dispose(): void;
  59307. }
  59308. }
  59309. declare module BABYLON.GUI {
  59310. /**
  59311. * Class used as a root to all buttons
  59312. */
  59313. export class AbstractButton3D extends Control3D {
  59314. /**
  59315. * Creates a new button
  59316. * @param name defines the control name
  59317. */
  59318. constructor(name?: string);
  59319. protected _getTypeName(): string;
  59320. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59321. }
  59322. }
  59323. declare module BABYLON.GUI {
  59324. /**
  59325. * Class used to create a button in 3D
  59326. */
  59327. export class Button3D extends AbstractButton3D {
  59328. /** @hidden */
  59329. protected _currentMaterial: BABYLON.Material;
  59330. private _facadeTexture;
  59331. private _content;
  59332. private _contentResolution;
  59333. private _contentScaleRatio;
  59334. /**
  59335. * Gets or sets the texture resolution used to render content (512 by default)
  59336. */
  59337. contentResolution: BABYLON.int;
  59338. /**
  59339. * Gets or sets the texture scale ratio used to render content (2 by default)
  59340. */
  59341. contentScaleRatio: number;
  59342. protected _disposeFacadeTexture(): void;
  59343. protected _resetContent(): void;
  59344. /**
  59345. * Creates a new button
  59346. * @param name defines the control name
  59347. */
  59348. constructor(name?: string);
  59349. /**
  59350. * Gets or sets the GUI 2D content used to display the button's facade
  59351. */
  59352. content: Control;
  59353. /**
  59354. * Apply the facade texture (created from the content property).
  59355. * This function can be overloaded by child classes
  59356. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59357. */
  59358. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59359. protected _getTypeName(): string;
  59360. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59361. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59362. /**
  59363. * Releases all associated resources
  59364. */
  59365. dispose(): void;
  59366. }
  59367. }
  59368. declare module BABYLON.GUI {
  59369. /**
  59370. * Abstract class used to create a container panel deployed on the surface of a volume
  59371. */
  59372. export abstract class VolumeBasedPanel extends Container3D {
  59373. private _columns;
  59374. private _rows;
  59375. private _rowThenColum;
  59376. private _orientation;
  59377. protected _cellWidth: number;
  59378. protected _cellHeight: number;
  59379. /**
  59380. * Gets or sets the distance between elements
  59381. */
  59382. margin: number;
  59383. /**
  59384. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59385. * | Value | Type | Description |
  59386. * | ----- | ----------------------------------- | ----------- |
  59387. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59388. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59389. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59390. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59391. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59392. */
  59393. orientation: number;
  59394. /**
  59395. * Gets or sets the number of columns requested (10 by default).
  59396. * The panel will automatically compute the number of rows based on number of child controls.
  59397. */
  59398. columns: BABYLON.int;
  59399. /**
  59400. * Gets or sets a the number of rows requested.
  59401. * The panel will automatically compute the number of columns based on number of child controls.
  59402. */
  59403. rows: BABYLON.int;
  59404. /**
  59405. * Creates new VolumeBasedPanel
  59406. */
  59407. constructor();
  59408. protected _arrangeChildren(): void;
  59409. /** Child classes must implement this function to provide correct control positioning */
  59410. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59411. /** Child classes can implement this function to provide additional processing */
  59412. protected _finalProcessing(): void;
  59413. }
  59414. }
  59415. declare module BABYLON.GUI {
  59416. /**
  59417. * Class used to create a container panel deployed on the surface of a cylinder
  59418. */
  59419. export class CylinderPanel extends VolumeBasedPanel {
  59420. private _radius;
  59421. /**
  59422. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59423. */
  59424. radius: BABYLON.float;
  59425. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59426. private _cylindricalMapping;
  59427. }
  59428. }
  59429. declare module BABYLON.GUI {
  59430. /** @hidden */
  59431. export var fluentVertexShader: {
  59432. name: string;
  59433. shader: string;
  59434. };
  59435. }
  59436. declare module BABYLON.GUI {
  59437. /** @hidden */
  59438. export var fluentPixelShader: {
  59439. name: string;
  59440. shader: string;
  59441. };
  59442. }
  59443. declare module BABYLON.GUI {
  59444. /** @hidden */
  59445. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59446. INNERGLOW: boolean;
  59447. BORDER: boolean;
  59448. HOVERLIGHT: boolean;
  59449. TEXTURE: boolean;
  59450. constructor();
  59451. }
  59452. /**
  59453. * Class used to render controls with fluent desgin
  59454. */
  59455. export class FluentMaterial extends BABYLON.PushMaterial {
  59456. /**
  59457. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59458. */
  59459. innerGlowColorIntensity: number;
  59460. /**
  59461. * Gets or sets the inner glow color (white by default)
  59462. */
  59463. innerGlowColor: BABYLON.Color3;
  59464. /**
  59465. * Gets or sets alpha value (default is 1.0)
  59466. */
  59467. alpha: number;
  59468. /**
  59469. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59470. */
  59471. albedoColor: BABYLON.Color3;
  59472. /**
  59473. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59474. */
  59475. renderBorders: boolean;
  59476. /**
  59477. * Gets or sets border width (default is 0.5)
  59478. */
  59479. borderWidth: number;
  59480. /**
  59481. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59482. */
  59483. edgeSmoothingValue: number;
  59484. /**
  59485. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59486. */
  59487. borderMinValue: number;
  59488. /**
  59489. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59490. */
  59491. renderHoverLight: boolean;
  59492. /**
  59493. * Gets or sets the radius used to render the hover light (default is 1.0)
  59494. */
  59495. hoverRadius: number;
  59496. /**
  59497. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59498. */
  59499. hoverColor: BABYLON.Color4;
  59500. /**
  59501. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59502. */
  59503. hoverPosition: BABYLON.Vector3;
  59504. private _albedoTexture;
  59505. /** Gets or sets the texture to use for albedo color */
  59506. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59507. /**
  59508. * Creates a new Fluent material
  59509. * @param name defines the name of the material
  59510. * @param scene defines the hosting scene
  59511. */
  59512. constructor(name: string, scene: BABYLON.Scene);
  59513. needAlphaBlending(): boolean;
  59514. needAlphaTesting(): boolean;
  59515. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59516. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59517. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59518. getActiveTextures(): BABYLON.BaseTexture[];
  59519. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59520. dispose(forceDisposeEffect?: boolean): void;
  59521. clone(name: string): FluentMaterial;
  59522. serialize(): any;
  59523. getClassName(): string;
  59524. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59525. }
  59526. }
  59527. declare module BABYLON.GUI {
  59528. /**
  59529. * Class used to create a holographic button in 3D
  59530. */
  59531. export class HolographicButton extends Button3D {
  59532. private _backPlate;
  59533. private _textPlate;
  59534. private _frontPlate;
  59535. private _text;
  59536. private _imageUrl;
  59537. private _shareMaterials;
  59538. private _frontMaterial;
  59539. private _backMaterial;
  59540. private _plateMaterial;
  59541. private _pickedPointObserver;
  59542. private _tooltipFade;
  59543. private _tooltipTextBlock;
  59544. private _tooltipTexture;
  59545. private _tooltipMesh;
  59546. private _tooltipHoverObserver;
  59547. private _tooltipOutObserver;
  59548. private _disposeTooltip;
  59549. /**
  59550. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59551. */
  59552. tooltipText: BABYLON.Nullable<string>;
  59553. /**
  59554. * Gets or sets text for the button
  59555. */
  59556. text: string;
  59557. /**
  59558. * Gets or sets the image url for the button
  59559. */
  59560. imageUrl: string;
  59561. /**
  59562. * Gets the back material used by this button
  59563. */
  59564. readonly backMaterial: FluentMaterial;
  59565. /**
  59566. * Gets the front material used by this button
  59567. */
  59568. readonly frontMaterial: FluentMaterial;
  59569. /**
  59570. * Gets the plate material used by this button
  59571. */
  59572. readonly plateMaterial: BABYLON.StandardMaterial;
  59573. /**
  59574. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59575. */
  59576. readonly shareMaterials: boolean;
  59577. /**
  59578. * Creates a new button
  59579. * @param name defines the control name
  59580. */
  59581. constructor(name?: string, shareMaterials?: boolean);
  59582. protected _getTypeName(): string;
  59583. private _rebuildContent;
  59584. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59585. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59586. private _createBackMaterial;
  59587. private _createFrontMaterial;
  59588. private _createPlateMaterial;
  59589. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59590. /**
  59591. * Releases all associated resources
  59592. */
  59593. dispose(): void;
  59594. }
  59595. }
  59596. declare module BABYLON.GUI {
  59597. /**
  59598. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59599. */
  59600. export class MeshButton3D extends Button3D {
  59601. /** @hidden */
  59602. protected _currentMesh: BABYLON.Mesh;
  59603. /**
  59604. * Creates a new 3D button based on a mesh
  59605. * @param mesh mesh to become a 3D button
  59606. * @param name defines the control name
  59607. */
  59608. constructor(mesh: BABYLON.Mesh, name?: string);
  59609. protected _getTypeName(): string;
  59610. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59611. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59612. }
  59613. }
  59614. declare module BABYLON.GUI {
  59615. /**
  59616. * Class used to create a container panel deployed on the surface of a plane
  59617. */
  59618. export class PlanePanel extends VolumeBasedPanel {
  59619. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59620. }
  59621. }
  59622. declare module BABYLON.GUI {
  59623. /**
  59624. * Class used to create a container panel where items get randomized planar mapping
  59625. */
  59626. export class ScatterPanel extends VolumeBasedPanel {
  59627. private _iteration;
  59628. /**
  59629. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59630. */
  59631. iteration: BABYLON.float;
  59632. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59633. private _scatterMapping;
  59634. protected _finalProcessing(): void;
  59635. }
  59636. }
  59637. declare module BABYLON.GUI {
  59638. /**
  59639. * Class used to create a container panel deployed on the surface of a sphere
  59640. */
  59641. export class SpherePanel extends VolumeBasedPanel {
  59642. private _radius;
  59643. /**
  59644. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59645. */
  59646. radius: BABYLON.float;
  59647. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59648. private _sphericalMapping;
  59649. }
  59650. }
  59651. declare module BABYLON.GUI {
  59652. /**
  59653. * Class used to create a stack panel in 3D on XY plane
  59654. */
  59655. export class StackPanel3D extends Container3D {
  59656. private _isVertical;
  59657. /**
  59658. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59659. */
  59660. isVertical: boolean;
  59661. /**
  59662. * Gets or sets the distance between elements
  59663. */
  59664. margin: number;
  59665. /**
  59666. * Creates new StackPanel
  59667. * @param isVertical
  59668. */
  59669. constructor(isVertical?: boolean);
  59670. protected _arrangeChildren(): void;
  59671. }
  59672. }
  59673. declare module BABYLON {
  59674. /**
  59675. * Mode that determines the coordinate system to use.
  59676. */
  59677. export enum GLTFLoaderCoordinateSystemMode {
  59678. /**
  59679. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59680. */
  59681. AUTO = 0,
  59682. /**
  59683. * Sets the useRightHandedSystem flag on the scene.
  59684. */
  59685. FORCE_RIGHT_HANDED = 1
  59686. }
  59687. /**
  59688. * Mode that determines what animations will start.
  59689. */
  59690. export enum GLTFLoaderAnimationStartMode {
  59691. /**
  59692. * No animation will start.
  59693. */
  59694. NONE = 0,
  59695. /**
  59696. * The first animation will start.
  59697. */
  59698. FIRST = 1,
  59699. /**
  59700. * All animations will start.
  59701. */
  59702. ALL = 2
  59703. }
  59704. /**
  59705. * Interface that contains the data for the glTF asset.
  59706. */
  59707. export interface IGLTFLoaderData {
  59708. /**
  59709. * Object that represents the glTF JSON.
  59710. */
  59711. json: Object;
  59712. /**
  59713. * The BIN chunk of a binary glTF.
  59714. */
  59715. bin: Nullable<ArrayBufferView>;
  59716. }
  59717. /**
  59718. * Interface for extending the loader.
  59719. */
  59720. export interface IGLTFLoaderExtension {
  59721. /**
  59722. * The name of this extension.
  59723. */
  59724. readonly name: string;
  59725. /**
  59726. * Defines whether this extension is enabled.
  59727. */
  59728. enabled: boolean;
  59729. }
  59730. /**
  59731. * Loader state.
  59732. */
  59733. export enum GLTFLoaderState {
  59734. /**
  59735. * The asset is loading.
  59736. */
  59737. LOADING = 0,
  59738. /**
  59739. * The asset is ready for rendering.
  59740. */
  59741. READY = 1,
  59742. /**
  59743. * The asset is completely loaded.
  59744. */
  59745. COMPLETE = 2
  59746. }
  59747. /** @hidden */
  59748. export interface IGLTFLoader extends IDisposable {
  59749. readonly state: Nullable<GLTFLoaderState>;
  59750. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59751. meshes: AbstractMesh[];
  59752. particleSystems: IParticleSystem[];
  59753. skeletons: Skeleton[];
  59754. animationGroups: AnimationGroup[];
  59755. }>;
  59756. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59757. }
  59758. /**
  59759. * File loader for loading glTF files into a scene.
  59760. */
  59761. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59762. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59763. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59764. /**
  59765. * Raised when the asset has been parsed
  59766. */
  59767. onParsedObservable: Observable<IGLTFLoaderData>;
  59768. private _onParsedObserver;
  59769. /**
  59770. * Raised when the asset has been parsed
  59771. */
  59772. onParsed: (loaderData: IGLTFLoaderData) => void;
  59773. /**
  59774. * 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.
  59775. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59776. * Defaults to true.
  59777. * @hidden
  59778. */
  59779. static IncrementalLoading: boolean;
  59780. /**
  59781. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59782. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59783. * @hidden
  59784. */
  59785. static HomogeneousCoordinates: boolean;
  59786. /**
  59787. * The coordinate system mode. Defaults to AUTO.
  59788. */
  59789. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59790. /**
  59791. * The animation start mode. Defaults to FIRST.
  59792. */
  59793. animationStartMode: GLTFLoaderAnimationStartMode;
  59794. /**
  59795. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59796. */
  59797. compileMaterials: boolean;
  59798. /**
  59799. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59800. */
  59801. useClipPlane: boolean;
  59802. /**
  59803. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59804. */
  59805. compileShadowGenerators: boolean;
  59806. /**
  59807. * Defines if the Alpha blended materials are only applied as coverage.
  59808. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59809. * If true, no extra effects are applied to transparent pixels.
  59810. */
  59811. transparencyAsCoverage: boolean;
  59812. /**
  59813. * Function called before loading a url referenced by the asset.
  59814. */
  59815. preprocessUrlAsync: (url: string) => Promise<string>;
  59816. /**
  59817. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59818. */
  59819. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59820. private _onMeshLoadedObserver;
  59821. /**
  59822. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59823. */
  59824. onMeshLoaded: (mesh: AbstractMesh) => void;
  59825. /**
  59826. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59827. */
  59828. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59829. private _onTextureLoadedObserver;
  59830. /**
  59831. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59832. */
  59833. onTextureLoaded: (texture: BaseTexture) => void;
  59834. /**
  59835. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59836. */
  59837. readonly onMaterialLoadedObservable: Observable<Material>;
  59838. private _onMaterialLoadedObserver;
  59839. /**
  59840. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59841. */
  59842. onMaterialLoaded: (material: Material) => void;
  59843. /**
  59844. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59845. */
  59846. readonly onCameraLoadedObservable: Observable<Camera>;
  59847. private _onCameraLoadedObserver;
  59848. /**
  59849. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59850. */
  59851. onCameraLoaded: (camera: Camera) => void;
  59852. /**
  59853. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59854. * For assets with LODs, raised when all of the LODs are complete.
  59855. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59856. */
  59857. readonly onCompleteObservable: Observable<void>;
  59858. private _onCompleteObserver;
  59859. /**
  59860. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59861. * For assets with LODs, raised when all of the LODs are complete.
  59862. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59863. */
  59864. onComplete: () => void;
  59865. /**
  59866. * Observable raised when an error occurs.
  59867. */
  59868. readonly onErrorObservable: Observable<any>;
  59869. private _onErrorObserver;
  59870. /**
  59871. * Callback raised when an error occurs.
  59872. */
  59873. onError: (reason: any) => void;
  59874. /**
  59875. * Observable raised after the loader is disposed.
  59876. */
  59877. readonly onDisposeObservable: Observable<void>;
  59878. private _onDisposeObserver;
  59879. /**
  59880. * Callback raised after the loader is disposed.
  59881. */
  59882. onDispose: () => void;
  59883. /**
  59884. * Observable raised after a loader extension is created.
  59885. * Set additional options for a loader extension in this event.
  59886. */
  59887. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59888. private _onExtensionLoadedObserver;
  59889. /**
  59890. * Callback raised after a loader extension is created.
  59891. */
  59892. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59893. /**
  59894. * Defines if the loader logging is enabled.
  59895. */
  59896. loggingEnabled: boolean;
  59897. /**
  59898. * Defines if the loader should capture performance counters.
  59899. */
  59900. capturePerformanceCounters: boolean;
  59901. /**
  59902. * Defines if the loader should validate the asset.
  59903. */
  59904. validate: boolean;
  59905. /**
  59906. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59907. */
  59908. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59909. private _onValidatedObserver;
  59910. /**
  59911. * Callback raised after a loader extension is created.
  59912. */
  59913. onValidated: (results: IGLTFValidationResults) => void;
  59914. private _loader;
  59915. /**
  59916. * Name of the loader ("gltf")
  59917. */
  59918. name: string;
  59919. /**
  59920. * Supported file extensions of the loader (.gltf, .glb)
  59921. */
  59922. extensions: ISceneLoaderPluginExtensions;
  59923. /**
  59924. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59925. */
  59926. dispose(): void;
  59927. /** @hidden */ clear(): void;
  59928. /**
  59929. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59930. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59931. * @param scene the scene the meshes should be added to
  59932. * @param data the glTF data to load
  59933. * @param rootUrl root url to load from
  59934. * @param onProgress event that fires when loading progress has occured
  59935. * @param fileName Defines the name of the file to load
  59936. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59937. */
  59938. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59939. meshes: AbstractMesh[];
  59940. particleSystems: IParticleSystem[];
  59941. skeletons: Skeleton[];
  59942. animationGroups: AnimationGroup[];
  59943. }>;
  59944. /**
  59945. * Imports all objects from the loaded glTF data and adds them to the scene
  59946. * @param scene the scene the objects should be added to
  59947. * @param data the glTF data to load
  59948. * @param rootUrl root url to load from
  59949. * @param onProgress event that fires when loading progress has occured
  59950. * @param fileName Defines the name of the file to load
  59951. * @returns a promise which completes when objects have been loaded to the scene
  59952. */
  59953. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59954. /**
  59955. * Load into an asset container.
  59956. * @param scene The scene to load into
  59957. * @param data The data to import
  59958. * @param rootUrl The root url for scene and resources
  59959. * @param onProgress The callback when the load progresses
  59960. * @param fileName Defines the name of the file to load
  59961. * @returns The loaded asset container
  59962. */
  59963. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59964. /**
  59965. * If the data string can be loaded directly.
  59966. * @param data string contianing the file data
  59967. * @returns if the data can be loaded directly
  59968. */
  59969. canDirectLoad(data: string): boolean;
  59970. /**
  59971. * Rewrites a url by combining a root url and response url.
  59972. */
  59973. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59974. /**
  59975. * Instantiates a glTF file loader plugin.
  59976. * @returns the created plugin
  59977. */
  59978. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59979. /**
  59980. * The loader state or null if the loader is not active.
  59981. */
  59982. readonly loaderState: Nullable<GLTFLoaderState>;
  59983. /**
  59984. * Returns a promise that resolves when the asset is completely loaded.
  59985. * @returns a promise that resolves when the asset is completely loaded.
  59986. */
  59987. whenCompleteAsync(): Promise<void>;
  59988. private _parseAsync;
  59989. private _validateAsync;
  59990. private _getLoader;
  59991. private _unpackBinary;
  59992. private _unpackBinaryV1;
  59993. private _unpackBinaryV2;
  59994. private static _parseVersion;
  59995. private static _compareVersion;
  59996. private static _decodeBufferToText;
  59997. private static readonly _logSpaces;
  59998. private _logIndentLevel;
  59999. private _loggingEnabled;
  60000. /** @hidden */ log: (message: string) => void;
  60001. /** @hidden */ logOpen(message: string): void;
  60002. /** @hidden */ logClose(): void;
  60003. private _logEnabled;
  60004. private _logDisabled;
  60005. private _capturePerformanceCounters;
  60006. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  60007. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  60008. private _startPerformanceCounterEnabled;
  60009. private _startPerformanceCounterDisabled;
  60010. private _endPerformanceCounterEnabled;
  60011. private _endPerformanceCounterDisabled;
  60012. }
  60013. }
  60014. declare module BABYLON.GLTF1 {
  60015. /**
  60016. * Enums
  60017. * @hidden
  60018. */
  60019. export enum EComponentType {
  60020. BYTE = 5120,
  60021. UNSIGNED_BYTE = 5121,
  60022. SHORT = 5122,
  60023. UNSIGNED_SHORT = 5123,
  60024. FLOAT = 5126
  60025. }
  60026. /** @hidden */
  60027. export enum EShaderType {
  60028. FRAGMENT = 35632,
  60029. VERTEX = 35633
  60030. }
  60031. /** @hidden */
  60032. export enum EParameterType {
  60033. BYTE = 5120,
  60034. UNSIGNED_BYTE = 5121,
  60035. SHORT = 5122,
  60036. UNSIGNED_SHORT = 5123,
  60037. INT = 5124,
  60038. UNSIGNED_INT = 5125,
  60039. FLOAT = 5126,
  60040. FLOAT_VEC2 = 35664,
  60041. FLOAT_VEC3 = 35665,
  60042. FLOAT_VEC4 = 35666,
  60043. INT_VEC2 = 35667,
  60044. INT_VEC3 = 35668,
  60045. INT_VEC4 = 35669,
  60046. BOOL = 35670,
  60047. BOOL_VEC2 = 35671,
  60048. BOOL_VEC3 = 35672,
  60049. BOOL_VEC4 = 35673,
  60050. FLOAT_MAT2 = 35674,
  60051. FLOAT_MAT3 = 35675,
  60052. FLOAT_MAT4 = 35676,
  60053. SAMPLER_2D = 35678
  60054. }
  60055. /** @hidden */
  60056. export enum ETextureWrapMode {
  60057. CLAMP_TO_EDGE = 33071,
  60058. MIRRORED_REPEAT = 33648,
  60059. REPEAT = 10497
  60060. }
  60061. /** @hidden */
  60062. export enum ETextureFilterType {
  60063. NEAREST = 9728,
  60064. LINEAR = 9728,
  60065. NEAREST_MIPMAP_NEAREST = 9984,
  60066. LINEAR_MIPMAP_NEAREST = 9985,
  60067. NEAREST_MIPMAP_LINEAR = 9986,
  60068. LINEAR_MIPMAP_LINEAR = 9987
  60069. }
  60070. /** @hidden */
  60071. export enum ETextureFormat {
  60072. ALPHA = 6406,
  60073. RGB = 6407,
  60074. RGBA = 6408,
  60075. LUMINANCE = 6409,
  60076. LUMINANCE_ALPHA = 6410
  60077. }
  60078. /** @hidden */
  60079. export enum ECullingType {
  60080. FRONT = 1028,
  60081. BACK = 1029,
  60082. FRONT_AND_BACK = 1032
  60083. }
  60084. /** @hidden */
  60085. export enum EBlendingFunction {
  60086. ZERO = 0,
  60087. ONE = 1,
  60088. SRC_COLOR = 768,
  60089. ONE_MINUS_SRC_COLOR = 769,
  60090. DST_COLOR = 774,
  60091. ONE_MINUS_DST_COLOR = 775,
  60092. SRC_ALPHA = 770,
  60093. ONE_MINUS_SRC_ALPHA = 771,
  60094. DST_ALPHA = 772,
  60095. ONE_MINUS_DST_ALPHA = 773,
  60096. CONSTANT_COLOR = 32769,
  60097. ONE_MINUS_CONSTANT_COLOR = 32770,
  60098. CONSTANT_ALPHA = 32771,
  60099. ONE_MINUS_CONSTANT_ALPHA = 32772,
  60100. SRC_ALPHA_SATURATE = 776
  60101. }
  60102. /** @hidden */
  60103. export interface IGLTFProperty {
  60104. extensions?: {
  60105. [key: string]: any;
  60106. };
  60107. extras?: Object;
  60108. }
  60109. /** @hidden */
  60110. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60111. name?: string;
  60112. }
  60113. /** @hidden */
  60114. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60115. bufferView: string;
  60116. byteOffset: number;
  60117. byteStride: number;
  60118. count: number;
  60119. type: string;
  60120. componentType: EComponentType;
  60121. max?: number[];
  60122. min?: number[];
  60123. name?: string;
  60124. }
  60125. /** @hidden */
  60126. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60127. buffer: string;
  60128. byteOffset: number;
  60129. byteLength: number;
  60130. byteStride: number;
  60131. target?: number;
  60132. }
  60133. /** @hidden */
  60134. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60135. uri: string;
  60136. byteLength?: number;
  60137. type?: string;
  60138. }
  60139. /** @hidden */
  60140. export interface IGLTFShader extends IGLTFChildRootProperty {
  60141. uri: string;
  60142. type: EShaderType;
  60143. }
  60144. /** @hidden */
  60145. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60146. attributes: string[];
  60147. fragmentShader: string;
  60148. vertexShader: string;
  60149. }
  60150. /** @hidden */
  60151. export interface IGLTFTechniqueParameter {
  60152. type: number;
  60153. count?: number;
  60154. semantic?: string;
  60155. node?: string;
  60156. value?: number | boolean | string | Array<any>;
  60157. source?: string;
  60158. babylonValue?: any;
  60159. }
  60160. /** @hidden */
  60161. export interface IGLTFTechniqueCommonProfile {
  60162. lightingModel: string;
  60163. texcoordBindings: Object;
  60164. parameters?: Array<any>;
  60165. }
  60166. /** @hidden */
  60167. export interface IGLTFTechniqueStatesFunctions {
  60168. blendColor?: number[];
  60169. blendEquationSeparate?: number[];
  60170. blendFuncSeparate?: number[];
  60171. colorMask: boolean[];
  60172. cullFace: number[];
  60173. }
  60174. /** @hidden */
  60175. export interface IGLTFTechniqueStates {
  60176. enable: number[];
  60177. functions: IGLTFTechniqueStatesFunctions;
  60178. }
  60179. /** @hidden */
  60180. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60181. parameters: {
  60182. [key: string]: IGLTFTechniqueParameter;
  60183. };
  60184. program: string;
  60185. attributes: {
  60186. [key: string]: string;
  60187. };
  60188. uniforms: {
  60189. [key: string]: string;
  60190. };
  60191. states: IGLTFTechniqueStates;
  60192. }
  60193. /** @hidden */
  60194. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60195. technique?: string;
  60196. values: string[];
  60197. }
  60198. /** @hidden */
  60199. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60200. attributes: {
  60201. [key: string]: string;
  60202. };
  60203. indices: string;
  60204. material: string;
  60205. mode?: number;
  60206. }
  60207. /** @hidden */
  60208. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60209. primitives: IGLTFMeshPrimitive[];
  60210. }
  60211. /** @hidden */
  60212. export interface IGLTFImage extends IGLTFChildRootProperty {
  60213. uri: string;
  60214. }
  60215. /** @hidden */
  60216. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60217. magFilter?: number;
  60218. minFilter?: number;
  60219. wrapS?: number;
  60220. wrapT?: number;
  60221. }
  60222. /** @hidden */
  60223. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60224. sampler: string;
  60225. source: string;
  60226. format?: ETextureFormat;
  60227. internalFormat?: ETextureFormat;
  60228. target?: number;
  60229. type?: number;
  60230. babylonTexture?: Texture;
  60231. }
  60232. /** @hidden */
  60233. export interface IGLTFAmbienLight {
  60234. color?: number[];
  60235. }
  60236. /** @hidden */
  60237. export interface IGLTFDirectionalLight {
  60238. color?: number[];
  60239. }
  60240. /** @hidden */
  60241. export interface IGLTFPointLight {
  60242. color?: number[];
  60243. constantAttenuation?: number;
  60244. linearAttenuation?: number;
  60245. quadraticAttenuation?: number;
  60246. }
  60247. /** @hidden */
  60248. export interface IGLTFSpotLight {
  60249. color?: number[];
  60250. constantAttenuation?: number;
  60251. fallOfAngle?: number;
  60252. fallOffExponent?: number;
  60253. linearAttenuation?: number;
  60254. quadraticAttenuation?: number;
  60255. }
  60256. /** @hidden */
  60257. export interface IGLTFLight extends IGLTFChildRootProperty {
  60258. type: string;
  60259. }
  60260. /** @hidden */
  60261. export interface IGLTFCameraOrthographic {
  60262. xmag: number;
  60263. ymag: number;
  60264. zfar: number;
  60265. znear: number;
  60266. }
  60267. /** @hidden */
  60268. export interface IGLTFCameraPerspective {
  60269. aspectRatio: number;
  60270. yfov: number;
  60271. zfar: number;
  60272. znear: number;
  60273. }
  60274. /** @hidden */
  60275. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60276. type: string;
  60277. }
  60278. /** @hidden */
  60279. export interface IGLTFAnimationChannelTarget {
  60280. id: string;
  60281. path: string;
  60282. }
  60283. /** @hidden */
  60284. export interface IGLTFAnimationChannel {
  60285. sampler: string;
  60286. target: IGLTFAnimationChannelTarget;
  60287. }
  60288. /** @hidden */
  60289. export interface IGLTFAnimationSampler {
  60290. input: string;
  60291. output: string;
  60292. interpolation?: string;
  60293. }
  60294. /** @hidden */
  60295. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60296. channels?: IGLTFAnimationChannel[];
  60297. parameters?: {
  60298. [key: string]: string;
  60299. };
  60300. samplers?: {
  60301. [key: string]: IGLTFAnimationSampler;
  60302. };
  60303. }
  60304. /** @hidden */
  60305. export interface IGLTFNodeInstanceSkin {
  60306. skeletons: string[];
  60307. skin: string;
  60308. meshes: string[];
  60309. }
  60310. /** @hidden */
  60311. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60312. bindShapeMatrix: number[];
  60313. inverseBindMatrices: string;
  60314. jointNames: string[];
  60315. babylonSkeleton?: Skeleton;
  60316. }
  60317. /** @hidden */
  60318. export interface IGLTFNode extends IGLTFChildRootProperty {
  60319. camera?: string;
  60320. children: string[];
  60321. skin?: string;
  60322. jointName?: string;
  60323. light?: string;
  60324. matrix: number[];
  60325. mesh?: string;
  60326. meshes?: string[];
  60327. rotation?: number[];
  60328. scale?: number[];
  60329. translation?: number[];
  60330. babylonNode?: Node;
  60331. }
  60332. /** @hidden */
  60333. export interface IGLTFScene extends IGLTFChildRootProperty {
  60334. nodes: string[];
  60335. }
  60336. /** @hidden */
  60337. export interface IGLTFRuntime {
  60338. extensions: {
  60339. [key: string]: any;
  60340. };
  60341. accessors: {
  60342. [key: string]: IGLTFAccessor;
  60343. };
  60344. buffers: {
  60345. [key: string]: IGLTFBuffer;
  60346. };
  60347. bufferViews: {
  60348. [key: string]: IGLTFBufferView;
  60349. };
  60350. meshes: {
  60351. [key: string]: IGLTFMesh;
  60352. };
  60353. lights: {
  60354. [key: string]: IGLTFLight;
  60355. };
  60356. cameras: {
  60357. [key: string]: IGLTFCamera;
  60358. };
  60359. nodes: {
  60360. [key: string]: IGLTFNode;
  60361. };
  60362. images: {
  60363. [key: string]: IGLTFImage;
  60364. };
  60365. textures: {
  60366. [key: string]: IGLTFTexture;
  60367. };
  60368. shaders: {
  60369. [key: string]: IGLTFShader;
  60370. };
  60371. programs: {
  60372. [key: string]: IGLTFProgram;
  60373. };
  60374. samplers: {
  60375. [key: string]: IGLTFSampler;
  60376. };
  60377. techniques: {
  60378. [key: string]: IGLTFTechnique;
  60379. };
  60380. materials: {
  60381. [key: string]: IGLTFMaterial;
  60382. };
  60383. animations: {
  60384. [key: string]: IGLTFAnimation;
  60385. };
  60386. skins: {
  60387. [key: string]: IGLTFSkins;
  60388. };
  60389. currentScene?: Object;
  60390. scenes: {
  60391. [key: string]: IGLTFScene;
  60392. };
  60393. extensionsUsed: string[];
  60394. extensionsRequired?: string[];
  60395. buffersCount: number;
  60396. shaderscount: number;
  60397. scene: Scene;
  60398. rootUrl: string;
  60399. loadedBufferCount: number;
  60400. loadedBufferViews: {
  60401. [name: string]: ArrayBufferView;
  60402. };
  60403. loadedShaderCount: number;
  60404. importOnlyMeshes: boolean;
  60405. importMeshesNames?: string[];
  60406. dummyNodes: Node[];
  60407. }
  60408. /** @hidden */
  60409. export interface INodeToRoot {
  60410. bone: Bone;
  60411. node: IGLTFNode;
  60412. id: string;
  60413. }
  60414. /** @hidden */
  60415. export interface IJointNode {
  60416. node: IGLTFNode;
  60417. id: string;
  60418. }
  60419. }
  60420. declare module BABYLON.GLTF1 {
  60421. /**
  60422. * Utils functions for GLTF
  60423. * @hidden
  60424. */
  60425. export class GLTFUtils {
  60426. /**
  60427. * Sets the given "parameter" matrix
  60428. * @param scene: the Scene object
  60429. * @param source: the source node where to pick the matrix
  60430. * @param parameter: the GLTF technique parameter
  60431. * @param uniformName: the name of the shader's uniform
  60432. * @param shaderMaterial: the shader material
  60433. */
  60434. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60435. /**
  60436. * Sets the given "parameter" matrix
  60437. * @param shaderMaterial: the shader material
  60438. * @param uniform: the name of the shader's uniform
  60439. * @param value: the value of the uniform
  60440. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60441. */
  60442. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60443. /**
  60444. * Returns the wrap mode of the texture
  60445. * @param mode: the mode value
  60446. */
  60447. static GetWrapMode(mode: number): number;
  60448. /**
  60449. * Returns the byte stride giving an accessor
  60450. * @param accessor: the GLTF accessor objet
  60451. */
  60452. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60453. /**
  60454. * Returns the texture filter mode giving a mode value
  60455. * @param mode: the filter mode value
  60456. */
  60457. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60458. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60459. /**
  60460. * Returns a buffer from its accessor
  60461. * @param gltfRuntime: the GLTF runtime
  60462. * @param accessor: the GLTF accessor
  60463. */
  60464. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60465. /**
  60466. * Decodes a buffer view into a string
  60467. * @param view: the buffer view
  60468. */
  60469. static DecodeBufferToText(view: ArrayBufferView): string;
  60470. /**
  60471. * Returns the default material of gltf. Related to
  60472. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60473. * @param scene: the Babylon.js scene
  60474. */
  60475. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60476. private static _DefaultMaterial;
  60477. }
  60478. }
  60479. declare module BABYLON.GLTF1 {
  60480. /**
  60481. * Implementation of the base glTF spec
  60482. * @hidden
  60483. */
  60484. export class GLTFLoaderBase {
  60485. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60486. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60487. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60488. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60489. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60490. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60491. }
  60492. /**
  60493. * glTF V1 Loader
  60494. * @hidden
  60495. */
  60496. export class GLTFLoader implements IGLTFLoader {
  60497. static Extensions: {
  60498. [name: string]: GLTFLoaderExtension;
  60499. };
  60500. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60501. state: Nullable<GLTFLoaderState>;
  60502. dispose(): void;
  60503. private _importMeshAsync;
  60504. /**
  60505. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60506. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60507. * @param scene the scene the meshes should be added to
  60508. * @param data gltf data containing information of the meshes in a loaded file
  60509. * @param rootUrl root url to load from
  60510. * @param onProgress event that fires when loading progress has occured
  60511. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60512. */
  60513. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60514. meshes: AbstractMesh[];
  60515. particleSystems: IParticleSystem[];
  60516. skeletons: Skeleton[];
  60517. animationGroups: AnimationGroup[];
  60518. }>;
  60519. private _loadAsync;
  60520. /**
  60521. * Imports all objects from a loaded gltf file and adds them to the scene
  60522. * @param scene the scene the objects should be added to
  60523. * @param data gltf data containing information of the meshes in a loaded file
  60524. * @param rootUrl root url to load from
  60525. * @param onProgress event that fires when loading progress has occured
  60526. * @returns a promise which completes when objects have been loaded to the scene
  60527. */
  60528. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60529. private _loadShadersAsync;
  60530. private _loadBuffersAsync;
  60531. private _createNodes;
  60532. }
  60533. /** @hidden */
  60534. export abstract class GLTFLoaderExtension {
  60535. private _name;
  60536. constructor(name: string);
  60537. readonly name: string;
  60538. /**
  60539. * Defines an override for loading the runtime
  60540. * Return true to stop further extensions from loading the runtime
  60541. */
  60542. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60543. /**
  60544. * Defines an onverride for creating gltf runtime
  60545. * Return true to stop further extensions from creating the runtime
  60546. */
  60547. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60548. /**
  60549. * Defines an override for loading buffers
  60550. * Return true to stop further extensions from loading this buffer
  60551. */
  60552. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60553. /**
  60554. * Defines an override for loading texture buffers
  60555. * Return true to stop further extensions from loading this texture data
  60556. */
  60557. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60558. /**
  60559. * Defines an override for creating textures
  60560. * Return true to stop further extensions from loading this texture
  60561. */
  60562. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60563. /**
  60564. * Defines an override for loading shader strings
  60565. * Return true to stop further extensions from loading this shader data
  60566. */
  60567. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60568. /**
  60569. * Defines an override for loading materials
  60570. * Return true to stop further extensions from loading this material
  60571. */
  60572. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60573. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60574. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60575. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60576. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60577. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60578. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60579. private static LoadTextureBufferAsync;
  60580. private static CreateTextureAsync;
  60581. private static ApplyExtensions;
  60582. }
  60583. }
  60584. declare module BABYLON.GLTF1 {
  60585. /** @hidden */
  60586. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60587. private _bin;
  60588. constructor();
  60589. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60590. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60591. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60592. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60593. }
  60594. }
  60595. declare module BABYLON.GLTF1 {
  60596. /** @hidden */
  60597. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60598. constructor();
  60599. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60600. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60601. private _loadTexture;
  60602. }
  60603. }
  60604. declare module BABYLON.GLTF2.Loader {
  60605. /**
  60606. * Loader interface with an index field.
  60607. */
  60608. export interface IArrayItem {
  60609. /**
  60610. * The index of this item in the array.
  60611. */
  60612. index: number;
  60613. }
  60614. /**
  60615. * Loader interface with additional members.
  60616. */
  60617. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60618. /** @hidden */ data?: Promise<ArrayBufferView>;
  60619. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60620. }
  60621. /**
  60622. * Loader interface with additional members.
  60623. */
  60624. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60625. }
  60626. /** @hidden */
  60627. export interface _IAnimationSamplerData {
  60628. input: Float32Array;
  60629. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60630. output: Float32Array;
  60631. }
  60632. /**
  60633. * Loader interface with additional members.
  60634. */
  60635. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60636. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60637. }
  60638. /**
  60639. * Loader interface with additional members.
  60640. */
  60641. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60642. channels: IAnimationChannel[];
  60643. samplers: IAnimationSampler[];
  60644. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60645. }
  60646. /**
  60647. * Loader interface with additional members.
  60648. */
  60649. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60650. /** @hidden */ data?: Promise<ArrayBufferView>;
  60651. }
  60652. /**
  60653. * Loader interface with additional members.
  60654. */
  60655. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60656. /** @hidden */ data?: Promise<ArrayBufferView>;
  60657. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60658. }
  60659. /**
  60660. * Loader interface with additional members.
  60661. */
  60662. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60663. }
  60664. /**
  60665. * Loader interface with additional members.
  60666. */
  60667. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60668. /** @hidden */ data?: Promise<ArrayBufferView>;
  60669. }
  60670. /**
  60671. * Loader interface with additional members.
  60672. */
  60673. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60674. }
  60675. /**
  60676. * Loader interface with additional members.
  60677. */
  60678. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60679. }
  60680. /**
  60681. * Loader interface with additional members.
  60682. */
  60683. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60684. baseColorTexture?: ITextureInfo;
  60685. metallicRoughnessTexture?: ITextureInfo;
  60686. }
  60687. /**
  60688. * Loader interface with additional members.
  60689. */
  60690. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60691. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60692. normalTexture?: IMaterialNormalTextureInfo;
  60693. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60694. emissiveTexture?: ITextureInfo;
  60695. /** @hidden */ data?: {
  60696. [babylonDrawMode: number]: {
  60697. babylonMaterial: Material;
  60698. babylonMeshes: AbstractMesh[];
  60699. promise: Promise<void>;
  60700. };
  60701. };
  60702. }
  60703. /**
  60704. * Loader interface with additional members.
  60705. */
  60706. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60707. primitives: IMeshPrimitive[];
  60708. }
  60709. /**
  60710. * Loader interface with additional members.
  60711. */
  60712. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60713. /** @hidden */ instanceData?: {
  60714. babylonSourceMesh: Mesh;
  60715. promise: Promise<any>;
  60716. };
  60717. }
  60718. /**
  60719. * Loader interface with additional members.
  60720. */
  60721. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60722. /**
  60723. * The parent glTF node.
  60724. */
  60725. parent?: INode;
  60726. /** @hidden */ babylonTransformNode?: TransformNode;
  60727. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60728. /** @hidden */ babylonBones?: Bone[];
  60729. /** @hidden */ numMorphTargets?: number;
  60730. }
  60731. /** @hidden */
  60732. export interface _ISamplerData {
  60733. noMipMaps: boolean;
  60734. samplingMode: number;
  60735. wrapU: number;
  60736. wrapV: number;
  60737. }
  60738. /**
  60739. * Loader interface with additional members.
  60740. */
  60741. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60742. /** @hidden */ data?: _ISamplerData;
  60743. }
  60744. /**
  60745. * Loader interface with additional members.
  60746. */
  60747. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60748. }
  60749. /**
  60750. * Loader interface with additional members.
  60751. */
  60752. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60753. /** @hidden */ data?: {
  60754. babylonSkeleton: Skeleton;
  60755. promise: Promise<void>;
  60756. };
  60757. }
  60758. /**
  60759. * Loader interface with additional members.
  60760. */
  60761. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60762. }
  60763. /**
  60764. * Loader interface with additional members.
  60765. */
  60766. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60767. }
  60768. /**
  60769. * Loader interface with additional members.
  60770. */
  60771. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60772. accessors?: IAccessor[];
  60773. animations?: IAnimation[];
  60774. buffers?: IBuffer[];
  60775. bufferViews?: IBufferView[];
  60776. cameras?: ICamera[];
  60777. images?: IImage[];
  60778. materials?: IMaterial[];
  60779. meshes?: IMesh[];
  60780. nodes?: INode[];
  60781. samplers?: ISampler[];
  60782. scenes?: IScene[];
  60783. skins?: ISkin[];
  60784. textures?: ITexture[];
  60785. }
  60786. }
  60787. declare module BABYLON.GLTF2 {
  60788. /**
  60789. * Interface for a glTF loader extension.
  60790. */
  60791. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60792. /**
  60793. * Called after the loader state changes to LOADING.
  60794. */
  60795. onLoading?(): void;
  60796. /**
  60797. * Called after the loader state changes to READY.
  60798. */
  60799. onReady?(): void;
  60800. /**
  60801. * Define this method to modify the default behavior when loading scenes.
  60802. * @param context The context when loading the asset
  60803. * @param scene The glTF scene property
  60804. * @returns A promise that resolves when the load is complete or null if not handled
  60805. */
  60806. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60807. /**
  60808. * Define this method to modify the default behavior when loading nodes.
  60809. * @param context The context when loading the asset
  60810. * @param node The glTF node property
  60811. * @param assign A function called synchronously after parsing the glTF properties
  60812. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60813. */
  60814. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60815. /**
  60816. * Define this method to modify the default behavior when loading cameras.
  60817. * @param context The context when loading the asset
  60818. * @param camera The glTF camera property
  60819. * @param assign A function called synchronously after parsing the glTF properties
  60820. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60821. */
  60822. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60823. /**
  60824. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60825. * @param context The context when loading the asset
  60826. * @param primitive The glTF mesh primitive property
  60827. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60828. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60829. /**
  60830. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60831. * @param context The context when loading the asset
  60832. * @param name The mesh name when loading the asset
  60833. * @param node The glTF node when loading the asset
  60834. * @param mesh The glTF mesh when loading the asset
  60835. * @param primitive The glTF mesh primitive property
  60836. * @param assign A function called synchronously after parsing the glTF properties
  60837. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60838. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60839. /**
  60840. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60841. * @param context The context when loading the asset
  60842. * @param material The glTF material property
  60843. * @param assign A function called synchronously after parsing the glTF properties
  60844. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60845. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60846. /**
  60847. * Define this method to modify the default behavior when creating materials.
  60848. * @param context The context when loading the asset
  60849. * @param material The glTF material property
  60850. * @param babylonDrawMode The draw mode for the Babylon material
  60851. * @returns The Babylon material or null if not handled
  60852. */
  60853. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60854. /**
  60855. * Define this method to modify the default behavior when loading material properties.
  60856. * @param context The context when loading the asset
  60857. * @param material The glTF material property
  60858. * @param babylonMaterial The Babylon material
  60859. * @returns A promise that resolves when the load is complete or null if not handled
  60860. */
  60861. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60862. /**
  60863. * Define this method to modify the default behavior when loading texture infos.
  60864. * @param context The context when loading the asset
  60865. * @param textureInfo The glTF texture info property
  60866. * @param assign A function called synchronously after parsing the glTF properties
  60867. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60868. */
  60869. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60870. /**
  60871. * Define this method to modify the default behavior when loading animations.
  60872. * @param context The context when loading the asset
  60873. * @param animation The glTF animation property
  60874. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60875. */
  60876. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60877. /**
  60878. * @hidden Define this method to modify the default behavior when loading skins.
  60879. * @param context The context when loading the asset
  60880. * @param node The glTF node property
  60881. * @param skin The glTF skin property
  60882. * @returns A promise that resolves when the load is complete or null if not handled
  60883. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60884. /**
  60885. * @hidden Define this method to modify the default behavior when loading uris.
  60886. * @param context The context when loading the asset
  60887. * @param property The glTF property associated with the uri
  60888. * @param uri The uri to load
  60889. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60890. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60891. }
  60892. }
  60893. declare module BABYLON.GLTF2 {
  60894. /**
  60895. * Helper class for working with arrays when loading the glTF asset
  60896. */
  60897. export class ArrayItem {
  60898. /**
  60899. * Gets an item from the given array.
  60900. * @param context The context when loading the asset
  60901. * @param array The array to get the item from
  60902. * @param index The index to the array
  60903. * @returns The array item
  60904. */
  60905. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60906. /**
  60907. * Assign an `index` field to each item of the given array.
  60908. * @param array The array of items
  60909. */
  60910. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60911. }
  60912. /**
  60913. * The glTF 2.0 loader
  60914. */
  60915. export class GLTFLoader implements IGLTFLoader {
  60916. /** @hidden */ completePromises: Promise<any>[];
  60917. private _disposed;
  60918. private _parent;
  60919. private _state;
  60920. private _extensions;
  60921. private _rootUrl;
  60922. private _fileName;
  60923. private _uniqueRootUrl;
  60924. private _gltf;
  60925. private _babylonScene;
  60926. private _rootBabylonMesh;
  60927. private _defaultBabylonMaterialData;
  60928. private _progressCallback?;
  60929. private _requests;
  60930. private static readonly _DefaultSampler;
  60931. private static _ExtensionNames;
  60932. private static _ExtensionFactories;
  60933. /**
  60934. * Registers a loader extension.
  60935. * @param name The name of the loader extension.
  60936. * @param factory The factory function that creates the loader extension.
  60937. */
  60938. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60939. /**
  60940. * Unregisters a loader extension.
  60941. * @param name The name of the loader extenion.
  60942. * @returns A boolean indicating whether the extension has been unregistered
  60943. */
  60944. static UnregisterExtension(name: string): boolean;
  60945. /**
  60946. * Gets the loader state.
  60947. */
  60948. readonly state: Nullable<GLTFLoaderState>;
  60949. /**
  60950. * The glTF object parsed from the JSON.
  60951. */
  60952. readonly gltf: IGLTF;
  60953. /**
  60954. * The Babylon scene when loading the asset.
  60955. */
  60956. readonly babylonScene: Scene;
  60957. /**
  60958. * The root Babylon mesh when loading the asset.
  60959. */
  60960. readonly rootBabylonMesh: Mesh;
  60961. /** @hidden */
  60962. constructor(parent: GLTFFileLoader);
  60963. /** @hidden */
  60964. dispose(): void;
  60965. /** @hidden */
  60966. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60967. meshes: AbstractMesh[];
  60968. particleSystems: IParticleSystem[];
  60969. skeletons: Skeleton[];
  60970. animationGroups: AnimationGroup[];
  60971. }>;
  60972. /** @hidden */
  60973. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60974. private _loadAsync;
  60975. private _loadData;
  60976. private _setupData;
  60977. private _loadExtensions;
  60978. private _checkExtensions;
  60979. private _setState;
  60980. private _createRootNode;
  60981. /**
  60982. * Loads a glTF scene.
  60983. * @param context The context when loading the asset
  60984. * @param scene The glTF scene property
  60985. * @returns A promise that resolves when the load is complete
  60986. */
  60987. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60988. private _forEachPrimitive;
  60989. private _getMeshes;
  60990. private _getSkeletons;
  60991. private _getAnimationGroups;
  60992. private _startAnimations;
  60993. /**
  60994. * Loads a glTF node.
  60995. * @param context The context when loading the asset
  60996. * @param node The glTF node property
  60997. * @param assign A function called synchronously after parsing the glTF properties
  60998. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60999. */
  61000. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  61001. private _loadMeshAsync;
  61002. /**
  61003. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  61004. * @param context The context when loading the asset
  61005. * @param name The mesh name when loading the asset
  61006. * @param node The glTF node when loading the asset
  61007. * @param mesh The glTF mesh when loading the asset
  61008. * @param primitive The glTF mesh primitive property
  61009. * @param assign A function called synchronously after parsing the glTF properties
  61010. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  61011. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  61012. private _loadVertexDataAsync;
  61013. private _createMorphTargets;
  61014. private _loadMorphTargetsAsync;
  61015. private _loadMorphTargetVertexDataAsync;
  61016. private static _LoadTransform;
  61017. private _loadSkinAsync;
  61018. private _loadBones;
  61019. private _loadBone;
  61020. private _loadSkinInverseBindMatricesDataAsync;
  61021. private _updateBoneMatrices;
  61022. private _getNodeMatrix;
  61023. /**
  61024. * Loads a glTF camera.
  61025. * @param context The context when loading the asset
  61026. * @param camera The glTF camera property
  61027. * @param assign A function called synchronously after parsing the glTF properties
  61028. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  61029. */
  61030. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  61031. private _loadAnimationsAsync;
  61032. /**
  61033. * Loads a glTF animation.
  61034. * @param context The context when loading the asset
  61035. * @param animation The glTF animation property
  61036. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  61037. */
  61038. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  61039. /**
  61040. * @hidden Loads a glTF animation channel.
  61041. * @param context The context when loading the asset
  61042. * @param animationContext The context of the animation when loading the asset
  61043. * @param animation The glTF animation property
  61044. * @param channel The glTF animation channel property
  61045. * @param babylonAnimationGroup The babylon animation group property
  61046. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  61047. * @returns A void promise when the channel load is complete
  61048. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  61049. private _loadAnimationSamplerAsync;
  61050. private _loadBufferAsync;
  61051. /**
  61052. * Loads a glTF buffer view.
  61053. * @param context The context when loading the asset
  61054. * @param bufferView The glTF buffer view property
  61055. * @returns A promise that resolves with the loaded data when the load is complete
  61056. */
  61057. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  61058. private _loadIndicesAccessorAsync;
  61059. private _loadFloatAccessorAsync;
  61060. private _loadVertexBufferViewAsync;
  61061. private _loadVertexAccessorAsync;
  61062. private _loadMaterialMetallicRoughnessPropertiesAsync;
  61063. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  61064. private _createDefaultMaterial;
  61065. /**
  61066. * Creates a Babylon material from a glTF material.
  61067. * @param context The context when loading the asset
  61068. * @param material The glTF material property
  61069. * @param babylonDrawMode The draw mode for the Babylon material
  61070. * @returns The Babylon material
  61071. */
  61072. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  61073. /**
  61074. * Loads properties from a glTF material into a Babylon material.
  61075. * @param context The context when loading the asset
  61076. * @param material The glTF material property
  61077. * @param babylonMaterial The Babylon material
  61078. * @returns A promise that resolves when the load is complete
  61079. */
  61080. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61081. /**
  61082. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  61083. * @param context The context when loading the asset
  61084. * @param material The glTF material property
  61085. * @param babylonMaterial The Babylon material
  61086. * @returns A promise that resolves when the load is complete
  61087. */
  61088. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61089. /**
  61090. * Loads the alpha properties from a glTF material into a Babylon material.
  61091. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  61092. * @param context The context when loading the asset
  61093. * @param material The glTF material property
  61094. * @param babylonMaterial The Babylon material
  61095. */
  61096. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  61097. /**
  61098. * Loads a glTF texture info.
  61099. * @param context The context when loading the asset
  61100. * @param textureInfo The glTF texture info property
  61101. * @param assign A function called synchronously after parsing the glTF properties
  61102. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  61103. */
  61104. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  61105. private _loadTextureAsync;
  61106. private _loadSampler;
  61107. /**
  61108. * Loads a glTF image.
  61109. * @param context The context when loading the asset
  61110. * @param image The glTF image property
  61111. * @returns A promise that resolves with the loaded data when the load is complete
  61112. */
  61113. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61114. /**
  61115. * Loads a glTF uri.
  61116. * @param context The context when loading the asset
  61117. * @param property The glTF property associated with the uri
  61118. * @param uri The base64 or relative uri
  61119. * @returns A promise that resolves with the loaded data when the load is complete
  61120. */
  61121. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61122. private _onProgress;
  61123. /**
  61124. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61125. * @param babylonObject the Babylon object with metadata
  61126. * @param pointer the JSON pointer
  61127. */
  61128. static AddPointerMetadata(babylonObject: {
  61129. metadata: any;
  61130. }, pointer: string): void;
  61131. private static _GetTextureWrapMode;
  61132. private static _GetTextureSamplingMode;
  61133. private static _GetTypedArray;
  61134. private static _GetNumComponents;
  61135. private static _ValidateUri;
  61136. private static _GetDrawMode;
  61137. private _compileMaterialsAsync;
  61138. private _compileShadowGeneratorsAsync;
  61139. private _forEachExtensions;
  61140. private _applyExtensions;
  61141. private _extensionsOnLoading;
  61142. private _extensionsOnReady;
  61143. private _extensionsLoadSceneAsync;
  61144. private _extensionsLoadNodeAsync;
  61145. private _extensionsLoadCameraAsync;
  61146. private _extensionsLoadVertexDataAsync;
  61147. private _extensionsLoadMeshPrimitiveAsync;
  61148. private _extensionsLoadMaterialAsync;
  61149. private _extensionsCreateMaterial;
  61150. private _extensionsLoadMaterialPropertiesAsync;
  61151. private _extensionsLoadTextureInfoAsync;
  61152. private _extensionsLoadAnimationAsync;
  61153. private _extensionsLoadSkinAsync;
  61154. private _extensionsLoadUriAsync;
  61155. /**
  61156. * Helper method called by a loader extension to load an glTF extension.
  61157. * @param context The context when loading the asset
  61158. * @param property The glTF property to load the extension from
  61159. * @param extensionName The name of the extension to load
  61160. * @param actionAsync The action to run
  61161. * @returns The promise returned by actionAsync or null if the extension does not exist
  61162. */
  61163. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61164. /**
  61165. * Helper method called by a loader extension to load a glTF extra.
  61166. * @param context The context when loading the asset
  61167. * @param property The glTF property to load the extra from
  61168. * @param extensionName The name of the extension to load
  61169. * @param actionAsync The action to run
  61170. * @returns The promise returned by actionAsync or null if the extra does not exist
  61171. */
  61172. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61173. /**
  61174. * Increments the indentation level and logs a message.
  61175. * @param message The message to log
  61176. */
  61177. logOpen(message: string): void;
  61178. /**
  61179. * Decrements the indentation level.
  61180. */
  61181. logClose(): void;
  61182. /**
  61183. * Logs a message
  61184. * @param message The message to log
  61185. */
  61186. log(message: string): void;
  61187. /**
  61188. * Starts a performance counter.
  61189. * @param counterName The name of the performance counter
  61190. */
  61191. startPerformanceCounter(counterName: string): void;
  61192. /**
  61193. * Ends a performance counter.
  61194. * @param counterName The name of the performance counter
  61195. */
  61196. endPerformanceCounter(counterName: string): void;
  61197. }
  61198. }
  61199. declare module BABYLON.GLTF2.Loader.Extensions {
  61200. /**
  61201. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61202. */
  61203. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61204. /** The name of this extension. */
  61205. readonly name: string;
  61206. /** Defines whether this extension is enabled. */
  61207. enabled: boolean;
  61208. private _loader;
  61209. private _lights?;
  61210. /** @hidden */
  61211. constructor(loader: GLTFLoader);
  61212. /** @hidden */
  61213. dispose(): void;
  61214. /** @hidden */
  61215. onLoading(): void;
  61216. /** @hidden */
  61217. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61218. private _loadLightAsync;
  61219. }
  61220. }
  61221. declare module BABYLON.GLTF2.Loader.Extensions {
  61222. /**
  61223. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61224. */
  61225. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61226. /** The name of this extension. */
  61227. readonly name: string;
  61228. /** The draco compression used to decode vertex data. */
  61229. dracoCompression?: DracoCompression;
  61230. /** Defines whether this extension is enabled. */
  61231. enabled: boolean;
  61232. private _loader;
  61233. private _dracoCompressionOwned;
  61234. /** @hidden */
  61235. constructor(loader: GLTFLoader);
  61236. /** @hidden */
  61237. dispose(): void;
  61238. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61239. }
  61240. }
  61241. declare module BABYLON.GLTF2.Loader.Extensions {
  61242. /**
  61243. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61244. */
  61245. export class KHR_lights implements IGLTFLoaderExtension {
  61246. /** The name of this extension. */
  61247. readonly name: string;
  61248. /** Defines whether this extension is enabled. */
  61249. enabled: boolean;
  61250. private _loader;
  61251. private _lights?;
  61252. /** @hidden */
  61253. constructor(loader: GLTFLoader);
  61254. /** @hidden */
  61255. dispose(): void;
  61256. /** @hidden */
  61257. onLoading(): void;
  61258. /** @hidden */
  61259. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61260. }
  61261. }
  61262. declare module BABYLON.GLTF2.Loader.Extensions {
  61263. /**
  61264. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61265. */
  61266. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61267. /** The name of this extension. */
  61268. readonly name: string;
  61269. /** Defines whether this extension is enabled. */
  61270. enabled: boolean;
  61271. private _loader;
  61272. /** @hidden */
  61273. constructor(loader: GLTFLoader);
  61274. /** @hidden */
  61275. dispose(): void;
  61276. /** @hidden */
  61277. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61278. private _loadSpecularGlossinessPropertiesAsync;
  61279. }
  61280. }
  61281. declare module BABYLON.GLTF2.Loader.Extensions {
  61282. /**
  61283. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61284. */
  61285. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61286. /** The name of this extension. */
  61287. readonly name: string;
  61288. /** Defines whether this extension is enabled. */
  61289. enabled: boolean;
  61290. private _loader;
  61291. /** @hidden */
  61292. constructor(loader: GLTFLoader);
  61293. /** @hidden */
  61294. dispose(): void;
  61295. /** @hidden */
  61296. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61297. private _loadUnlitPropertiesAsync;
  61298. }
  61299. }
  61300. declare module BABYLON.GLTF2.Loader.Extensions {
  61301. /**
  61302. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61303. */
  61304. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61305. /** The name of this extension. */
  61306. readonly name: string;
  61307. /** Defines whether this extension is enabled. */
  61308. enabled: boolean;
  61309. private _loader;
  61310. /** @hidden */
  61311. constructor(loader: GLTFLoader);
  61312. /** @hidden */
  61313. dispose(): void;
  61314. /** @hidden */
  61315. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61316. }
  61317. }
  61318. declare module BABYLON.GLTF2.Loader.Extensions {
  61319. /**
  61320. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61321. */
  61322. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61323. /** The name of this extension. */
  61324. readonly name: string;
  61325. /** Defines whether this extension is enabled. */
  61326. enabled: boolean;
  61327. private _loader;
  61328. private _clips;
  61329. private _emitters;
  61330. /** @hidden */
  61331. constructor(loader: GLTFLoader);
  61332. /** @hidden */
  61333. dispose(): void;
  61334. /** @hidden */
  61335. onLoading(): void;
  61336. /** @hidden */
  61337. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61338. /** @hidden */
  61339. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61340. /** @hidden */
  61341. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61342. private _loadClipAsync;
  61343. private _loadEmitterAsync;
  61344. private _getEventAction;
  61345. private _loadAnimationEventAsync;
  61346. }
  61347. }
  61348. declare module BABYLON.GLTF2.Loader.Extensions {
  61349. /**
  61350. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61351. */
  61352. export class MSFT_lod implements IGLTFLoaderExtension {
  61353. /** The name of this extension. */
  61354. readonly name: string;
  61355. /** Defines whether this extension is enabled. */
  61356. enabled: boolean;
  61357. /**
  61358. * Maximum number of LODs to load, starting from the lowest LOD.
  61359. */
  61360. maxLODsToLoad: number;
  61361. /**
  61362. * Observable raised when all node LODs of one level are loaded.
  61363. * The event data is the index of the loaded LOD starting from zero.
  61364. * Dispose the loader to cancel the loading of the next level of LODs.
  61365. */
  61366. onNodeLODsLoadedObservable: Observable<number>;
  61367. /**
  61368. * Observable raised when all material LODs of one level are loaded.
  61369. * The event data is the index of the loaded LOD starting from zero.
  61370. * Dispose the loader to cancel the loading of the next level of LODs.
  61371. */
  61372. onMaterialLODsLoadedObservable: Observable<number>;
  61373. private _loader;
  61374. private _nodeIndexLOD;
  61375. private _nodeSignalLODs;
  61376. private _nodePromiseLODs;
  61377. private _materialIndexLOD;
  61378. private _materialSignalLODs;
  61379. private _materialPromiseLODs;
  61380. /** @hidden */
  61381. constructor(loader: GLTFLoader);
  61382. /** @hidden */
  61383. dispose(): void;
  61384. /** @hidden */
  61385. onReady(): void;
  61386. /** @hidden */
  61387. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61388. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61389. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61390. /**
  61391. * Gets an array of LOD properties from lowest to highest.
  61392. */
  61393. private _getLODs;
  61394. private _disposeUnusedMaterials;
  61395. }
  61396. }
  61397. declare module BABYLON.GLTF2.Loader.Extensions {
  61398. /** @hidden */
  61399. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61400. readonly name: string;
  61401. enabled: boolean;
  61402. private _loader;
  61403. constructor(loader: GLTFLoader);
  61404. dispose(): void;
  61405. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61406. }
  61407. }
  61408. declare module BABYLON.GLTF2.Loader.Extensions {
  61409. /** @hidden */
  61410. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61411. readonly name: string;
  61412. enabled: boolean;
  61413. private _loader;
  61414. constructor(loader: GLTFLoader);
  61415. dispose(): void;
  61416. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61417. }
  61418. }
  61419. declare module BABYLON {
  61420. /**
  61421. * Class reading and parsing the MTL file bundled with the obj file.
  61422. */
  61423. export class MTLFileLoader {
  61424. /**
  61425. * All material loaded from the mtl will be set here
  61426. */
  61427. materials: StandardMaterial[];
  61428. /**
  61429. * This function will read the mtl file and create each material described inside
  61430. * This function could be improve by adding :
  61431. * -some component missing (Ni, Tf...)
  61432. * -including the specific options available
  61433. *
  61434. * @param scene defines the scene the material will be created in
  61435. * @param data defines the mtl data to parse
  61436. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61437. */
  61438. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61439. /**
  61440. * Gets the texture for the material.
  61441. *
  61442. * If the material is imported from input file,
  61443. * We sanitize the url to ensure it takes the textre from aside the material.
  61444. *
  61445. * @param rootUrl The root url to load from
  61446. * @param value The value stored in the mtl
  61447. * @return The Texture
  61448. */
  61449. private static _getTexture;
  61450. }
  61451. /**
  61452. * Options for loading OBJ/MTL files
  61453. */
  61454. type MeshLoadOptions = {
  61455. /**
  61456. * Defines if UVs are optimized by default during load.
  61457. */
  61458. OptimizeWithUV: boolean;
  61459. /**
  61460. * Defines custom scaling of UV coordinates of loaded meshes.
  61461. */
  61462. UVScaling: Vector2;
  61463. /**
  61464. * Invert model on y-axis (does a model scaling inversion)
  61465. */
  61466. InvertY: boolean;
  61467. /**
  61468. * Invert Y-Axis of referenced textures on load
  61469. */
  61470. InvertTextureY: boolean;
  61471. /**
  61472. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61473. */
  61474. ImportVertexColors: boolean;
  61475. /**
  61476. * Compute the normals for the model, even if normals are present in the file.
  61477. */
  61478. ComputeNormals: boolean;
  61479. /**
  61480. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61481. */
  61482. SkipMaterials: boolean;
  61483. /**
  61484. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61485. */
  61486. MaterialLoadingFailsSilently: boolean;
  61487. };
  61488. /**
  61489. * OBJ file type loader.
  61490. * This is a babylon scene loader plugin.
  61491. */
  61492. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61493. /**
  61494. * Defines if UVs are optimized by default during load.
  61495. */
  61496. static OPTIMIZE_WITH_UV: boolean;
  61497. /**
  61498. * Invert model on y-axis (does a model scaling inversion)
  61499. */
  61500. static INVERT_Y: boolean;
  61501. /**
  61502. * Invert Y-Axis of referenced textures on load
  61503. */
  61504. static INVERT_TEXTURE_Y: boolean;
  61505. /**
  61506. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61507. */
  61508. static IMPORT_VERTEX_COLORS: boolean;
  61509. /**
  61510. * Compute the normals for the model, even if normals are present in the file.
  61511. */
  61512. static COMPUTE_NORMALS: boolean;
  61513. /**
  61514. * Defines custom scaling of UV coordinates of loaded meshes.
  61515. */
  61516. static UV_SCALING: Vector2;
  61517. /**
  61518. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61519. */
  61520. static SKIP_MATERIALS: boolean;
  61521. /**
  61522. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61523. *
  61524. * Defaults to true for backwards compatibility.
  61525. */
  61526. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61527. /**
  61528. * Defines the name of the plugin.
  61529. */
  61530. name: string;
  61531. /**
  61532. * Defines the extension the plugin is able to load.
  61533. */
  61534. extensions: string;
  61535. /** @hidden */
  61536. obj: RegExp;
  61537. /** @hidden */
  61538. group: RegExp;
  61539. /** @hidden */
  61540. mtllib: RegExp;
  61541. /** @hidden */
  61542. usemtl: RegExp;
  61543. /** @hidden */
  61544. smooth: RegExp;
  61545. /** @hidden */
  61546. vertexPattern: RegExp;
  61547. /** @hidden */
  61548. normalPattern: RegExp;
  61549. /** @hidden */
  61550. uvPattern: RegExp;
  61551. /** @hidden */
  61552. facePattern1: RegExp;
  61553. /** @hidden */
  61554. facePattern2: RegExp;
  61555. /** @hidden */
  61556. facePattern3: RegExp;
  61557. /** @hidden */
  61558. facePattern4: RegExp;
  61559. /** @hidden */
  61560. facePattern5: RegExp;
  61561. private _meshLoadOptions;
  61562. /**
  61563. * Creates loader for .OBJ files
  61564. *
  61565. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61566. */
  61567. constructor(meshLoadOptions?: MeshLoadOptions);
  61568. private static readonly currentMeshLoadOptions;
  61569. /**
  61570. * Calls synchronously the MTL file attached to this obj.
  61571. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61572. * Without this function materials are not displayed in the first frame (but displayed after).
  61573. * In consequence it is impossible to get material information in your HTML file
  61574. *
  61575. * @param url The URL of the MTL file
  61576. * @param rootUrl
  61577. * @param onSuccess Callback function to be called when the MTL file is loaded
  61578. * @private
  61579. */
  61580. private _loadMTL;
  61581. /**
  61582. * Instantiates a OBJ file loader plugin.
  61583. * @returns the created plugin
  61584. */
  61585. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61586. /**
  61587. * If the data string can be loaded directly.
  61588. *
  61589. * @param data string containing the file data
  61590. * @returns if the data can be loaded directly
  61591. */
  61592. canDirectLoad(data: string): boolean;
  61593. /**
  61594. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61595. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61596. * @param scene the scene the meshes should be added to
  61597. * @param data the OBJ data to load
  61598. * @param rootUrl root url to load from
  61599. * @param onProgress event that fires when loading progress has occured
  61600. * @param fileName Defines the name of the file to load
  61601. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61602. */
  61603. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61604. meshes: AbstractMesh[];
  61605. particleSystems: IParticleSystem[];
  61606. skeletons: Skeleton[];
  61607. animationGroups: AnimationGroup[];
  61608. }>;
  61609. /**
  61610. * Imports all objects from the loaded OBJ data and adds them to the scene
  61611. * @param scene the scene the objects should be added to
  61612. * @param data the OBJ data to load
  61613. * @param rootUrl root url to load from
  61614. * @param onProgress event that fires when loading progress has occured
  61615. * @param fileName Defines the name of the file to load
  61616. * @returns a promise which completes when objects have been loaded to the scene
  61617. */
  61618. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61619. /**
  61620. * Load into an asset container.
  61621. * @param scene The scene to load into
  61622. * @param data The data to import
  61623. * @param rootUrl The root url for scene and resources
  61624. * @param onProgress The callback when the load progresses
  61625. * @param fileName Defines the name of the file to load
  61626. * @returns The loaded asset container
  61627. */
  61628. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61629. /**
  61630. * Read the OBJ file and create an Array of meshes.
  61631. * Each mesh contains all information given by the OBJ and the MTL file.
  61632. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61633. *
  61634. * @param meshesNames
  61635. * @param scene Scene The scene where are displayed the data
  61636. * @param data String The content of the obj file
  61637. * @param rootUrl String The path to the folder
  61638. * @returns Array<AbstractMesh>
  61639. * @private
  61640. */
  61641. private _parseSolid;
  61642. }
  61643. }
  61644. declare module BABYLON {
  61645. /**
  61646. * STL file type loader.
  61647. * This is a babylon scene loader plugin.
  61648. */
  61649. export class STLFileLoader implements ISceneLoaderPlugin {
  61650. /** @hidden */
  61651. solidPattern: RegExp;
  61652. /** @hidden */
  61653. facetsPattern: RegExp;
  61654. /** @hidden */
  61655. normalPattern: RegExp;
  61656. /** @hidden */
  61657. vertexPattern: RegExp;
  61658. /**
  61659. * Defines the name of the plugin.
  61660. */
  61661. name: string;
  61662. /**
  61663. * Defines the extensions the stl loader is able to load.
  61664. * force data to come in as an ArrayBuffer
  61665. * we'll convert to string if it looks like it's an ASCII .stl
  61666. */
  61667. extensions: ISceneLoaderPluginExtensions;
  61668. /**
  61669. * Import meshes into a scene.
  61670. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61671. * @param scene The scene to import into
  61672. * @param data The data to import
  61673. * @param rootUrl The root url for scene and resources
  61674. * @param meshes The meshes array to import into
  61675. * @param particleSystems The particle systems array to import into
  61676. * @param skeletons The skeletons array to import into
  61677. * @param onError The callback when import fails
  61678. * @returns True if successful or false otherwise
  61679. */
  61680. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61681. /**
  61682. * Load into a scene.
  61683. * @param scene The scene to load into
  61684. * @param data The data to import
  61685. * @param rootUrl The root url for scene and resources
  61686. * @param onError The callback when import fails
  61687. * @returns true if successful or false otherwise
  61688. */
  61689. load(scene: Scene, data: any, rootUrl: string): boolean;
  61690. /**
  61691. * Load into an asset container.
  61692. * @param scene The scene to load into
  61693. * @param data The data to import
  61694. * @param rootUrl The root url for scene and resources
  61695. * @param onError The callback when import fails
  61696. * @returns The loaded asset container
  61697. */
  61698. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61699. private _isBinary;
  61700. private _parseBinary;
  61701. private _parseASCII;
  61702. }
  61703. }
  61704. declare module BABYLON {
  61705. /**
  61706. * Class for generating OBJ data from a Babylon scene.
  61707. */
  61708. export class OBJExport {
  61709. /**
  61710. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61711. * @param mesh defines the list of meshes to serialize
  61712. * @param materials defines if materials should be exported
  61713. * @param matlibname defines the name of the associated mtl file
  61714. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61715. * @returns the OBJ content
  61716. */
  61717. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61718. /**
  61719. * Exports the material(s) of a mesh in .MTL file format (text)
  61720. * @param mesh defines the mesh to extract the material from
  61721. * @returns the mtl content
  61722. */
  61723. static MTL(mesh: Mesh): string;
  61724. }
  61725. }
  61726. declare module BABYLON {
  61727. /** @hidden */
  61728. export var __IGLTFExporterExtension: number;
  61729. /**
  61730. * Interface for extending the exporter
  61731. * @hidden
  61732. */
  61733. export interface IGLTFExporterExtension {
  61734. /**
  61735. * The name of this extension
  61736. */
  61737. readonly name: string;
  61738. /**
  61739. * Defines whether this extension is enabled
  61740. */
  61741. enabled: boolean;
  61742. /**
  61743. * Defines whether this extension is required
  61744. */
  61745. required: boolean;
  61746. }
  61747. }
  61748. declare module BABYLON.GLTF2.Exporter {
  61749. /** @hidden */
  61750. export var __IGLTFExporterExtensionV2: number;
  61751. /**
  61752. * Interface for a glTF exporter extension
  61753. * @hidden
  61754. */
  61755. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61756. /**
  61757. * Define this method to modify the default behavior before exporting a texture
  61758. * @param context The context when loading the asset
  61759. * @param babylonTexture The glTF texture info property
  61760. * @param mimeType The mime-type of the generated image
  61761. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61762. */
  61763. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61764. /**
  61765. * Define this method to modify the default behavior when exporting texture info
  61766. * @param context The context when loading the asset
  61767. * @param meshPrimitive glTF mesh primitive
  61768. * @param babylonSubMesh Babylon submesh
  61769. * @param binaryWriter glTF serializer binary writer instance
  61770. * @returns nullable IMeshPrimitive promise
  61771. */
  61772. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61773. /**
  61774. * Define this method to modify the default behavior when exporting a node
  61775. * @param context The context when exporting the node
  61776. * @param node glTF node
  61777. * @param babylonNode BabylonJS node
  61778. * @returns nullable INode promise
  61779. */
  61780. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61781. /**
  61782. * Called after the exporter state changes to EXPORTING
  61783. */
  61784. onExporting?(): void;
  61785. }
  61786. }
  61787. declare module BABYLON.GLTF2.Exporter {
  61788. /**
  61789. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61790. * @hidden
  61791. */
  61792. export class _GLTFMaterialExporter {
  61793. /**
  61794. * Represents the dielectric specular values for R, G and B
  61795. */
  61796. private static readonly _DielectricSpecular;
  61797. /**
  61798. * Allows the maximum specular power to be defined for material calculations
  61799. */
  61800. private static readonly _MaxSpecularPower;
  61801. /**
  61802. * Mapping to store textures
  61803. */
  61804. private _textureMap;
  61805. /**
  61806. * Numeric tolerance value
  61807. */
  61808. private static readonly _Epsilon;
  61809. /**
  61810. * Reference to the glTF Exporter
  61811. */
  61812. private _exporter;
  61813. constructor(exporter: _Exporter);
  61814. /**
  61815. * Specifies if two colors are approximately equal in value
  61816. * @param color1 first color to compare to
  61817. * @param color2 second color to compare to
  61818. * @param epsilon threshold value
  61819. */
  61820. private static FuzzyEquals;
  61821. /**
  61822. * Gets the materials from a Babylon scene and converts them to glTF materials
  61823. * @param scene babylonjs scene
  61824. * @param mimeType texture mime type
  61825. * @param images array of images
  61826. * @param textures array of textures
  61827. * @param materials array of materials
  61828. * @param imageData mapping of texture names to base64 textures
  61829. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61830. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61831. /**
  61832. * Makes a copy of the glTF material without the texture parameters
  61833. * @param originalMaterial original glTF material
  61834. * @returns glTF material without texture parameters
  61835. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61836. /**
  61837. * Specifies if the material has any texture parameters present
  61838. * @param material glTF Material
  61839. * @returns boolean specifying if texture parameters are present
  61840. */ hasTexturesPresent(material: IMaterial): boolean;
  61841. /**
  61842. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61843. * @param babylonStandardMaterial
  61844. * @returns glTF Metallic Roughness Material representation
  61845. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61846. /**
  61847. * Computes the metallic factor
  61848. * @param diffuse diffused value
  61849. * @param specular specular value
  61850. * @param oneMinusSpecularStrength one minus the specular strength
  61851. * @returns metallic value
  61852. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61853. /**
  61854. * Gets the glTF alpha mode from the Babylon Material
  61855. * @param babylonMaterial Babylon Material
  61856. * @returns The Babylon alpha mode value
  61857. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61858. /**
  61859. * Converts a Babylon Standard Material to a glTF Material
  61860. * @param babylonStandardMaterial BJS Standard Material
  61861. * @param mimeType mime type to use for the textures
  61862. * @param images array of glTF image interfaces
  61863. * @param textures array of glTF texture interfaces
  61864. * @param materials array of glTF material interfaces
  61865. * @param imageData map of image file name to data
  61866. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61867. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61868. /**
  61869. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61870. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61871. * @param mimeType mime type to use for the textures
  61872. * @param images array of glTF image interfaces
  61873. * @param textures array of glTF texture interfaces
  61874. * @param materials array of glTF material interfaces
  61875. * @param imageData map of image file name to data
  61876. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61877. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61878. /**
  61879. * Converts an image typed array buffer to a base64 image
  61880. * @param buffer typed array buffer
  61881. * @param width width of the image
  61882. * @param height height of the image
  61883. * @param mimeType mimetype of the image
  61884. * @returns base64 image string
  61885. */
  61886. private _createBase64FromCanvasAsync;
  61887. /**
  61888. * Generates a white texture based on the specified width and height
  61889. * @param width width of the texture in pixels
  61890. * @param height height of the texture in pixels
  61891. * @param scene babylonjs scene
  61892. * @returns white texture
  61893. */
  61894. private _createWhiteTexture;
  61895. /**
  61896. * 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
  61897. * @param texture1 first texture to resize
  61898. * @param texture2 second texture to resize
  61899. * @param scene babylonjs scene
  61900. * @returns resized textures or null
  61901. */
  61902. private _resizeTexturesToSameDimensions;
  61903. /**
  61904. * Converts an array of pixels to a Float32Array
  61905. * Throws an error if the pixel format is not supported
  61906. * @param pixels - array buffer containing pixel values
  61907. * @returns Float32 of pixels
  61908. */
  61909. private _convertPixelArrayToFloat32;
  61910. /**
  61911. * Convert Specular Glossiness Textures to Metallic Roughness
  61912. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61913. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61914. * @param diffuseTexture texture used to store diffuse information
  61915. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61916. * @param factors specular glossiness material factors
  61917. * @param mimeType the mime type to use for the texture
  61918. * @returns pbr metallic roughness interface or null
  61919. */
  61920. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61921. /**
  61922. * Converts specular glossiness material properties to metallic roughness
  61923. * @param specularGlossiness interface with specular glossiness material properties
  61924. * @returns interface with metallic roughness material properties
  61925. */
  61926. private _convertSpecularGlossinessToMetallicRoughness;
  61927. /**
  61928. * Calculates the surface reflectance, independent of lighting conditions
  61929. * @param color Color source to calculate brightness from
  61930. * @returns number representing the perceived brightness, or zero if color is undefined
  61931. */
  61932. private _getPerceivedBrightness;
  61933. /**
  61934. * Returns the maximum color component value
  61935. * @param color
  61936. * @returns maximum color component value, or zero if color is null or undefined
  61937. */
  61938. private _getMaxComponent;
  61939. /**
  61940. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61941. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61942. * @param mimeType mime type to use for the textures
  61943. * @param images array of glTF image interfaces
  61944. * @param textures array of glTF texture interfaces
  61945. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61946. * @param imageData map of image file name to data
  61947. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61948. * @returns glTF PBR Metallic Roughness factors
  61949. */
  61950. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61951. private _getGLTFTextureSampler;
  61952. private _getGLTFTextureWrapMode;
  61953. private _getGLTFTextureWrapModesSampler;
  61954. /**
  61955. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61956. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61957. * @param mimeType mime type to use for the textures
  61958. * @param images array of glTF image interfaces
  61959. * @param textures array of glTF texture interfaces
  61960. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61961. * @param imageData map of image file name to data
  61962. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61963. * @returns glTF PBR Metallic Roughness factors
  61964. */
  61965. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61966. /**
  61967. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61968. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61969. * @param mimeType mime type to use for the textures
  61970. * @param images array of glTF image interfaces
  61971. * @param textures array of glTF texture interfaces
  61972. * @param materials array of glTF material interfaces
  61973. * @param imageData map of image file name to data
  61974. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61975. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61976. private setMetallicRoughnessPbrMaterial;
  61977. private getPixelsFromTexture;
  61978. /**
  61979. * Extracts a texture from a Babylon texture into file data and glTF data
  61980. * @param babylonTexture Babylon texture to extract
  61981. * @param mimeType Mime Type of the babylonTexture
  61982. * @return glTF texture info, or null if the texture format is not supported
  61983. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61984. /**
  61985. * Builds a texture from base64 string
  61986. * @param base64Texture base64 texture string
  61987. * @param baseTextureName Name to use for the texture
  61988. * @param mimeType image mime type for the texture
  61989. * @param images array of images
  61990. * @param textures array of textures
  61991. * @param imageData map of image data
  61992. * @returns glTF texture info, or null if the texture format is not supported
  61993. */
  61994. private _getTextureInfoFromBase64;
  61995. }
  61996. }
  61997. declare module BABYLON {
  61998. /**
  61999. * Class for holding and downloading glTF file data
  62000. */
  62001. export class GLTFData {
  62002. /**
  62003. * Object which contains the file name as the key and its data as the value
  62004. */
  62005. glTFFiles: {
  62006. [fileName: string]: string | Blob;
  62007. };
  62008. /**
  62009. * Initializes the glTF file object
  62010. */
  62011. constructor();
  62012. /**
  62013. * Downloads the glTF data as files based on their names and data
  62014. */
  62015. downloadFiles(): void;
  62016. }
  62017. }
  62018. declare module BABYLON {
  62019. /**
  62020. * Holds a collection of exporter options and parameters
  62021. */
  62022. export interface IExportOptions {
  62023. /**
  62024. * Function which indicates whether a babylon node should be exported or not
  62025. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  62026. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  62027. */
  62028. shouldExportNode?(node: Node): boolean;
  62029. /**
  62030. * The sample rate to bake animation curves
  62031. */
  62032. animationSampleRate?: number;
  62033. /**
  62034. * Begin serialization without waiting for the scene to be ready
  62035. */
  62036. exportWithoutWaitingForScene?: boolean;
  62037. }
  62038. /**
  62039. * Class for generating glTF data from a Babylon scene.
  62040. */
  62041. export class GLTF2Export {
  62042. /**
  62043. * Exports the geometry of the scene to .gltf file format asynchronously
  62044. * @param scene Babylon scene with scene hierarchy information
  62045. * @param filePrefix File prefix to use when generating the glTF file
  62046. * @param options Exporter options
  62047. * @returns Returns an object with a .gltf file and associates texture names
  62048. * as keys and their data and paths as values
  62049. */
  62050. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62051. private static _PreExportAsync;
  62052. private static _PostExportAsync;
  62053. /**
  62054. * Exports the geometry of the scene to .glb file format asychronously
  62055. * @param scene Babylon scene with scene hierarchy information
  62056. * @param filePrefix File prefix to use when generating glb file
  62057. * @param options Exporter options
  62058. * @returns Returns an object with a .glb filename as key and data as value
  62059. */
  62060. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62061. }
  62062. }
  62063. declare module BABYLON.GLTF2.Exporter {
  62064. /**
  62065. * @hidden
  62066. */
  62067. export class _GLTFUtilities {
  62068. /**
  62069. * Creates a buffer view based on the supplied arguments
  62070. * @param bufferIndex index value of the specified buffer
  62071. * @param byteOffset byte offset value
  62072. * @param byteLength byte length of the bufferView
  62073. * @param byteStride byte distance between conequential elements
  62074. * @param name name of the buffer view
  62075. * @returns bufferView for glTF
  62076. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  62077. /**
  62078. * Creates an accessor based on the supplied arguments
  62079. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  62080. * @param name The name of the accessor
  62081. * @param type The type of the accessor
  62082. * @param componentType The datatype of components in the attribute
  62083. * @param count The number of attributes referenced by this accessor
  62084. * @param byteOffset The offset relative to the start of the bufferView in bytes
  62085. * @param min Minimum value of each component in this attribute
  62086. * @param max Maximum value of each component in this attribute
  62087. * @returns accessor for glTF
  62088. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  62089. /**
  62090. * Calculates the minimum and maximum values of an array of position floats
  62091. * @param positions Positions array of a mesh
  62092. * @param vertexStart Starting vertex offset to calculate min and max values
  62093. * @param vertexCount Number of vertices to check for min and max values
  62094. * @returns min number array and max number array
  62095. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  62096. min: number[];
  62097. max: number[];
  62098. };
  62099. /**
  62100. * Converts a new right-handed Vector3
  62101. * @param vector vector3 array
  62102. * @returns right-handed Vector3
  62103. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  62104. /**
  62105. * Converts a Vector3 to right-handed
  62106. * @param vector Vector3 to convert to right-handed
  62107. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  62108. /**
  62109. * Converts a three element number array to right-handed
  62110. * @param vector number array to convert to right-handed
  62111. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  62112. /**
  62113. * Converts a new right-handed Vector3
  62114. * @param vector vector3 array
  62115. * @returns right-handed Vector3
  62116. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  62117. /**
  62118. * Converts a Vector3 to right-handed
  62119. * @param vector Vector3 to convert to right-handed
  62120. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  62121. /**
  62122. * Converts a three element number array to right-handed
  62123. * @param vector number array to convert to right-handed
  62124. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  62125. /**
  62126. * Converts a Vector4 to right-handed
  62127. * @param vector Vector4 to convert to right-handed
  62128. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62129. /**
  62130. * Converts a Vector4 to right-handed
  62131. * @param vector Vector4 to convert to right-handed
  62132. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62133. /**
  62134. * Converts a Quaternion to right-handed
  62135. * @param quaternion Source quaternion to convert to right-handed
  62136. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62137. /**
  62138. * Converts a Quaternion to right-handed
  62139. * @param quaternion Source quaternion to convert to right-handed
  62140. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62141. }
  62142. }
  62143. declare module BABYLON.GLTF2.Exporter {
  62144. /**
  62145. * Converts Babylon Scene into glTF 2.0.
  62146. * @hidden
  62147. */
  62148. export class _Exporter {
  62149. /**
  62150. * Stores the glTF to export
  62151. */ glTF: IGLTF;
  62152. /**
  62153. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62154. */ bufferViews: IBufferView[];
  62155. /**
  62156. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62157. */ accessors: IAccessor[];
  62158. /**
  62159. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62160. */
  62161. private _nodes;
  62162. /**
  62163. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62164. */
  62165. private _scenes;
  62166. /**
  62167. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62168. */
  62169. private _meshes;
  62170. /**
  62171. * Stores all the generated material information, which represents the appearance of each primitive
  62172. */ materials: IMaterial[]; materialMap: {
  62173. [materialID: number]: number;
  62174. };
  62175. /**
  62176. * Stores all the generated texture information, which is referenced by glTF materials
  62177. */ textures: ITexture[];
  62178. /**
  62179. * Stores all the generated image information, which is referenced by glTF textures
  62180. */ images: IImage[];
  62181. /**
  62182. * Stores all the texture samplers
  62183. */ samplers: ISampler[];
  62184. /**
  62185. * Stores all the generated animation samplers, which is referenced by glTF animations
  62186. */
  62187. /**
  62188. * Stores the animations for glTF models
  62189. */
  62190. private _animations;
  62191. /**
  62192. * Stores the total amount of bytes stored in the glTF buffer
  62193. */
  62194. private _totalByteLength;
  62195. /**
  62196. * Stores a reference to the Babylon scene containing the source geometry and material information
  62197. */ babylonScene: Scene;
  62198. /**
  62199. * Stores a map of the image data, where the key is the file name and the value
  62200. * is the image data
  62201. */ imageData: {
  62202. [fileName: string]: {
  62203. data: Uint8Array;
  62204. mimeType: ImageMimeType;
  62205. };
  62206. };
  62207. /**
  62208. * Stores a map of the unique id of a node to its index in the node array
  62209. */
  62210. private _nodeMap;
  62211. /**
  62212. * Specifies if the Babylon scene should be converted to right-handed on export
  62213. */ convertToRightHandedSystem: boolean;
  62214. /**
  62215. * Baked animation sample rate
  62216. */
  62217. private _animationSampleRate;
  62218. /**
  62219. * Callback which specifies if a node should be exported or not
  62220. */
  62221. private _shouldExportNode;
  62222. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62223. private _extensions;
  62224. private static _ExtensionNames;
  62225. private static _ExtensionFactories;
  62226. 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>>;
  62227. private _forEachExtensions;
  62228. private _extensionsOnExporting;
  62229. /**
  62230. * Load glTF serializer extensions
  62231. */
  62232. private _loadExtensions;
  62233. /**
  62234. * Creates a glTF Exporter instance, which can accept optional exporter options
  62235. * @param babylonScene Babylon scene object
  62236. * @param options Options to modify the behavior of the exporter
  62237. */
  62238. constructor(babylonScene: Scene, options?: IExportOptions);
  62239. /**
  62240. * Registers a glTF exporter extension
  62241. * @param name Name of the extension to export
  62242. * @param factory The factory function that creates the exporter extension
  62243. */
  62244. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62245. /**
  62246. * Un-registers an exporter extension
  62247. * @param name The name fo the exporter extension
  62248. * @returns A boolean indicating whether the extension has been un-registered
  62249. */
  62250. static UnregisterExtension(name: string): boolean;
  62251. /**
  62252. * Lazy load a local engine with premultiplied alpha set to false
  62253. */ getLocalEngine(): Engine;
  62254. private reorderIndicesBasedOnPrimitiveMode;
  62255. /**
  62256. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62257. * clock-wise during export to glTF
  62258. * @param submesh BabylonJS submesh
  62259. * @param primitiveMode Primitive mode of the mesh
  62260. * @param sideOrientation the winding order of the submesh
  62261. * @param vertexBufferKind The type of vertex attribute
  62262. * @param meshAttributeArray The vertex attribute data
  62263. * @param byteOffset The offset to the binary data
  62264. * @param binaryWriter The binary data for the glTF file
  62265. */
  62266. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62267. /**
  62268. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62269. * clock-wise during export to glTF
  62270. * @param submesh BabylonJS submesh
  62271. * @param primitiveMode Primitive mode of the mesh
  62272. * @param sideOrientation the winding order of the submesh
  62273. * @param vertexBufferKind The type of vertex attribute
  62274. * @param meshAttributeArray The vertex attribute data
  62275. * @param byteOffset The offset to the binary data
  62276. * @param binaryWriter The binary data for the glTF file
  62277. */
  62278. private reorderTriangleFillMode;
  62279. /**
  62280. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62281. * clock-wise during export to glTF
  62282. * @param submesh BabylonJS submesh
  62283. * @param primitiveMode Primitive mode of the mesh
  62284. * @param sideOrientation the winding order of the submesh
  62285. * @param vertexBufferKind The type of vertex attribute
  62286. * @param meshAttributeArray The vertex attribute data
  62287. * @param byteOffset The offset to the binary data
  62288. * @param binaryWriter The binary data for the glTF file
  62289. */
  62290. private reorderTriangleStripDrawMode;
  62291. /**
  62292. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62293. * clock-wise during export to glTF
  62294. * @param submesh BabylonJS submesh
  62295. * @param primitiveMode Primitive mode of the mesh
  62296. * @param sideOrientation the winding order of the submesh
  62297. * @param vertexBufferKind The type of vertex attribute
  62298. * @param meshAttributeArray The vertex attribute data
  62299. * @param byteOffset The offset to the binary data
  62300. * @param binaryWriter The binary data for the glTF file
  62301. */
  62302. private reorderTriangleFanMode;
  62303. /**
  62304. * Writes the vertex attribute data to binary
  62305. * @param vertices The vertices to write to the binary writer
  62306. * @param byteOffset The offset into the binary writer to overwrite binary data
  62307. * @param vertexAttributeKind The vertex attribute type
  62308. * @param meshAttributeArray The vertex attribute data
  62309. * @param binaryWriter The writer containing the binary data
  62310. */
  62311. private writeVertexAttributeData;
  62312. /**
  62313. * Writes mesh attribute data to a data buffer
  62314. * Returns the bytelength of the data
  62315. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62316. * @param meshAttributeArray Array containing the attribute data
  62317. * @param binaryWriter The buffer to write the binary data to
  62318. * @param indices Used to specify the order of the vertex data
  62319. */
  62320. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62321. /**
  62322. * Generates glTF json data
  62323. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62324. * @param glTFPrefix Text to use when prefixing a glTF file
  62325. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62326. * @returns json data as string
  62327. */
  62328. private generateJSON;
  62329. /**
  62330. * Generates data for .gltf and .bin files based on the glTF prefix string
  62331. * @param glTFPrefix Text to use when prefixing a glTF file
  62332. * @returns GLTFData with glTF file data
  62333. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62334. /**
  62335. * Creates a binary buffer for glTF
  62336. * @returns array buffer for binary data
  62337. */
  62338. private _generateBinaryAsync;
  62339. /**
  62340. * Pads the number to a multiple of 4
  62341. * @param num number to pad
  62342. * @returns padded number
  62343. */
  62344. private _getPadding;
  62345. /**
  62346. * Generates a glb file from the json and binary data
  62347. * Returns an object with the glb file name as the key and data as the value
  62348. * @param glTFPrefix
  62349. * @returns object with glb filename as key and data as value
  62350. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62351. /**
  62352. * Sets the TRS for each node
  62353. * @param node glTF Node for storing the transformation data
  62354. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62355. */
  62356. private setNodeTransformation;
  62357. private getVertexBufferFromMesh;
  62358. /**
  62359. * Creates a bufferview based on the vertices type for the Babylon mesh
  62360. * @param kind Indicates the type of vertices data
  62361. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62362. * @param binaryWriter The buffer to write the bufferview data to
  62363. */
  62364. private createBufferViewKind;
  62365. /**
  62366. * The primitive mode of the Babylon mesh
  62367. * @param babylonMesh The BabylonJS mesh
  62368. */
  62369. private getMeshPrimitiveMode;
  62370. /**
  62371. * Sets the primitive mode of the glTF mesh primitive
  62372. * @param meshPrimitive glTF mesh primitive
  62373. * @param primitiveMode The primitive mode
  62374. */
  62375. private setPrimitiveMode;
  62376. /**
  62377. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62378. * @param meshPrimitive glTF mesh primitive
  62379. * @param attributeKind vertex attribute
  62380. * @returns boolean specifying if uv coordinates are present
  62381. */
  62382. private setAttributeKind;
  62383. /**
  62384. * Sets data for the primitive attributes of each submesh
  62385. * @param mesh glTF Mesh object to store the primitive attribute information
  62386. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62387. * @param binaryWriter Buffer to write the attribute data to
  62388. */
  62389. private setPrimitiveAttributesAsync;
  62390. /**
  62391. * Creates a glTF scene based on the array of meshes
  62392. * Returns the the total byte offset
  62393. * @param babylonScene Babylon scene to get the mesh data from
  62394. * @param binaryWriter Buffer to write binary data to
  62395. */
  62396. private createSceneAsync;
  62397. /**
  62398. * Creates a mapping of Node unique id to node index and handles animations
  62399. * @param babylonScene Babylon Scene
  62400. * @param nodes Babylon transform nodes
  62401. * @param shouldExportNode Callback specifying if a transform node should be exported
  62402. * @param binaryWriter Buffer to write binary data to
  62403. * @returns Node mapping of unique id to index
  62404. */
  62405. private createNodeMapAndAnimationsAsync;
  62406. /**
  62407. * Creates a glTF node from a Babylon mesh
  62408. * @param babylonMesh Source Babylon mesh
  62409. * @param binaryWriter Buffer for storing geometry data
  62410. * @returns glTF node
  62411. */
  62412. private createNodeAsync;
  62413. }
  62414. /**
  62415. * @hidden
  62416. *
  62417. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62418. */
  62419. export class _BinaryWriter {
  62420. /**
  62421. * Array buffer which stores all binary data
  62422. */
  62423. private _arrayBuffer;
  62424. /**
  62425. * View of the array buffer
  62426. */
  62427. private _dataView;
  62428. /**
  62429. * byte offset of data in array buffer
  62430. */
  62431. private _byteOffset;
  62432. /**
  62433. * Initialize binary writer with an initial byte length
  62434. * @param byteLength Initial byte length of the array buffer
  62435. */
  62436. constructor(byteLength: number);
  62437. /**
  62438. * Resize the array buffer to the specified byte length
  62439. * @param byteLength
  62440. */
  62441. private resizeBuffer;
  62442. /**
  62443. * Get an array buffer with the length of the byte offset
  62444. * @returns ArrayBuffer resized to the byte offset
  62445. */
  62446. getArrayBuffer(): ArrayBuffer;
  62447. /**
  62448. * Get the byte offset of the array buffer
  62449. * @returns byte offset
  62450. */
  62451. getByteOffset(): number;
  62452. /**
  62453. * Stores an UInt8 in the array buffer
  62454. * @param entry
  62455. * @param byteOffset If defined, specifies where to set the value as an offset.
  62456. */
  62457. setUInt8(entry: number, byteOffset?: number): void;
  62458. /**
  62459. * Gets an UInt32 in the array buffer
  62460. * @param entry
  62461. * @param byteOffset If defined, specifies where to set the value as an offset.
  62462. */
  62463. getUInt32(byteOffset: number): number;
  62464. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62465. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62466. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62467. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62468. /**
  62469. * Stores a Float32 in the array buffer
  62470. * @param entry
  62471. */
  62472. setFloat32(entry: number, byteOffset?: number): void;
  62473. /**
  62474. * Stores an UInt32 in the array buffer
  62475. * @param entry
  62476. * @param byteOffset If defined, specifies where to set the value as an offset.
  62477. */
  62478. setUInt32(entry: number, byteOffset?: number): void;
  62479. }
  62480. }
  62481. declare module BABYLON.GLTF2.Exporter {
  62482. /**
  62483. * @hidden
  62484. * Interface to store animation data.
  62485. */
  62486. export interface _IAnimationData {
  62487. /**
  62488. * Keyframe data.
  62489. */
  62490. inputs: number[];
  62491. /**
  62492. * Value data.
  62493. */
  62494. outputs: number[][];
  62495. /**
  62496. * Animation interpolation data.
  62497. */
  62498. samplerInterpolation: AnimationSamplerInterpolation;
  62499. /**
  62500. * Minimum keyframe value.
  62501. */
  62502. inputsMin: number;
  62503. /**
  62504. * Maximum keyframe value.
  62505. */
  62506. inputsMax: number;
  62507. }
  62508. /**
  62509. * @hidden
  62510. */
  62511. export interface _IAnimationInfo {
  62512. /**
  62513. * The target channel for the animation
  62514. */
  62515. animationChannelTargetPath: AnimationChannelTargetPath;
  62516. /**
  62517. * The glTF accessor type for the data.
  62518. */
  62519. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62520. /**
  62521. * Specifies if quaternions should be used.
  62522. */
  62523. useQuaternion: boolean;
  62524. }
  62525. /**
  62526. * @hidden
  62527. * Utility class for generating glTF animation data from BabylonJS.
  62528. */
  62529. export class _GLTFAnimation {
  62530. /**
  62531. * @ignore
  62532. *
  62533. * Creates glTF channel animation from BabylonJS animation.
  62534. * @param babylonTransformNode - BabylonJS mesh.
  62535. * @param animation - animation.
  62536. * @param animationChannelTargetPath - The target animation channel.
  62537. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62538. * @param useQuaternion - Specifies if quaternions are used.
  62539. * @returns nullable IAnimationData
  62540. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62541. private static _DeduceAnimationInfo;
  62542. /**
  62543. * @ignore
  62544. * Create node animations from the transform node animations
  62545. * @param babylonNode
  62546. * @param runtimeGLTFAnimation
  62547. * @param idleGLTFAnimations
  62548. * @param nodeMap
  62549. * @param nodes
  62550. * @param binaryWriter
  62551. * @param bufferViews
  62552. * @param accessors
  62553. * @param convertToRightHandedSystem
  62554. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62555. [key: number]: number;
  62556. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62557. /**
  62558. * @ignore
  62559. * Create node animations from the animation groups
  62560. * @param babylonScene
  62561. * @param glTFAnimations
  62562. * @param nodeMap
  62563. * @param nodes
  62564. * @param binaryWriter
  62565. * @param bufferViews
  62566. * @param accessors
  62567. * @param convertToRightHandedSystem
  62568. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62569. [key: number]: number;
  62570. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62571. private static AddAnimation;
  62572. /**
  62573. * Create a baked animation
  62574. * @param babylonTransformNode BabylonJS mesh
  62575. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62576. * @param animationChannelTargetPath animation target channel
  62577. * @param minFrame minimum animation frame
  62578. * @param maxFrame maximum animation frame
  62579. * @param fps frames per second of the animation
  62580. * @param inputs input key frames of the animation
  62581. * @param outputs output key frame data of the animation
  62582. * @param convertToRightHandedSystem converts the values to right-handed
  62583. * @param useQuaternion specifies if quaternions should be used
  62584. */
  62585. private static _CreateBakedAnimation;
  62586. private static _ConvertFactorToVector3OrQuaternion;
  62587. private static _SetInterpolatedValue;
  62588. /**
  62589. * Creates linear animation from the animation key frames
  62590. * @param babylonTransformNode BabylonJS mesh
  62591. * @param animation BabylonJS animation
  62592. * @param animationChannelTargetPath The target animation channel
  62593. * @param frameDelta The difference between the last and first frame of the animation
  62594. * @param inputs Array to store the key frame times
  62595. * @param outputs Array to store the key frame data
  62596. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62597. * @param useQuaternion Specifies if quaternions are used in the animation
  62598. */
  62599. private static _CreateLinearOrStepAnimation;
  62600. /**
  62601. * Creates cubic spline animation from the animation key frames
  62602. * @param babylonTransformNode BabylonJS mesh
  62603. * @param animation BabylonJS animation
  62604. * @param animationChannelTargetPath The target animation channel
  62605. * @param frameDelta The difference between the last and first frame of the animation
  62606. * @param inputs Array to store the key frame times
  62607. * @param outputs Array to store the key frame data
  62608. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62609. * @param useQuaternion Specifies if quaternions are used in the animation
  62610. */
  62611. private static _CreateCubicSplineAnimation;
  62612. private static _GetBasePositionRotationOrScale;
  62613. /**
  62614. * Adds a key frame value
  62615. * @param keyFrame
  62616. * @param animation
  62617. * @param outputs
  62618. * @param animationChannelTargetPath
  62619. * @param basePositionRotationOrScale
  62620. * @param convertToRightHandedSystem
  62621. * @param useQuaternion
  62622. */
  62623. private static _AddKeyframeValue;
  62624. /**
  62625. * Determine the interpolation based on the key frames
  62626. * @param keyFrames
  62627. * @param animationChannelTargetPath
  62628. * @param useQuaternion
  62629. */
  62630. private static _DeduceInterpolation;
  62631. /**
  62632. * Adds an input tangent or output tangent to the output data
  62633. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62634. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62635. * @param outputs The animation data by keyframe
  62636. * @param animationChannelTargetPath The target animation channel
  62637. * @param interpolation The interpolation type
  62638. * @param keyFrame The key frame with the animation data
  62639. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62640. * @param useQuaternion Specifies if quaternions are used
  62641. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62642. */
  62643. private static AddSplineTangent;
  62644. /**
  62645. * Get the minimum and maximum key frames' frame values
  62646. * @param keyFrames animation key frames
  62647. * @returns the minimum and maximum key frame value
  62648. */
  62649. private static calculateMinMaxKeyFrames;
  62650. }
  62651. }
  62652. declare module BABYLON.GLTF2.Exporter {
  62653. /** @hidden */
  62654. export var textureTransformPixelShader: {
  62655. name: string;
  62656. shader: string;
  62657. };
  62658. }
  62659. declare module BABYLON.GLTF2.Exporter.Extensions {
  62660. /**
  62661. * @hidden
  62662. */
  62663. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62664. /** Name of this extension */
  62665. readonly name: string;
  62666. /** Defines whether this extension is enabled */
  62667. enabled: boolean;
  62668. /** Defines whether this extension is required */
  62669. required: boolean;
  62670. /** Reference to the glTF exporter */
  62671. private _exporter;
  62672. constructor(exporter: _Exporter);
  62673. dispose(): void;
  62674. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62675. /**
  62676. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62677. * @param babylonTexture
  62678. * @param offset
  62679. * @param rotation
  62680. * @param scale
  62681. * @param scene
  62682. */
  62683. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62684. }
  62685. }
  62686. declare module BABYLON.GLTF2.Exporter.Extensions {
  62687. /**
  62688. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62689. */
  62690. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62691. /** The name of this extension. */
  62692. readonly name: string;
  62693. /** Defines whether this extension is enabled. */
  62694. enabled: boolean;
  62695. /** Defines whether this extension is required */
  62696. required: boolean;
  62697. /** Reference to the glTF exporter */
  62698. private _exporter;
  62699. private _lights;
  62700. /** @hidden */
  62701. constructor(exporter: _Exporter);
  62702. /** @hidden */
  62703. dispose(): void;
  62704. /** @hidden */
  62705. onExporting(): void;
  62706. /**
  62707. * Define this method to modify the default behavior when exporting a node
  62708. * @param context The context when exporting the node
  62709. * @param node glTF node
  62710. * @param babylonNode BabylonJS node
  62711. * @returns nullable INode promise
  62712. */
  62713. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62714. }
  62715. }
  62716. declare module BABYLON {
  62717. /**
  62718. * Class for generating STL data from a Babylon scene.
  62719. */
  62720. export class STLExport {
  62721. /**
  62722. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62723. * @param meshes list defines the mesh to serialize
  62724. * @param download triggers the automatic download of the file.
  62725. * @param fileName changes the downloads fileName.
  62726. * @param binary changes the STL to a binary type.
  62727. * @param isLittleEndian toggle for binary type exporter.
  62728. * @returns the STL as UTF8 string
  62729. */
  62730. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62731. }
  62732. }
  62733. /**
  62734. * @ignoreChildren
  62735. * @ignore
  62736. */
  62737. declare module "babylonjs-gltf2interface" {
  62738. export = BABYLON.GLTF2;
  62739. }
  62740. /**
  62741. * Module for glTF 2.0 Interface
  62742. * @ignoreChildren
  62743. * @ignore
  62744. */
  62745. declare module BABYLON.GLTF2 {
  62746. /**
  62747. * The datatype of the components in the attribute
  62748. */
  62749. const enum AccessorComponentType {
  62750. /**
  62751. * Byte
  62752. */
  62753. BYTE = 5120,
  62754. /**
  62755. * Unsigned Byte
  62756. */
  62757. UNSIGNED_BYTE = 5121,
  62758. /**
  62759. * Short
  62760. */
  62761. SHORT = 5122,
  62762. /**
  62763. * Unsigned Short
  62764. */
  62765. UNSIGNED_SHORT = 5123,
  62766. /**
  62767. * Unsigned Int
  62768. */
  62769. UNSIGNED_INT = 5125,
  62770. /**
  62771. * Float
  62772. */
  62773. FLOAT = 5126,
  62774. }
  62775. /**
  62776. * Specifies if the attirbute is a scalar, vector, or matrix
  62777. */
  62778. const enum AccessorType {
  62779. /**
  62780. * Scalar
  62781. */
  62782. SCALAR = "SCALAR",
  62783. /**
  62784. * Vector2
  62785. */
  62786. VEC2 = "VEC2",
  62787. /**
  62788. * Vector3
  62789. */
  62790. VEC3 = "VEC3",
  62791. /**
  62792. * Vector4
  62793. */
  62794. VEC4 = "VEC4",
  62795. /**
  62796. * Matrix2x2
  62797. */
  62798. MAT2 = "MAT2",
  62799. /**
  62800. * Matrix3x3
  62801. */
  62802. MAT3 = "MAT3",
  62803. /**
  62804. * Matrix4x4
  62805. */
  62806. MAT4 = "MAT4",
  62807. }
  62808. /**
  62809. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62810. */
  62811. const enum AnimationChannelTargetPath {
  62812. /**
  62813. * Translation
  62814. */
  62815. TRANSLATION = "translation",
  62816. /**
  62817. * Rotation
  62818. */
  62819. ROTATION = "rotation",
  62820. /**
  62821. * Scale
  62822. */
  62823. SCALE = "scale",
  62824. /**
  62825. * Weights
  62826. */
  62827. WEIGHTS = "weights",
  62828. }
  62829. /**
  62830. * Interpolation algorithm
  62831. */
  62832. const enum AnimationSamplerInterpolation {
  62833. /**
  62834. * The animated values are linearly interpolated between keyframes
  62835. */
  62836. LINEAR = "LINEAR",
  62837. /**
  62838. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62839. */
  62840. STEP = "STEP",
  62841. /**
  62842. * The animation's interpolation is computed using a cubic spline with specified tangents
  62843. */
  62844. CUBICSPLINE = "CUBICSPLINE",
  62845. }
  62846. /**
  62847. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62848. */
  62849. const enum CameraType {
  62850. /**
  62851. * A perspective camera containing properties to create a perspective projection matrix
  62852. */
  62853. PERSPECTIVE = "perspective",
  62854. /**
  62855. * An orthographic camera containing properties to create an orthographic projection matrix
  62856. */
  62857. ORTHOGRAPHIC = "orthographic",
  62858. }
  62859. /**
  62860. * The mime-type of the image
  62861. */
  62862. const enum ImageMimeType {
  62863. /**
  62864. * JPEG Mime-type
  62865. */
  62866. JPEG = "image/jpeg",
  62867. /**
  62868. * PNG Mime-type
  62869. */
  62870. PNG = "image/png",
  62871. }
  62872. /**
  62873. * The alpha rendering mode of the material
  62874. */
  62875. const enum MaterialAlphaMode {
  62876. /**
  62877. * The alpha value is ignored and the rendered output is fully opaque
  62878. */
  62879. OPAQUE = "OPAQUE",
  62880. /**
  62881. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62882. */
  62883. MASK = "MASK",
  62884. /**
  62885. * 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)
  62886. */
  62887. BLEND = "BLEND",
  62888. }
  62889. /**
  62890. * The type of the primitives to render
  62891. */
  62892. const enum MeshPrimitiveMode {
  62893. /**
  62894. * Points
  62895. */
  62896. POINTS = 0,
  62897. /**
  62898. * Lines
  62899. */
  62900. LINES = 1,
  62901. /**
  62902. * Line Loop
  62903. */
  62904. LINE_LOOP = 2,
  62905. /**
  62906. * Line Strip
  62907. */
  62908. LINE_STRIP = 3,
  62909. /**
  62910. * Triangles
  62911. */
  62912. TRIANGLES = 4,
  62913. /**
  62914. * Triangle Strip
  62915. */
  62916. TRIANGLE_STRIP = 5,
  62917. /**
  62918. * Triangle Fan
  62919. */
  62920. TRIANGLE_FAN = 6,
  62921. }
  62922. /**
  62923. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62924. */
  62925. const enum TextureMagFilter {
  62926. /**
  62927. * Nearest
  62928. */
  62929. NEAREST = 9728,
  62930. /**
  62931. * Linear
  62932. */
  62933. LINEAR = 9729,
  62934. }
  62935. /**
  62936. * Minification filter. All valid values correspond to WebGL enums
  62937. */
  62938. const enum TextureMinFilter {
  62939. /**
  62940. * Nearest
  62941. */
  62942. NEAREST = 9728,
  62943. /**
  62944. * Linear
  62945. */
  62946. LINEAR = 9729,
  62947. /**
  62948. * Nearest Mip-Map Nearest
  62949. */
  62950. NEAREST_MIPMAP_NEAREST = 9984,
  62951. /**
  62952. * Linear Mipmap Nearest
  62953. */
  62954. LINEAR_MIPMAP_NEAREST = 9985,
  62955. /**
  62956. * Nearest Mipmap Linear
  62957. */
  62958. NEAREST_MIPMAP_LINEAR = 9986,
  62959. /**
  62960. * Linear Mipmap Linear
  62961. */
  62962. LINEAR_MIPMAP_LINEAR = 9987,
  62963. }
  62964. /**
  62965. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62966. */
  62967. const enum TextureWrapMode {
  62968. /**
  62969. * Clamp to Edge
  62970. */
  62971. CLAMP_TO_EDGE = 33071,
  62972. /**
  62973. * Mirrored Repeat
  62974. */
  62975. MIRRORED_REPEAT = 33648,
  62976. /**
  62977. * Repeat
  62978. */
  62979. REPEAT = 10497,
  62980. }
  62981. /**
  62982. * glTF Property
  62983. */
  62984. interface IProperty {
  62985. /**
  62986. * Dictionary object with extension-specific objects
  62987. */
  62988. extensions?: {
  62989. [key: string]: any;
  62990. };
  62991. /**
  62992. * Application-Specific data
  62993. */
  62994. extras?: any;
  62995. }
  62996. /**
  62997. * glTF Child of Root Property
  62998. */
  62999. interface IChildRootProperty extends IProperty {
  63000. /**
  63001. * The user-defined name of this object
  63002. */
  63003. name?: string;
  63004. }
  63005. /**
  63006. * Indices of those attributes that deviate from their initialization value
  63007. */
  63008. interface IAccessorSparseIndices extends IProperty {
  63009. /**
  63010. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63011. */
  63012. bufferView: number;
  63013. /**
  63014. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63015. */
  63016. byteOffset?: number;
  63017. /**
  63018. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  63019. */
  63020. componentType: AccessorComponentType;
  63021. }
  63022. /**
  63023. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  63024. */
  63025. interface IAccessorSparseValues extends IProperty {
  63026. /**
  63027. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63028. */
  63029. bufferView: number;
  63030. /**
  63031. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63032. */
  63033. byteOffset?: number;
  63034. }
  63035. /**
  63036. * Sparse storage of attributes that deviate from their initialization value
  63037. */
  63038. interface IAccessorSparse extends IProperty {
  63039. /**
  63040. * The number of attributes encoded in this sparse accessor
  63041. */
  63042. count: number;
  63043. /**
  63044. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  63045. */
  63046. indices: IAccessorSparseIndices;
  63047. /**
  63048. * 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
  63049. */
  63050. values: IAccessorSparseValues;
  63051. }
  63052. /**
  63053. * 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
  63054. */
  63055. interface IAccessor extends IChildRootProperty {
  63056. /**
  63057. * The index of the bufferview
  63058. */
  63059. bufferView?: number;
  63060. /**
  63061. * The offset relative to the start of the bufferView in bytes
  63062. */
  63063. byteOffset?: number;
  63064. /**
  63065. * The datatype of components in the attribute
  63066. */
  63067. componentType: AccessorComponentType;
  63068. /**
  63069. * Specifies whether integer data values should be normalized
  63070. */
  63071. normalized?: boolean;
  63072. /**
  63073. * The number of attributes referenced by this accessor
  63074. */
  63075. count: number;
  63076. /**
  63077. * Specifies if the attribute is a scalar, vector, or matrix
  63078. */
  63079. type: AccessorType;
  63080. /**
  63081. * Maximum value of each component in this attribute
  63082. */
  63083. max?: number[];
  63084. /**
  63085. * Minimum value of each component in this attribute
  63086. */
  63087. min?: number[];
  63088. /**
  63089. * Sparse storage of attributes that deviate from their initialization value
  63090. */
  63091. sparse?: IAccessorSparse;
  63092. }
  63093. /**
  63094. * Targets an animation's sampler at a node's property
  63095. */
  63096. interface IAnimationChannel extends IProperty {
  63097. /**
  63098. * The index of a sampler in this animation used to compute the value for the target
  63099. */
  63100. sampler: number;
  63101. /**
  63102. * The index of the node and TRS property to target
  63103. */
  63104. target: IAnimationChannelTarget;
  63105. }
  63106. /**
  63107. * The index of the node and TRS property that an animation channel targets
  63108. */
  63109. interface IAnimationChannelTarget extends IProperty {
  63110. /**
  63111. * The index of the node to target
  63112. */
  63113. node: number;
  63114. /**
  63115. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  63116. */
  63117. path: AnimationChannelTargetPath;
  63118. }
  63119. /**
  63120. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63121. */
  63122. interface IAnimationSampler extends IProperty {
  63123. /**
  63124. * The index of an accessor containing keyframe input values, e.g., time
  63125. */
  63126. input: number;
  63127. /**
  63128. * Interpolation algorithm
  63129. */
  63130. interpolation?: AnimationSamplerInterpolation;
  63131. /**
  63132. * The index of an accessor, containing keyframe output values
  63133. */
  63134. output: number;
  63135. }
  63136. /**
  63137. * A keyframe animation
  63138. */
  63139. interface IAnimation extends IChildRootProperty {
  63140. /**
  63141. * An array of channels, each of which targets an animation's sampler at a node's property
  63142. */
  63143. channels: IAnimationChannel[];
  63144. /**
  63145. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63146. */
  63147. samplers: IAnimationSampler[];
  63148. }
  63149. /**
  63150. * Metadata about the glTF asset
  63151. */
  63152. interface IAsset extends IChildRootProperty {
  63153. /**
  63154. * A copyright message suitable for display to credit the content creator
  63155. */
  63156. copyright?: string;
  63157. /**
  63158. * Tool that generated this glTF model. Useful for debugging
  63159. */
  63160. generator?: string;
  63161. /**
  63162. * The glTF version that this asset targets
  63163. */
  63164. version: string;
  63165. /**
  63166. * The minimum glTF version that this asset targets
  63167. */
  63168. minVersion?: string;
  63169. }
  63170. /**
  63171. * A buffer points to binary geometry, animation, or skins
  63172. */
  63173. interface IBuffer extends IChildRootProperty {
  63174. /**
  63175. * 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
  63176. */
  63177. uri?: string;
  63178. /**
  63179. * The length of the buffer in bytes
  63180. */
  63181. byteLength: number;
  63182. }
  63183. /**
  63184. * A view into a buffer generally representing a subset of the buffer
  63185. */
  63186. interface IBufferView extends IChildRootProperty {
  63187. /**
  63188. * The index of the buffer
  63189. */
  63190. buffer: number;
  63191. /**
  63192. * The offset into the buffer in bytes
  63193. */
  63194. byteOffset?: number;
  63195. /**
  63196. * The lenth of the bufferView in bytes
  63197. */
  63198. byteLength: number;
  63199. /**
  63200. * The stride, in bytes
  63201. */
  63202. byteStride?: number;
  63203. }
  63204. /**
  63205. * An orthographic camera containing properties to create an orthographic projection matrix
  63206. */
  63207. interface ICameraOrthographic extends IProperty {
  63208. /**
  63209. * The floating-point horizontal magnification of the view. Must not be zero
  63210. */
  63211. xmag: number;
  63212. /**
  63213. * The floating-point vertical magnification of the view. Must not be zero
  63214. */
  63215. ymag: number;
  63216. /**
  63217. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63218. */
  63219. zfar: number;
  63220. /**
  63221. * The floating-point distance to the near clipping plane
  63222. */
  63223. znear: number;
  63224. }
  63225. /**
  63226. * A perspective camera containing properties to create a perspective projection matrix
  63227. */
  63228. interface ICameraPerspective extends IProperty {
  63229. /**
  63230. * The floating-point aspect ratio of the field of view
  63231. */
  63232. aspectRatio?: number;
  63233. /**
  63234. * The floating-point vertical field of view in radians
  63235. */
  63236. yfov: number;
  63237. /**
  63238. * The floating-point distance to the far clipping plane
  63239. */
  63240. zfar?: number;
  63241. /**
  63242. * The floating-point distance to the near clipping plane
  63243. */
  63244. znear: number;
  63245. }
  63246. /**
  63247. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63248. */
  63249. interface ICamera extends IChildRootProperty {
  63250. /**
  63251. * An orthographic camera containing properties to create an orthographic projection matrix
  63252. */
  63253. orthographic?: ICameraOrthographic;
  63254. /**
  63255. * A perspective camera containing properties to create a perspective projection matrix
  63256. */
  63257. perspective?: ICameraPerspective;
  63258. /**
  63259. * Specifies if the camera uses a perspective or orthographic projection
  63260. */
  63261. type: CameraType;
  63262. }
  63263. /**
  63264. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63265. */
  63266. interface IImage extends IChildRootProperty {
  63267. /**
  63268. * 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
  63269. */
  63270. uri?: string;
  63271. /**
  63272. * The image's MIME type
  63273. */
  63274. mimeType?: ImageMimeType;
  63275. /**
  63276. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63277. */
  63278. bufferView?: number;
  63279. }
  63280. /**
  63281. * Material Normal Texture Info
  63282. */
  63283. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63284. /**
  63285. * The scalar multiplier applied to each normal vector of the normal texture
  63286. */
  63287. scale?: number;
  63288. }
  63289. /**
  63290. * Material Occlusion Texture Info
  63291. */
  63292. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63293. /**
  63294. * A scalar multiplier controlling the amount of occlusion applied
  63295. */
  63296. strength?: number;
  63297. }
  63298. /**
  63299. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63300. */
  63301. interface IMaterialPbrMetallicRoughness {
  63302. /**
  63303. * The material's base color factor
  63304. */
  63305. baseColorFactor?: number[];
  63306. /**
  63307. * The base color texture
  63308. */
  63309. baseColorTexture?: ITextureInfo;
  63310. /**
  63311. * The metalness of the material
  63312. */
  63313. metallicFactor?: number;
  63314. /**
  63315. * The roughness of the material
  63316. */
  63317. roughnessFactor?: number;
  63318. /**
  63319. * The metallic-roughness texture
  63320. */
  63321. metallicRoughnessTexture?: ITextureInfo;
  63322. }
  63323. /**
  63324. * The material appearance of a primitive
  63325. */
  63326. interface IMaterial extends IChildRootProperty {
  63327. /**
  63328. * 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
  63329. */
  63330. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63331. /**
  63332. * The normal map texture
  63333. */
  63334. normalTexture?: IMaterialNormalTextureInfo;
  63335. /**
  63336. * The occlusion map texture
  63337. */
  63338. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63339. /**
  63340. * The emissive map texture
  63341. */
  63342. emissiveTexture?: ITextureInfo;
  63343. /**
  63344. * 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
  63345. */
  63346. emissiveFactor?: number[];
  63347. /**
  63348. * The alpha rendering mode of the material
  63349. */
  63350. alphaMode?: MaterialAlphaMode;
  63351. /**
  63352. * The alpha cutoff value of the material
  63353. */
  63354. alphaCutoff?: number;
  63355. /**
  63356. * Specifies whether the material is double sided
  63357. */
  63358. doubleSided?: boolean;
  63359. }
  63360. /**
  63361. * Geometry to be rendered with the given material
  63362. */
  63363. interface IMeshPrimitive extends IProperty {
  63364. /**
  63365. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63366. */
  63367. attributes: {
  63368. [name: string]: number;
  63369. };
  63370. /**
  63371. * The index of the accessor that contains the indices
  63372. */
  63373. indices?: number;
  63374. /**
  63375. * The index of the material to apply to this primitive when rendering
  63376. */
  63377. material?: number;
  63378. /**
  63379. * The type of primitives to render. All valid values correspond to WebGL enums
  63380. */
  63381. mode?: MeshPrimitiveMode;
  63382. /**
  63383. * 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
  63384. */
  63385. targets?: {
  63386. [name: string]: number;
  63387. }[];
  63388. }
  63389. /**
  63390. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63391. */
  63392. interface IMesh extends IChildRootProperty {
  63393. /**
  63394. * An array of primitives, each defining geometry to be rendered with a material
  63395. */
  63396. primitives: IMeshPrimitive[];
  63397. /**
  63398. * Array of weights to be applied to the Morph Targets
  63399. */
  63400. weights?: number[];
  63401. }
  63402. /**
  63403. * A node in the node hierarchy
  63404. */
  63405. interface INode extends IChildRootProperty {
  63406. /**
  63407. * The index of the camera referenced by this node
  63408. */
  63409. camera?: number;
  63410. /**
  63411. * The indices of this node's children
  63412. */
  63413. children?: number[];
  63414. /**
  63415. * The index of the skin referenced by this node
  63416. */
  63417. skin?: number;
  63418. /**
  63419. * A floating-point 4x4 transformation matrix stored in column-major order
  63420. */
  63421. matrix?: number[];
  63422. /**
  63423. * The index of the mesh in this node
  63424. */
  63425. mesh?: number;
  63426. /**
  63427. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63428. */
  63429. rotation?: number[];
  63430. /**
  63431. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63432. */
  63433. scale?: number[];
  63434. /**
  63435. * The node's translation along the x, y, and z axes
  63436. */
  63437. translation?: number[];
  63438. /**
  63439. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63440. */
  63441. weights?: number[];
  63442. }
  63443. /**
  63444. * Texture sampler properties for filtering and wrapping modes
  63445. */
  63446. interface ISampler extends IChildRootProperty {
  63447. /**
  63448. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63449. */
  63450. magFilter?: TextureMagFilter;
  63451. /**
  63452. * Minification filter. All valid values correspond to WebGL enums
  63453. */
  63454. minFilter?: TextureMinFilter;
  63455. /**
  63456. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63457. */
  63458. wrapS?: TextureWrapMode;
  63459. /**
  63460. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63461. */
  63462. wrapT?: TextureWrapMode;
  63463. }
  63464. /**
  63465. * The root nodes of a scene
  63466. */
  63467. interface IScene extends IChildRootProperty {
  63468. /**
  63469. * The indices of each root node
  63470. */
  63471. nodes: number[];
  63472. }
  63473. /**
  63474. * Joints and matrices defining a skin
  63475. */
  63476. interface ISkin extends IChildRootProperty {
  63477. /**
  63478. * 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
  63479. */
  63480. inverseBindMatrices?: number;
  63481. /**
  63482. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63483. */
  63484. skeleton?: number;
  63485. /**
  63486. * 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)
  63487. */
  63488. joints: number[];
  63489. }
  63490. /**
  63491. * A texture and its sampler
  63492. */
  63493. interface ITexture extends IChildRootProperty {
  63494. /**
  63495. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63496. */
  63497. sampler?: number;
  63498. /**
  63499. * The index of the image used by this texture
  63500. */
  63501. source: number;
  63502. }
  63503. /**
  63504. * Reference to a texture
  63505. */
  63506. interface ITextureInfo extends IProperty {
  63507. /**
  63508. * The index of the texture
  63509. */
  63510. index: number;
  63511. /**
  63512. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63513. */
  63514. texCoord?: number;
  63515. }
  63516. /**
  63517. * The root object for a glTF asset
  63518. */
  63519. interface IGLTF extends IProperty {
  63520. /**
  63521. * An array of accessors. An accessor is a typed view into a bufferView
  63522. */
  63523. accessors?: IAccessor[];
  63524. /**
  63525. * An array of keyframe animations
  63526. */
  63527. animations?: IAnimation[];
  63528. /**
  63529. * Metadata about the glTF asset
  63530. */
  63531. asset: IAsset;
  63532. /**
  63533. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63534. */
  63535. buffers?: IBuffer[];
  63536. /**
  63537. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63538. */
  63539. bufferViews?: IBufferView[];
  63540. /**
  63541. * An array of cameras
  63542. */
  63543. cameras?: ICamera[];
  63544. /**
  63545. * Names of glTF extensions used somewhere in this asset
  63546. */
  63547. extensionsUsed?: string[];
  63548. /**
  63549. * Names of glTF extensions required to properly load this asset
  63550. */
  63551. extensionsRequired?: string[];
  63552. /**
  63553. * An array of images. An image defines data used to create a texture
  63554. */
  63555. images?: IImage[];
  63556. /**
  63557. * An array of materials. A material defines the appearance of a primitive
  63558. */
  63559. materials?: IMaterial[];
  63560. /**
  63561. * An array of meshes. A mesh is a set of primitives to be rendered
  63562. */
  63563. meshes?: IMesh[];
  63564. /**
  63565. * An array of nodes
  63566. */
  63567. nodes?: INode[];
  63568. /**
  63569. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63570. */
  63571. samplers?: ISampler[];
  63572. /**
  63573. * The index of the default scene
  63574. */
  63575. scene?: number;
  63576. /**
  63577. * An array of scenes
  63578. */
  63579. scenes?: IScene[];
  63580. /**
  63581. * An array of skins. A skin is defined by joints and matrices
  63582. */
  63583. skins?: ISkin[];
  63584. /**
  63585. * An array of textures
  63586. */
  63587. textures?: ITexture[];
  63588. }
  63589. /**
  63590. * Interface for glTF validation results
  63591. */
  63592. interface IGLTFValidationResults {
  63593. info: {
  63594. generator: string;
  63595. hasAnimations: boolean;
  63596. hasDefaultScene: boolean;
  63597. hasMaterials: boolean;
  63598. hasMorphTargets: boolean;
  63599. hasSkins: boolean;
  63600. hasTextures: boolean;
  63601. maxAttributesUsed: number;
  63602. primitivesCount: number
  63603. };
  63604. issues: {
  63605. messages: Array<string>;
  63606. numErrors: number;
  63607. numHints: number;
  63608. numInfos: number;
  63609. numWarnings: number;
  63610. truncated: boolean
  63611. };
  63612. mimeType: string;
  63613. uri: string;
  63614. validatedAt: string;
  63615. validatorVersion: string;
  63616. }
  63617. /**
  63618. * Interface for glTF validation options
  63619. */
  63620. interface IGLTFValidationOptions {
  63621. uri?: string;
  63622. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63623. validateAccessorData?: boolean;
  63624. maxIssues?: number;
  63625. ignoredIssues?: Array<string>;
  63626. severityOverrides?: Object;
  63627. }
  63628. /**
  63629. * glTF validator object Tyyings
  63630. */
  63631. interface IGLTFValidatorTypings {
  63632. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63633. }
  63634. }
  63635. /**
  63636. * Interface for glTF validation results
  63637. */
  63638. interface IGLTFValidationResults {
  63639. info: {
  63640. generator: string;
  63641. hasAnimations: boolean;
  63642. hasDefaultScene: boolean;
  63643. hasMaterials: boolean;
  63644. hasMorphTargets: boolean;
  63645. hasSkins: boolean;
  63646. hasTextures: boolean;
  63647. maxAttributesUsed: number;
  63648. primitivesCount: number
  63649. };
  63650. issues: {
  63651. messages: Array<string>;
  63652. numErrors: number;
  63653. numHints: number;
  63654. numInfos: number;
  63655. numWarnings: number;
  63656. truncated: boolean
  63657. };
  63658. mimeType: string;
  63659. uri: string;
  63660. validatedAt: string;
  63661. validatorVersion: string;
  63662. }
  63663. /**
  63664. * Interface for glTF validation options
  63665. */
  63666. interface IGLTFValidationOptions {
  63667. uri?: string;
  63668. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63669. validateAccessorData?: boolean;
  63670. maxIssues?: number;
  63671. ignoredIssues?: Array<string>;
  63672. severityOverrides?: Object;
  63673. }
  63674. /**
  63675. * glTF validator object Tyyings
  63676. */
  63677. interface IGLTFValidatorTypings {
  63678. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63679. }
  63680. declare module BABYLON {
  63681. /** @hidden */
  63682. export var cellPixelShader: {
  63683. name: string;
  63684. shader: string;
  63685. };
  63686. }
  63687. declare module BABYLON {
  63688. /** @hidden */
  63689. export var cellVertexShader: {
  63690. name: string;
  63691. shader: string;
  63692. };
  63693. }
  63694. declare module BABYLON {
  63695. export class CellMaterial extends BABYLON.PushMaterial {
  63696. private _diffuseTexture;
  63697. diffuseTexture: BABYLON.BaseTexture;
  63698. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63699. computeHighLevel: boolean;
  63700. private _disableLighting;
  63701. disableLighting: boolean;
  63702. private _maxSimultaneousLights;
  63703. maxSimultaneousLights: number;
  63704. private _renderId;
  63705. constructor(name: string, scene: BABYLON.Scene);
  63706. needAlphaBlending(): boolean;
  63707. needAlphaTesting(): boolean;
  63708. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63709. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63710. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63711. getAnimatables(): BABYLON.IAnimatable[];
  63712. getActiveTextures(): BABYLON.BaseTexture[];
  63713. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63714. dispose(forceDisposeEffect?: boolean): void;
  63715. getClassName(): string;
  63716. clone(name: string): CellMaterial;
  63717. serialize(): any;
  63718. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. export class CustomShaderStructure {
  63723. FragmentStore: string;
  63724. VertexStore: string;
  63725. constructor();
  63726. }
  63727. export class ShaderSpecialParts {
  63728. constructor();
  63729. Fragment_Begin: string;
  63730. Fragment_Definitions: string;
  63731. Fragment_MainBegin: string;
  63732. Fragment_Custom_Diffuse: string;
  63733. Fragment_Before_Lights: string;
  63734. Fragment_Before_Fog: string;
  63735. Fragment_Custom_Alpha: string;
  63736. Fragment_Before_FragColor: string;
  63737. Vertex_Begin: string;
  63738. Vertex_Definitions: string;
  63739. Vertex_MainBegin: string;
  63740. Vertex_Before_PositionUpdated: string;
  63741. Vertex_Before_NormalUpdated: string;
  63742. Vertex_MainEnd: string;
  63743. }
  63744. export class CustomMaterial extends BABYLON.StandardMaterial {
  63745. static ShaderIndexer: number;
  63746. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63747. FragmentShader: string;
  63748. VertexShader: string;
  63749. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63750. ReviewUniform(name: string, arr: string[]): string[];
  63751. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63752. constructor(name: string, scene: BABYLON.Scene);
  63753. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63754. Fragment_Begin(shaderPart: string): CustomMaterial;
  63755. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63756. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63757. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63758. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63759. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63760. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63761. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63762. Vertex_Begin(shaderPart: string): CustomMaterial;
  63763. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63764. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63765. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63766. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63767. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63768. }
  63769. }
  63770. declare module BABYLON {
  63771. export class ShaderAlebdoParts {
  63772. constructor();
  63773. Fragment_Begin: string;
  63774. Fragment_Definitions: string;
  63775. Fragment_MainBegin: string;
  63776. Fragment_Custom_Albedo: string;
  63777. Fragment_Before_Lights: string;
  63778. Fragment_Before_Fog: string;
  63779. Fragment_Custom_Alpha: string;
  63780. Fragment_Before_FragColor: string;
  63781. Vertex_Begin: string;
  63782. Vertex_Definitions: string;
  63783. Vertex_MainBegin: string;
  63784. Vertex_Before_PositionUpdated: string;
  63785. Vertex_Before_NormalUpdated: string;
  63786. Vertex_MainEnd: string;
  63787. }
  63788. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63789. static ShaderIndexer: number;
  63790. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63791. FragmentShader: string;
  63792. VertexShader: string;
  63793. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63794. ReviewUniform(name: string, arr: string[]): string[];
  63795. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63796. constructor(name: string, scene: BABYLON.Scene);
  63797. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63798. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63799. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63800. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63801. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63802. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63803. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63804. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63805. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63806. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63807. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63808. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63809. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63810. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63811. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /** @hidden */
  63816. export var firePixelShader: {
  63817. name: string;
  63818. shader: string;
  63819. };
  63820. }
  63821. declare module BABYLON {
  63822. /** @hidden */
  63823. export var fireVertexShader: {
  63824. name: string;
  63825. shader: string;
  63826. };
  63827. }
  63828. declare module BABYLON {
  63829. export class FireMaterial extends BABYLON.PushMaterial {
  63830. private _diffuseTexture;
  63831. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63832. private _distortionTexture;
  63833. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63834. private _opacityTexture;
  63835. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63836. diffuseColor: BABYLON.Color3;
  63837. speed: number;
  63838. private _scaledDiffuse;
  63839. private _renderId;
  63840. private _lastTime;
  63841. constructor(name: string, scene: BABYLON.Scene);
  63842. needAlphaBlending(): boolean;
  63843. needAlphaTesting(): boolean;
  63844. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63845. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63846. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63847. getAnimatables(): BABYLON.IAnimatable[];
  63848. getActiveTextures(): BABYLON.BaseTexture[];
  63849. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63850. getClassName(): string;
  63851. dispose(forceDisposeEffect?: boolean): void;
  63852. clone(name: string): FireMaterial;
  63853. serialize(): any;
  63854. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63855. }
  63856. }
  63857. declare module BABYLON {
  63858. /** @hidden */
  63859. export var furPixelShader: {
  63860. name: string;
  63861. shader: string;
  63862. };
  63863. }
  63864. declare module BABYLON {
  63865. /** @hidden */
  63866. export var furVertexShader: {
  63867. name: string;
  63868. shader: string;
  63869. };
  63870. }
  63871. declare module BABYLON {
  63872. export class FurMaterial extends BABYLON.PushMaterial {
  63873. private _diffuseTexture;
  63874. diffuseTexture: BABYLON.BaseTexture;
  63875. private _heightTexture;
  63876. heightTexture: BABYLON.BaseTexture;
  63877. diffuseColor: BABYLON.Color3;
  63878. furLength: number;
  63879. furAngle: number;
  63880. furColor: BABYLON.Color3;
  63881. furOffset: number;
  63882. furSpacing: number;
  63883. furGravity: BABYLON.Vector3;
  63884. furSpeed: number;
  63885. furDensity: number;
  63886. furOcclusion: number;
  63887. furTexture: BABYLON.DynamicTexture;
  63888. private _disableLighting;
  63889. disableLighting: boolean;
  63890. private _maxSimultaneousLights;
  63891. maxSimultaneousLights: number;
  63892. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63893. private _renderId;
  63894. private _furTime;
  63895. constructor(name: string, scene: BABYLON.Scene);
  63896. furTime: number;
  63897. needAlphaBlending(): boolean;
  63898. needAlphaTesting(): boolean;
  63899. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63900. updateFur(): void;
  63901. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63902. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63903. getAnimatables(): BABYLON.IAnimatable[];
  63904. getActiveTextures(): BABYLON.BaseTexture[];
  63905. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63906. dispose(forceDisposeEffect?: boolean): void;
  63907. clone(name: string): FurMaterial;
  63908. serialize(): any;
  63909. getClassName(): string;
  63910. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63911. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63912. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63913. }
  63914. }
  63915. declare module BABYLON {
  63916. /** @hidden */
  63917. export var gradientPixelShader: {
  63918. name: string;
  63919. shader: string;
  63920. };
  63921. }
  63922. declare module BABYLON {
  63923. /** @hidden */
  63924. export var gradientVertexShader: {
  63925. name: string;
  63926. shader: string;
  63927. };
  63928. }
  63929. declare module BABYLON {
  63930. export class GradientMaterial extends BABYLON.PushMaterial {
  63931. private _maxSimultaneousLights;
  63932. maxSimultaneousLights: number;
  63933. topColor: BABYLON.Color3;
  63934. topColorAlpha: number;
  63935. bottomColor: BABYLON.Color3;
  63936. bottomColorAlpha: number;
  63937. offset: number;
  63938. scale: number;
  63939. smoothness: number;
  63940. private _disableLighting;
  63941. disableLighting: boolean;
  63942. private _renderId;
  63943. constructor(name: string, scene: BABYLON.Scene);
  63944. needAlphaBlending(): boolean;
  63945. needAlphaTesting(): boolean;
  63946. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63947. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63948. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63949. getAnimatables(): BABYLON.IAnimatable[];
  63950. dispose(forceDisposeEffect?: boolean): void;
  63951. clone(name: string): GradientMaterial;
  63952. serialize(): any;
  63953. getClassName(): string;
  63954. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63955. }
  63956. }
  63957. declare module BABYLON {
  63958. /** @hidden */
  63959. export var gridPixelShader: {
  63960. name: string;
  63961. shader: string;
  63962. };
  63963. }
  63964. declare module BABYLON {
  63965. /** @hidden */
  63966. export var gridVertexShader: {
  63967. name: string;
  63968. shader: string;
  63969. };
  63970. }
  63971. declare module BABYLON {
  63972. /**
  63973. * The grid materials allows you to wrap any shape with a grid.
  63974. * Colors are customizable.
  63975. */
  63976. export class GridMaterial extends BABYLON.PushMaterial {
  63977. /**
  63978. * Main color of the grid (e.g. between lines)
  63979. */
  63980. mainColor: BABYLON.Color3;
  63981. /**
  63982. * Color of the grid lines.
  63983. */
  63984. lineColor: BABYLON.Color3;
  63985. /**
  63986. * The scale of the grid compared to unit.
  63987. */
  63988. gridRatio: number;
  63989. /**
  63990. * Allows setting an offset for the grid lines.
  63991. */
  63992. gridOffset: BABYLON.Vector3;
  63993. /**
  63994. * The frequency of thicker lines.
  63995. */
  63996. majorUnitFrequency: number;
  63997. /**
  63998. * The visibility of minor units in the grid.
  63999. */
  64000. minorUnitVisibility: number;
  64001. /**
  64002. * The grid opacity outside of the lines.
  64003. */
  64004. opacity: number;
  64005. /**
  64006. * Determine RBG output is premultiplied by alpha value.
  64007. */
  64008. preMultiplyAlpha: boolean;
  64009. private _opacityTexture;
  64010. opacityTexture: BABYLON.BaseTexture;
  64011. private _gridControl;
  64012. private _renderId;
  64013. /**
  64014. * constructor
  64015. * @param name The name given to the material in order to identify it afterwards.
  64016. * @param scene The scene the material is used in.
  64017. */
  64018. constructor(name: string, scene: BABYLON.Scene);
  64019. /**
  64020. * Returns wehter or not the grid requires alpha blending.
  64021. */
  64022. needAlphaBlending(): boolean;
  64023. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64024. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64025. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64026. /**
  64027. * Dispose the material and its associated resources.
  64028. * @param forceDisposeEffect will also dispose the used effect when true
  64029. */
  64030. dispose(forceDisposeEffect?: boolean): void;
  64031. clone(name: string): GridMaterial;
  64032. serialize(): any;
  64033. getClassName(): string;
  64034. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /** @hidden */
  64039. export var lavaPixelShader: {
  64040. name: string;
  64041. shader: string;
  64042. };
  64043. }
  64044. declare module BABYLON {
  64045. /** @hidden */
  64046. export var lavaVertexShader: {
  64047. name: string;
  64048. shader: string;
  64049. };
  64050. }
  64051. declare module BABYLON {
  64052. export class LavaMaterial extends BABYLON.PushMaterial {
  64053. private _diffuseTexture;
  64054. diffuseTexture: BABYLON.BaseTexture;
  64055. noiseTexture: BABYLON.BaseTexture;
  64056. fogColor: BABYLON.Color3;
  64057. speed: number;
  64058. movingSpeed: number;
  64059. lowFrequencySpeed: number;
  64060. fogDensity: number;
  64061. private _lastTime;
  64062. diffuseColor: BABYLON.Color3;
  64063. private _disableLighting;
  64064. disableLighting: boolean;
  64065. private _unlit;
  64066. unlit: boolean;
  64067. private _maxSimultaneousLights;
  64068. maxSimultaneousLights: number;
  64069. private _scaledDiffuse;
  64070. private _renderId;
  64071. constructor(name: string, scene: BABYLON.Scene);
  64072. needAlphaBlending(): boolean;
  64073. needAlphaTesting(): boolean;
  64074. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64075. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64076. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64077. getAnimatables(): BABYLON.IAnimatable[];
  64078. getActiveTextures(): BABYLON.BaseTexture[];
  64079. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64080. dispose(forceDisposeEffect?: boolean): void;
  64081. clone(name: string): LavaMaterial;
  64082. serialize(): any;
  64083. getClassName(): string;
  64084. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /** @hidden */
  64089. export var mixPixelShader: {
  64090. name: string;
  64091. shader: string;
  64092. };
  64093. }
  64094. declare module BABYLON {
  64095. /** @hidden */
  64096. export var mixVertexShader: {
  64097. name: string;
  64098. shader: string;
  64099. };
  64100. }
  64101. declare module BABYLON {
  64102. export class MixMaterial extends BABYLON.PushMaterial {
  64103. /**
  64104. * Mix textures
  64105. */
  64106. private _mixTexture1;
  64107. mixTexture1: BABYLON.BaseTexture;
  64108. private _mixTexture2;
  64109. mixTexture2: BABYLON.BaseTexture;
  64110. /**
  64111. * Diffuse textures
  64112. */
  64113. private _diffuseTexture1;
  64114. diffuseTexture1: BABYLON.Texture;
  64115. private _diffuseTexture2;
  64116. diffuseTexture2: BABYLON.Texture;
  64117. private _diffuseTexture3;
  64118. diffuseTexture3: BABYLON.Texture;
  64119. private _diffuseTexture4;
  64120. diffuseTexture4: BABYLON.Texture;
  64121. private _diffuseTexture5;
  64122. diffuseTexture5: BABYLON.Texture;
  64123. private _diffuseTexture6;
  64124. diffuseTexture6: BABYLON.Texture;
  64125. private _diffuseTexture7;
  64126. diffuseTexture7: BABYLON.Texture;
  64127. private _diffuseTexture8;
  64128. diffuseTexture8: BABYLON.Texture;
  64129. /**
  64130. * Uniforms
  64131. */
  64132. diffuseColor: BABYLON.Color3;
  64133. specularColor: BABYLON.Color3;
  64134. specularPower: number;
  64135. private _disableLighting;
  64136. disableLighting: boolean;
  64137. private _maxSimultaneousLights;
  64138. maxSimultaneousLights: number;
  64139. private _renderId;
  64140. constructor(name: string, scene: BABYLON.Scene);
  64141. needAlphaBlending(): boolean;
  64142. needAlphaTesting(): boolean;
  64143. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64146. getAnimatables(): BABYLON.IAnimatable[];
  64147. getActiveTextures(): BABYLON.BaseTexture[];
  64148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64149. dispose(forceDisposeEffect?: boolean): void;
  64150. clone(name: string): MixMaterial;
  64151. serialize(): any;
  64152. getClassName(): string;
  64153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64154. }
  64155. }
  64156. declare module BABYLON {
  64157. /** @hidden */
  64158. export var normalPixelShader: {
  64159. name: string;
  64160. shader: string;
  64161. };
  64162. }
  64163. declare module BABYLON {
  64164. /** @hidden */
  64165. export var normalVertexShader: {
  64166. name: string;
  64167. shader: string;
  64168. };
  64169. }
  64170. declare module BABYLON {
  64171. export class NormalMaterial extends BABYLON.PushMaterial {
  64172. private _diffuseTexture;
  64173. diffuseTexture: BABYLON.BaseTexture;
  64174. diffuseColor: BABYLON.Color3;
  64175. private _disableLighting;
  64176. disableLighting: boolean;
  64177. private _maxSimultaneousLights;
  64178. maxSimultaneousLights: number;
  64179. private _renderId;
  64180. constructor(name: string, scene: BABYLON.Scene);
  64181. needAlphaBlending(): boolean;
  64182. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64183. needAlphaTesting(): boolean;
  64184. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64185. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64186. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64187. getAnimatables(): BABYLON.IAnimatable[];
  64188. getActiveTextures(): BABYLON.BaseTexture[];
  64189. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64190. dispose(forceDisposeEffect?: boolean): void;
  64191. clone(name: string): NormalMaterial;
  64192. serialize(): any;
  64193. getClassName(): string;
  64194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64195. }
  64196. }
  64197. declare module BABYLON {
  64198. /** @hidden */
  64199. export var shadowOnlyPixelShader: {
  64200. name: string;
  64201. shader: string;
  64202. };
  64203. }
  64204. declare module BABYLON {
  64205. /** @hidden */
  64206. export var shadowOnlyVertexShader: {
  64207. name: string;
  64208. shader: string;
  64209. };
  64210. }
  64211. declare module BABYLON {
  64212. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64213. private _renderId;
  64214. private _activeLight;
  64215. constructor(name: string, scene: BABYLON.Scene);
  64216. shadowColor: BABYLON.Color3;
  64217. needAlphaBlending(): boolean;
  64218. needAlphaTesting(): boolean;
  64219. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64220. activeLight: BABYLON.IShadowLight;
  64221. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64222. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64223. clone(name: string): ShadowOnlyMaterial;
  64224. serialize(): any;
  64225. getClassName(): string;
  64226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64227. }
  64228. }
  64229. declare module BABYLON {
  64230. /** @hidden */
  64231. export var simplePixelShader: {
  64232. name: string;
  64233. shader: string;
  64234. };
  64235. }
  64236. declare module BABYLON {
  64237. /** @hidden */
  64238. export var simpleVertexShader: {
  64239. name: string;
  64240. shader: string;
  64241. };
  64242. }
  64243. declare module BABYLON {
  64244. export class SimpleMaterial extends BABYLON.PushMaterial {
  64245. private _diffuseTexture;
  64246. diffuseTexture: BABYLON.BaseTexture;
  64247. diffuseColor: BABYLON.Color3;
  64248. private _disableLighting;
  64249. disableLighting: boolean;
  64250. private _maxSimultaneousLights;
  64251. maxSimultaneousLights: number;
  64252. private _renderId;
  64253. constructor(name: string, scene: BABYLON.Scene);
  64254. needAlphaBlending(): boolean;
  64255. needAlphaTesting(): boolean;
  64256. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64257. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64258. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64259. getAnimatables(): BABYLON.IAnimatable[];
  64260. getActiveTextures(): BABYLON.BaseTexture[];
  64261. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64262. dispose(forceDisposeEffect?: boolean): void;
  64263. clone(name: string): SimpleMaterial;
  64264. serialize(): any;
  64265. getClassName(): string;
  64266. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64267. }
  64268. }
  64269. declare module BABYLON {
  64270. /** @hidden */
  64271. export var skyPixelShader: {
  64272. name: string;
  64273. shader: string;
  64274. };
  64275. }
  64276. declare module BABYLON {
  64277. /** @hidden */
  64278. export var skyVertexShader: {
  64279. name: string;
  64280. shader: string;
  64281. };
  64282. }
  64283. declare module BABYLON {
  64284. /**
  64285. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64286. * @see https://doc.babylonjs.com/extensions/sky
  64287. */
  64288. export class SkyMaterial extends BABYLON.PushMaterial {
  64289. /**
  64290. * Defines the overall luminance of sky in interval ]0, 1[.
  64291. */
  64292. luminance: number;
  64293. /**
  64294. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64295. */
  64296. turbidity: number;
  64297. /**
  64298. * Defines the sky appearance (light intensity).
  64299. */
  64300. rayleigh: number;
  64301. /**
  64302. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64303. */
  64304. mieCoefficient: number;
  64305. /**
  64306. * Defines the amount of haze particles following the Mie scattering theory.
  64307. */
  64308. mieDirectionalG: number;
  64309. /**
  64310. * Defines the distance of the sun according to the active scene camera.
  64311. */
  64312. distance: number;
  64313. /**
  64314. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64315. * "inclined".
  64316. */
  64317. inclination: number;
  64318. /**
  64319. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64320. * an object direction and a reference direction.
  64321. */
  64322. azimuth: number;
  64323. /**
  64324. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64325. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64326. */
  64327. sunPosition: BABYLON.Vector3;
  64328. /**
  64329. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64330. * .sunPosition property.
  64331. */
  64332. useSunPosition: boolean;
  64333. /**
  64334. * Defines an offset vector used to get a horizon offset.
  64335. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64336. */
  64337. cameraOffset: BABYLON.Vector3;
  64338. private _cameraPosition;
  64339. private _renderId;
  64340. /**
  64341. * Instantiates a new sky material.
  64342. * This material allows to create dynamic and texture free
  64343. * effects for skyboxes by taking care of the atmosphere state.
  64344. * @see https://doc.babylonjs.com/extensions/sky
  64345. * @param name Define the name of the material in the scene
  64346. * @param scene Define the scene the material belong to
  64347. */
  64348. constructor(name: string, scene: BABYLON.Scene);
  64349. /**
  64350. * Specifies if the material will require alpha blending
  64351. * @returns a boolean specifying if alpha blending is needed
  64352. */
  64353. needAlphaBlending(): boolean;
  64354. /**
  64355. * Specifies if this material should be rendered in alpha test mode
  64356. * @returns false as the sky material doesn't need alpha testing.
  64357. */
  64358. needAlphaTesting(): boolean;
  64359. /**
  64360. * Get the texture used for alpha test purpose.
  64361. * @returns null as the sky material has no texture.
  64362. */
  64363. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64364. /**
  64365. * Get if the submesh is ready to be used and all its information available.
  64366. * Child classes can use it to update shaders
  64367. * @param mesh defines the mesh to check
  64368. * @param subMesh defines which submesh to check
  64369. * @param useInstances specifies that instances should be used
  64370. * @returns a boolean indicating that the submesh is ready or not
  64371. */
  64372. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64373. /**
  64374. * Binds the submesh to this material by preparing the effect and shader to draw
  64375. * @param world defines the world transformation matrix
  64376. * @param mesh defines the mesh containing the submesh
  64377. * @param subMesh defines the submesh to bind the material to
  64378. */
  64379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64380. /**
  64381. * Get the list of animatables in the material.
  64382. * @returns the list of animatables object used in the material
  64383. */
  64384. getAnimatables(): BABYLON.IAnimatable[];
  64385. /**
  64386. * Disposes the material
  64387. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64388. */
  64389. dispose(forceDisposeEffect?: boolean): void;
  64390. /**
  64391. * Makes a duplicate of the material, and gives it a new name
  64392. * @param name defines the new name for the duplicated material
  64393. * @returns the cloned material
  64394. */
  64395. clone(name: string): SkyMaterial;
  64396. /**
  64397. * Serializes this material in a JSON representation
  64398. * @returns the serialized material object
  64399. */
  64400. serialize(): any;
  64401. /**
  64402. * Gets the current class name of the material e.g. "SkyMaterial"
  64403. * Mainly use in serialization.
  64404. * @returns the class name
  64405. */
  64406. getClassName(): string;
  64407. /**
  64408. * Creates a sky material from parsed material data
  64409. * @param source defines the JSON representation of the material
  64410. * @param scene defines the hosting scene
  64411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64412. * @returns a new sky material
  64413. */
  64414. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /** @hidden */
  64419. export var terrainPixelShader: {
  64420. name: string;
  64421. shader: string;
  64422. };
  64423. }
  64424. declare module BABYLON {
  64425. /** @hidden */
  64426. export var terrainVertexShader: {
  64427. name: string;
  64428. shader: string;
  64429. };
  64430. }
  64431. declare module BABYLON {
  64432. export class TerrainMaterial extends BABYLON.PushMaterial {
  64433. private _mixTexture;
  64434. mixTexture: BABYLON.BaseTexture;
  64435. private _diffuseTexture1;
  64436. diffuseTexture1: BABYLON.Texture;
  64437. private _diffuseTexture2;
  64438. diffuseTexture2: BABYLON.Texture;
  64439. private _diffuseTexture3;
  64440. diffuseTexture3: BABYLON.Texture;
  64441. private _bumpTexture1;
  64442. bumpTexture1: BABYLON.Texture;
  64443. private _bumpTexture2;
  64444. bumpTexture2: BABYLON.Texture;
  64445. private _bumpTexture3;
  64446. bumpTexture3: BABYLON.Texture;
  64447. diffuseColor: BABYLON.Color3;
  64448. specularColor: BABYLON.Color3;
  64449. specularPower: number;
  64450. private _disableLighting;
  64451. disableLighting: boolean;
  64452. private _maxSimultaneousLights;
  64453. maxSimultaneousLights: number;
  64454. private _renderId;
  64455. constructor(name: string, scene: BABYLON.Scene);
  64456. needAlphaBlending(): boolean;
  64457. needAlphaTesting(): boolean;
  64458. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64459. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64460. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64461. getAnimatables(): BABYLON.IAnimatable[];
  64462. getActiveTextures(): BABYLON.BaseTexture[];
  64463. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64464. dispose(forceDisposeEffect?: boolean): void;
  64465. clone(name: string): TerrainMaterial;
  64466. serialize(): any;
  64467. getClassName(): string;
  64468. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64469. }
  64470. }
  64471. declare module BABYLON {
  64472. /** @hidden */
  64473. export var triplanarPixelShader: {
  64474. name: string;
  64475. shader: string;
  64476. };
  64477. }
  64478. declare module BABYLON {
  64479. /** @hidden */
  64480. export var triplanarVertexShader: {
  64481. name: string;
  64482. shader: string;
  64483. };
  64484. }
  64485. declare module BABYLON {
  64486. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64487. mixTexture: BABYLON.BaseTexture;
  64488. private _diffuseTextureX;
  64489. diffuseTextureX: BABYLON.BaseTexture;
  64490. private _diffuseTextureY;
  64491. diffuseTextureY: BABYLON.BaseTexture;
  64492. private _diffuseTextureZ;
  64493. diffuseTextureZ: BABYLON.BaseTexture;
  64494. private _normalTextureX;
  64495. normalTextureX: BABYLON.BaseTexture;
  64496. private _normalTextureY;
  64497. normalTextureY: BABYLON.BaseTexture;
  64498. private _normalTextureZ;
  64499. normalTextureZ: BABYLON.BaseTexture;
  64500. tileSize: number;
  64501. diffuseColor: BABYLON.Color3;
  64502. specularColor: BABYLON.Color3;
  64503. specularPower: number;
  64504. private _disableLighting;
  64505. disableLighting: boolean;
  64506. private _maxSimultaneousLights;
  64507. maxSimultaneousLights: number;
  64508. private _renderId;
  64509. constructor(name: string, scene: BABYLON.Scene);
  64510. needAlphaBlending(): boolean;
  64511. needAlphaTesting(): boolean;
  64512. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64513. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64514. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64515. getAnimatables(): BABYLON.IAnimatable[];
  64516. getActiveTextures(): BABYLON.BaseTexture[];
  64517. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64518. dispose(forceDisposeEffect?: boolean): void;
  64519. clone(name: string): TriPlanarMaterial;
  64520. serialize(): any;
  64521. getClassName(): string;
  64522. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64523. }
  64524. }
  64525. declare module BABYLON {
  64526. /** @hidden */
  64527. export var waterPixelShader: {
  64528. name: string;
  64529. shader: string;
  64530. };
  64531. }
  64532. declare module BABYLON {
  64533. /** @hidden */
  64534. export var waterVertexShader: {
  64535. name: string;
  64536. shader: string;
  64537. };
  64538. }
  64539. declare module BABYLON {
  64540. export class WaterMaterial extends BABYLON.PushMaterial {
  64541. renderTargetSize: BABYLON.Vector2;
  64542. private _bumpTexture;
  64543. bumpTexture: BABYLON.BaseTexture;
  64544. diffuseColor: BABYLON.Color3;
  64545. specularColor: BABYLON.Color3;
  64546. specularPower: number;
  64547. private _disableLighting;
  64548. disableLighting: boolean;
  64549. private _maxSimultaneousLights;
  64550. maxSimultaneousLights: number;
  64551. /**
  64552. * @param {number}: Represents the wind force
  64553. */
  64554. windForce: number;
  64555. /**
  64556. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64557. */
  64558. windDirection: BABYLON.Vector2;
  64559. /**
  64560. * @param {number}: Wave height, represents the height of the waves
  64561. */
  64562. waveHeight: number;
  64563. /**
  64564. * @param {number}: Bump height, represents the bump height related to the bump map
  64565. */
  64566. bumpHeight: number;
  64567. /**
  64568. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64569. */
  64570. private _bumpSuperimpose;
  64571. bumpSuperimpose: boolean;
  64572. /**
  64573. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64574. */
  64575. private _fresnelSeparate;
  64576. fresnelSeparate: boolean;
  64577. /**
  64578. * @param {boolean}: bump Waves modify the reflection.
  64579. */
  64580. private _bumpAffectsReflection;
  64581. bumpAffectsReflection: boolean;
  64582. /**
  64583. * @param {number}: The water color blended with the refraction (near)
  64584. */
  64585. waterColor: BABYLON.Color3;
  64586. /**
  64587. * @param {number}: The blend factor related to the water color
  64588. */
  64589. colorBlendFactor: number;
  64590. /**
  64591. * @param {number}: The water color blended with the reflection (far)
  64592. */
  64593. waterColor2: BABYLON.Color3;
  64594. /**
  64595. * @param {number}: The blend factor related to the water color (reflection, far)
  64596. */
  64597. colorBlendFactor2: number;
  64598. /**
  64599. * @param {number}: Represents the maximum length of a wave
  64600. */
  64601. waveLength: number;
  64602. /**
  64603. * @param {number}: Defines the waves speed
  64604. */
  64605. waveSpeed: number;
  64606. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64607. private _mesh;
  64608. private _refractionRTT;
  64609. private _reflectionRTT;
  64610. private _reflectionTransform;
  64611. private _lastTime;
  64612. private _lastDeltaTime;
  64613. private _renderId;
  64614. private _useLogarithmicDepth;
  64615. private _waitingRenderList;
  64616. /**
  64617. * Gets a boolean indicating that current material needs to register RTT
  64618. */
  64619. readonly hasRenderTargetTextures: boolean;
  64620. /**
  64621. * Constructor
  64622. */
  64623. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64624. useLogarithmicDepth: boolean;
  64625. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64626. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64627. addToRenderList(node: any): void;
  64628. enableRenderTargets(enable: boolean): void;
  64629. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64630. readonly renderTargetsEnabled: boolean;
  64631. needAlphaBlending(): boolean;
  64632. needAlphaTesting(): boolean;
  64633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64634. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64635. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64636. private _createRenderTargets;
  64637. getAnimatables(): BABYLON.IAnimatable[];
  64638. getActiveTextures(): BABYLON.BaseTexture[];
  64639. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64640. dispose(forceDisposeEffect?: boolean): void;
  64641. clone(name: string): WaterMaterial;
  64642. serialize(): any;
  64643. getClassName(): string;
  64644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64645. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64646. }
  64647. }
  64648. declare module BABYLON {
  64649. /** @hidden */
  64650. export var asciiartPixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module BABYLON {
  64656. /**
  64657. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64658. *
  64659. * It basically takes care rendering the font front the given font size to a texture.
  64660. * This is used later on in the postprocess.
  64661. */
  64662. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64663. private _font;
  64664. private _text;
  64665. private _charSize;
  64666. /**
  64667. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64668. */
  64669. readonly charSize: number;
  64670. /**
  64671. * Create a new instance of the Ascii Art FontTexture class
  64672. * @param name the name of the texture
  64673. * @param font the font to use, use the W3C CSS notation
  64674. * @param text the caracter set to use in the rendering.
  64675. * @param scene the scene that owns the texture
  64676. */
  64677. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64678. /**
  64679. * Gets the max char width of a font.
  64680. * @param font the font to use, use the W3C CSS notation
  64681. * @return the max char width
  64682. */
  64683. private getFontWidth;
  64684. /**
  64685. * Gets the max char height of a font.
  64686. * @param font the font to use, use the W3C CSS notation
  64687. * @return the max char height
  64688. */
  64689. private getFontHeight;
  64690. /**
  64691. * Clones the current AsciiArtTexture.
  64692. * @return the clone of the texture.
  64693. */
  64694. clone(): AsciiArtFontTexture;
  64695. /**
  64696. * Parses a json object representing the texture and returns an instance of it.
  64697. * @param source the source JSON representation
  64698. * @param scene the scene to create the texture for
  64699. * @return the parsed texture
  64700. */
  64701. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64702. }
  64703. /**
  64704. * Option available in the Ascii Art Post Process.
  64705. */
  64706. export interface IAsciiArtPostProcessOptions {
  64707. /**
  64708. * The font to use following the w3c font definition.
  64709. */
  64710. font?: string;
  64711. /**
  64712. * The character set to use in the postprocess.
  64713. */
  64714. characterSet?: string;
  64715. /**
  64716. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64717. * This number is defined between 0 and 1;
  64718. */
  64719. mixToTile?: number;
  64720. /**
  64721. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64722. * This number is defined between 0 and 1;
  64723. */
  64724. mixToNormal?: number;
  64725. }
  64726. /**
  64727. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64728. *
  64729. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64730. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64731. */
  64732. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64733. /**
  64734. * The font texture used to render the char in the post process.
  64735. */
  64736. private _asciiArtFontTexture;
  64737. /**
  64738. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64739. * This number is defined between 0 and 1;
  64740. */
  64741. mixToTile: number;
  64742. /**
  64743. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64744. * This number is defined between 0 and 1;
  64745. */
  64746. mixToNormal: number;
  64747. /**
  64748. * Instantiates a new Ascii Art Post Process.
  64749. * @param name the name to give to the postprocess
  64750. * @camera the camera to apply the post process to.
  64751. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64752. */
  64753. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64754. }
  64755. }
  64756. declare module BABYLON {
  64757. /** @hidden */
  64758. export var digitalrainPixelShader: {
  64759. name: string;
  64760. shader: string;
  64761. };
  64762. }
  64763. declare module BABYLON {
  64764. /**
  64765. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64766. *
  64767. * It basically takes care rendering the font front the given font size to a texture.
  64768. * This is used later on in the postprocess.
  64769. */
  64770. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64771. private _font;
  64772. private _text;
  64773. private _charSize;
  64774. /**
  64775. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64776. */
  64777. readonly charSize: number;
  64778. /**
  64779. * Create a new instance of the Digital Rain FontTexture class
  64780. * @param name the name of the texture
  64781. * @param font the font to use, use the W3C CSS notation
  64782. * @param text the caracter set to use in the rendering.
  64783. * @param scene the scene that owns the texture
  64784. */
  64785. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64786. /**
  64787. * Gets the max char width of a font.
  64788. * @param font the font to use, use the W3C CSS notation
  64789. * @return the max char width
  64790. */
  64791. private getFontWidth;
  64792. /**
  64793. * Gets the max char height of a font.
  64794. * @param font the font to use, use the W3C CSS notation
  64795. * @return the max char height
  64796. */
  64797. private getFontHeight;
  64798. /**
  64799. * Clones the current DigitalRainFontTexture.
  64800. * @return the clone of the texture.
  64801. */
  64802. clone(): DigitalRainFontTexture;
  64803. /**
  64804. * Parses a json object representing the texture and returns an instance of it.
  64805. * @param source the source JSON representation
  64806. * @param scene the scene to create the texture for
  64807. * @return the parsed texture
  64808. */
  64809. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64810. }
  64811. /**
  64812. * Option available in the Digital Rain Post Process.
  64813. */
  64814. export interface IDigitalRainPostProcessOptions {
  64815. /**
  64816. * The font to use following the w3c font definition.
  64817. */
  64818. font?: string;
  64819. /**
  64820. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64821. * This number is defined between 0 and 1;
  64822. */
  64823. mixToTile?: number;
  64824. /**
  64825. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64826. * This number is defined between 0 and 1;
  64827. */
  64828. mixToNormal?: number;
  64829. }
  64830. /**
  64831. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64832. *
  64833. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64834. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64835. */
  64836. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64837. /**
  64838. * The font texture used to render the char in the post process.
  64839. */
  64840. private _digitalRainFontTexture;
  64841. /**
  64842. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64843. * This number is defined between 0 and 1;
  64844. */
  64845. mixToTile: number;
  64846. /**
  64847. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64848. * This number is defined between 0 and 1;
  64849. */
  64850. mixToNormal: number;
  64851. /**
  64852. * Instantiates a new Digital Rain Post Process.
  64853. * @param name the name to give to the postprocess
  64854. * @camera the camera to apply the post process to.
  64855. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64856. */
  64857. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64858. }
  64859. }
  64860. declare module BABYLON {
  64861. /** @hidden */
  64862. export var oceanPostProcessPixelShader: {
  64863. name: string;
  64864. shader: string;
  64865. };
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * Option available in the Ocean Post Process.
  64870. */
  64871. export interface IOceanPostProcessOptions {
  64872. /**
  64873. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64874. */
  64875. reflectionSize?: number | {
  64876. width: number;
  64877. height: number;
  64878. } | {
  64879. ratio: number;
  64880. };
  64881. /**
  64882. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64883. */
  64884. refractionSize?: number | {
  64885. width: number;
  64886. height: number;
  64887. } | {
  64888. ratio: number;
  64889. };
  64890. }
  64891. /**
  64892. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64893. *
  64894. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64895. * Example usage:
  64896. * var pp = new OceanPostProcess("myOcean", camera);
  64897. * pp.reflectionEnabled = true;
  64898. * pp.refractionEnabled = true;
  64899. */
  64900. export class OceanPostProcess extends BABYLON.PostProcess {
  64901. /**
  64902. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64903. */
  64904. /**
  64905. * Sets weither or not the real-time reflection is enabled on the ocean.
  64906. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64907. */
  64908. reflectionEnabled: boolean;
  64909. /**
  64910. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64911. */
  64912. /**
  64913. * Sets weither or not the real-time refraction is enabled on the ocean.
  64914. * Is set to true, the refraction render target texture will be used as refraction texture.
  64915. */
  64916. refractionEnabled: boolean;
  64917. /**
  64918. * Gets wether or not the post-processes is supported by the running hardware.
  64919. * This requires draw buffer supports.
  64920. */
  64921. readonly isSupported: boolean;
  64922. /**
  64923. * This is the reflection mirror texture used to display reflections on the ocean.
  64924. * By default, render list is empty.
  64925. */
  64926. reflectionTexture: BABYLON.MirrorTexture;
  64927. /**
  64928. * This is the refraction render target texture used to display refraction on the ocean.
  64929. * By default, render list is empty.
  64930. */
  64931. refractionTexture: BABYLON.RenderTargetTexture;
  64932. private _time;
  64933. private _cameraRotation;
  64934. private _cameraViewMatrix;
  64935. private _reflectionEnabled;
  64936. private _refractionEnabled;
  64937. private _geometryRenderer;
  64938. /**
  64939. * Instantiates a new Ocean Post Process.
  64940. * @param name the name to give to the postprocess.
  64941. * @camera the camera to apply the post process to.
  64942. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64943. */
  64944. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64945. /**
  64946. * Returns the appropriate defines according to the current configuration.
  64947. */
  64948. private _getDefines;
  64949. /**
  64950. * Computes the current camera rotation as the shader requires a camera rotation.
  64951. */
  64952. private _computeCameraRotation;
  64953. }
  64954. }
  64955. declare module BABYLON {
  64956. /** @hidden */
  64957. export var brickProceduralTexturePixelShader: {
  64958. name: string;
  64959. shader: string;
  64960. };
  64961. }
  64962. declare module BABYLON {
  64963. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64964. private _numberOfBricksHeight;
  64965. private _numberOfBricksWidth;
  64966. private _jointColor;
  64967. private _brickColor;
  64968. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64969. updateShaderUniforms(): void;
  64970. numberOfBricksHeight: number;
  64971. numberOfBricksWidth: number;
  64972. jointColor: BABYLON.Color3;
  64973. brickColor: BABYLON.Color3;
  64974. /**
  64975. * Serializes this brick procedural texture
  64976. * @returns a serialized brick procedural texture object
  64977. */
  64978. serialize(): any;
  64979. /**
  64980. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64981. * @param parsedTexture defines parsed texture data
  64982. * @param scene defines the current scene
  64983. * @param rootUrl defines the root URL containing brick procedural texture information
  64984. * @returns a parsed Brick Procedural BABYLON.Texture
  64985. */
  64986. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64987. }
  64988. }
  64989. declare module BABYLON {
  64990. /** @hidden */
  64991. export var cloudProceduralTexturePixelShader: {
  64992. name: string;
  64993. shader: string;
  64994. };
  64995. }
  64996. declare module BABYLON {
  64997. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64998. private _skyColor;
  64999. private _cloudColor;
  65000. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65001. updateShaderUniforms(): void;
  65002. skyColor: BABYLON.Color4;
  65003. cloudColor: BABYLON.Color4;
  65004. /**
  65005. * Serializes this cloud procedural texture
  65006. * @returns a serialized cloud procedural texture object
  65007. */
  65008. serialize(): any;
  65009. /**
  65010. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  65011. * @param parsedTexture defines parsed texture data
  65012. * @param scene defines the current scene
  65013. * @param rootUrl defines the root URL containing cloud procedural texture information
  65014. * @returns a parsed Cloud Procedural BABYLON.Texture
  65015. */
  65016. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /** @hidden */
  65021. export var fireProceduralTexturePixelShader: {
  65022. name: string;
  65023. shader: string;
  65024. };
  65025. }
  65026. declare module BABYLON {
  65027. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  65028. private _time;
  65029. private _speed;
  65030. private _autoGenerateTime;
  65031. private _fireColors;
  65032. private _alphaThreshold;
  65033. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65034. updateShaderUniforms(): void;
  65035. render(useCameraPostProcess?: boolean): void;
  65036. static readonly PurpleFireColors: BABYLON.Color3[];
  65037. static readonly GreenFireColors: BABYLON.Color3[];
  65038. static readonly RedFireColors: BABYLON.Color3[];
  65039. static readonly BlueFireColors: BABYLON.Color3[];
  65040. autoGenerateTime: boolean;
  65041. fireColors: BABYLON.Color3[];
  65042. time: number;
  65043. speed: BABYLON.Vector2;
  65044. alphaThreshold: number;
  65045. /**
  65046. * Serializes this fire procedural texture
  65047. * @returns a serialized fire procedural texture object
  65048. */
  65049. serialize(): any;
  65050. /**
  65051. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  65052. * @param parsedTexture defines parsed texture data
  65053. * @param scene defines the current scene
  65054. * @param rootUrl defines the root URL containing fire procedural texture information
  65055. * @returns a parsed Fire Procedural BABYLON.Texture
  65056. */
  65057. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /** @hidden */
  65062. export var grassProceduralTexturePixelShader: {
  65063. name: string;
  65064. shader: string;
  65065. };
  65066. }
  65067. declare module BABYLON {
  65068. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  65069. private _grassColors;
  65070. private _groundColor;
  65071. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65072. updateShaderUniforms(): void;
  65073. grassColors: BABYLON.Color3[];
  65074. groundColor: BABYLON.Color3;
  65075. /**
  65076. * Serializes this grass procedural texture
  65077. * @returns a serialized grass procedural texture object
  65078. */
  65079. serialize(): any;
  65080. /**
  65081. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  65082. * @param parsedTexture defines parsed texture data
  65083. * @param scene defines the current scene
  65084. * @param rootUrl defines the root URL containing grass procedural texture information
  65085. * @returns a parsed Grass Procedural BABYLON.Texture
  65086. */
  65087. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  65088. }
  65089. }
  65090. declare module BABYLON {
  65091. /** @hidden */
  65092. export var marbleProceduralTexturePixelShader: {
  65093. name: string;
  65094. shader: string;
  65095. };
  65096. }
  65097. declare module BABYLON {
  65098. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  65099. private _numberOfTilesHeight;
  65100. private _numberOfTilesWidth;
  65101. private _amplitude;
  65102. private _jointColor;
  65103. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65104. updateShaderUniforms(): void;
  65105. numberOfTilesHeight: number;
  65106. amplitude: number;
  65107. numberOfTilesWidth: number;
  65108. jointColor: BABYLON.Color3;
  65109. /**
  65110. * Serializes this marble procedural texture
  65111. * @returns a serialized marble procedural texture object
  65112. */
  65113. serialize(): any;
  65114. /**
  65115. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  65116. * @param parsedTexture defines parsed texture data
  65117. * @param scene defines the current scene
  65118. * @param rootUrl defines the root URL containing marble procedural texture information
  65119. * @returns a parsed Marble Procedural BABYLON.Texture
  65120. */
  65121. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  65122. }
  65123. }
  65124. declare module BABYLON {
  65125. /** @hidden */
  65126. export var normalMapProceduralTexturePixelShader: {
  65127. name: string;
  65128. shader: string;
  65129. };
  65130. }
  65131. declare module BABYLON {
  65132. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65133. private _baseTexture;
  65134. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65135. updateShaderUniforms(): void;
  65136. render(useCameraPostProcess?: boolean): void;
  65137. resize(size: any, generateMipMaps: any): void;
  65138. baseTexture: BABYLON.Texture;
  65139. /**
  65140. * Serializes this normal map procedural texture
  65141. * @returns a serialized normal map procedural texture object
  65142. */
  65143. serialize(): any;
  65144. /**
  65145. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65146. * @param parsedTexture defines parsed texture data
  65147. * @param scene defines the current scene
  65148. * @param rootUrl defines the root URL containing normal map procedural texture information
  65149. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65150. */
  65151. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /** @hidden */
  65156. export var perlinNoiseProceduralTexturePixelShader: {
  65157. name: string;
  65158. shader: string;
  65159. };
  65160. }
  65161. declare module BABYLON {
  65162. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65163. time: number;
  65164. timeScale: number;
  65165. translationSpeed: number;
  65166. private _currentTranslation;
  65167. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65168. updateShaderUniforms(): void;
  65169. render(useCameraPostProcess?: boolean): void;
  65170. resize(size: any, generateMipMaps: any): void;
  65171. /**
  65172. * Serializes this perlin noise procedural texture
  65173. * @returns a serialized perlin noise procedural texture object
  65174. */
  65175. serialize(): any;
  65176. /**
  65177. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  65178. * @param parsedTexture defines parsed texture data
  65179. * @param scene defines the current scene
  65180. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  65181. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65182. */
  65183. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /** @hidden */
  65188. export var roadProceduralTexturePixelShader: {
  65189. name: string;
  65190. shader: string;
  65191. };
  65192. }
  65193. declare module BABYLON {
  65194. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65195. private _roadColor;
  65196. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65197. updateShaderUniforms(): void;
  65198. roadColor: BABYLON.Color3;
  65199. /**
  65200. * Serializes this road procedural texture
  65201. * @returns a serialized road procedural texture object
  65202. */
  65203. serialize(): any;
  65204. /**
  65205. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65206. * @param parsedTexture defines parsed texture data
  65207. * @param scene defines the current scene
  65208. * @param rootUrl defines the root URL containing road procedural texture information
  65209. * @returns a parsed Road Procedural BABYLON.Texture
  65210. */
  65211. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /** @hidden */
  65216. export var starfieldProceduralTexturePixelShader: {
  65217. name: string;
  65218. shader: string;
  65219. };
  65220. }
  65221. declare module BABYLON {
  65222. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65223. private _time;
  65224. private _alpha;
  65225. private _beta;
  65226. private _zoom;
  65227. private _formuparam;
  65228. private _stepsize;
  65229. private _tile;
  65230. private _brightness;
  65231. private _darkmatter;
  65232. private _distfading;
  65233. private _saturation;
  65234. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65235. updateShaderUniforms(): void;
  65236. time: number;
  65237. alpha: number;
  65238. beta: number;
  65239. formuparam: number;
  65240. stepsize: number;
  65241. zoom: number;
  65242. tile: number;
  65243. brightness: number;
  65244. darkmatter: number;
  65245. distfading: number;
  65246. saturation: number;
  65247. /**
  65248. * Serializes this starfield procedural texture
  65249. * @returns a serialized starfield procedural texture object
  65250. */
  65251. serialize(): any;
  65252. /**
  65253. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65254. * @param parsedTexture defines parsed texture data
  65255. * @param scene defines the current scene
  65256. * @param rootUrl defines the root URL containing startfield procedural texture information
  65257. * @returns a parsed Starfield Procedural BABYLON.Texture
  65258. */
  65259. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /** @hidden */
  65264. export var woodProceduralTexturePixelShader: {
  65265. name: string;
  65266. shader: string;
  65267. };
  65268. }
  65269. declare module BABYLON {
  65270. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65271. private _ampScale;
  65272. private _woodColor;
  65273. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65274. updateShaderUniforms(): void;
  65275. ampScale: number;
  65276. woodColor: BABYLON.Color3;
  65277. /**
  65278. * Serializes this wood procedural texture
  65279. * @returns a serialized wood procedural texture object
  65280. */
  65281. serialize(): any;
  65282. /**
  65283. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65284. * @param parsedTexture defines parsed texture data
  65285. * @param scene defines the current scene
  65286. * @param rootUrl defines the root URL containing wood procedural texture information
  65287. * @returns a parsed Wood Procedural BABYLON.Texture
  65288. */
  65289. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65290. }
  65291. }