babylon.d.txt 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173
  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. * Get the current class name of the texture useful for serialization or dynamic coding.
  8465. * @returns "CubeTexture"
  8466. */
  8467. getClassName(): string;
  8468. /**
  8469. * Update the url (and optional buffer) of this texture if url was null during construction.
  8470. * @param url the url of the texture
  8471. * @param forcedExtension defines the extension to use
  8472. * @param onLoad callback called when the texture is loaded (defaults to null)
  8473. */
  8474. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8475. /**
  8476. * Delays loading of the cube texture
  8477. * @param forcedExtension defines the extension to use
  8478. */
  8479. delayLoad(forcedExtension?: string): void;
  8480. /**
  8481. * Returns the reflection texture matrix
  8482. * @returns the reflection texture matrix
  8483. */
  8484. getReflectionTextureMatrix(): Matrix;
  8485. /**
  8486. * Sets the reflection texture matrix
  8487. * @param value Reflection texture matrix
  8488. */
  8489. setReflectionTextureMatrix(value: Matrix): void;
  8490. /**
  8491. * Parses text to create a cube texture
  8492. * @param parsedTexture define the serialized text to read from
  8493. * @param scene defines the hosting scene
  8494. * @param rootUrl defines the root url of the cube texture
  8495. * @returns a cube texture
  8496. */
  8497. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8498. /**
  8499. * Makes a clone, or deep copy, of the cube texture
  8500. * @returns a new cube texture
  8501. */
  8502. clone(): CubeTexture;
  8503. }
  8504. }
  8505. declare module BABYLON {
  8506. /** @hidden */
  8507. export var postprocessVertexShader: {
  8508. name: string;
  8509. shader: string;
  8510. };
  8511. }
  8512. declare module BABYLON {
  8513. /**
  8514. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8515. * This is the base of the follow, arc rotate cameras and Free camera
  8516. * @see http://doc.babylonjs.com/features/cameras
  8517. */
  8518. export class TargetCamera extends Camera {
  8519. private static _RigCamTransformMatrix;
  8520. private static _TargetTransformMatrix;
  8521. private static _TargetFocalPoint;
  8522. /**
  8523. * Define the current direction the camera is moving to
  8524. */
  8525. cameraDirection: Vector3;
  8526. /**
  8527. * Define the current rotation the camera is rotating to
  8528. */
  8529. cameraRotation: Vector2;
  8530. /**
  8531. * When set, the up vector of the camera will be updated by the rotation of the camera
  8532. */
  8533. updateUpVectorFromRotation: boolean;
  8534. private _tmpQuaternion;
  8535. /**
  8536. * Define the current rotation of the camera
  8537. */
  8538. rotation: Vector3;
  8539. /**
  8540. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8541. */
  8542. rotationQuaternion: Quaternion;
  8543. /**
  8544. * Define the current speed of the camera
  8545. */
  8546. speed: number;
  8547. /**
  8548. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8549. * around all axis.
  8550. */
  8551. noRotationConstraint: boolean;
  8552. /**
  8553. * Define the current target of the camera as an object or a position.
  8554. */
  8555. lockedTarget: any;
  8556. /** @hidden */ currentTarget: Vector3;
  8557. /** @hidden */ initialFocalDistance: number;
  8558. /** @hidden */ viewMatrix: Matrix;
  8559. /** @hidden */ camMatrix: Matrix;
  8560. /** @hidden */ cameraTransformMatrix: Matrix;
  8561. /** @hidden */ cameraRotationMatrix: Matrix;
  8562. /** @hidden */ referencePoint: Vector3;
  8563. /** @hidden */ transformedReferencePoint: Vector3;
  8564. protected _globalCurrentTarget: Vector3;
  8565. protected _globalCurrentUpVector: Vector3;
  8566. /** @hidden */ reset: () => void;
  8567. private _defaultUp;
  8568. /**
  8569. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8570. * This is the base of the follow, arc rotate cameras and Free camera
  8571. * @see http://doc.babylonjs.com/features/cameras
  8572. * @param name Defines the name of the camera in the scene
  8573. * @param position Defines the start position of the camera in the scene
  8574. * @param scene Defines the scene the camera belongs to
  8575. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8576. */
  8577. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8578. /**
  8579. * Gets the position in front of the camera at a given distance.
  8580. * @param distance The distance from the camera we want the position to be
  8581. * @returns the position
  8582. */
  8583. getFrontPosition(distance: number): Vector3;
  8584. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8585. private _storedPosition;
  8586. private _storedRotation;
  8587. private _storedRotationQuaternion;
  8588. /**
  8589. * Store current camera state of the camera (fov, position, rotation, etc..)
  8590. * @returns the camera
  8591. */
  8592. storeState(): Camera;
  8593. /**
  8594. * Restored camera state. You must call storeState() first
  8595. * @returns whether it was successful or not
  8596. * @hidden
  8597. */ restoreStateValues(): boolean;
  8598. /** @hidden */ initCache(): void;
  8599. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8600. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8601. /** @hidden */ computeLocalCameraSpeed(): number;
  8602. /**
  8603. * Defines the target the camera should look at.
  8604. * This will automatically adapt alpha beta and radius to fit within the new target.
  8605. * @param target Defines the new target as a Vector or a mesh
  8606. */
  8607. setTarget(target: Vector3): void;
  8608. /**
  8609. * Return the current target position of the camera. This value is expressed in local space.
  8610. * @returns the target position
  8611. */
  8612. getTarget(): Vector3;
  8613. /** @hidden */ decideIfNeedsToMove(): boolean;
  8614. /** @hidden */ updatePosition(): void;
  8615. /** @hidden */ checkInputs(): void;
  8616. protected _updateCameraRotationMatrix(): void;
  8617. /**
  8618. * 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)
  8619. * @returns the current camera
  8620. */
  8621. private _rotateUpVectorWithCameraRotationMatrix;
  8622. private _cachedRotationZ;
  8623. private _cachedQuaternionRotationZ;
  8624. /** @hidden */ getViewMatrix(): Matrix;
  8625. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8626. /**
  8627. * @hidden
  8628. */
  8629. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8630. /**
  8631. * @hidden
  8632. */ updateRigCameras(): void;
  8633. private _getRigCamPositionAndTarget;
  8634. /**
  8635. * Gets the current object class name.
  8636. * @return the class name
  8637. */
  8638. getClassName(): string;
  8639. }
  8640. }
  8641. declare module BABYLON {
  8642. /**
  8643. * @ignore
  8644. * This is a list of all the different input types that are available in the application.
  8645. * Fo instance: ArcRotateCameraGamepadInput...
  8646. */
  8647. export var CameraInputTypes: {};
  8648. /**
  8649. * This is the contract to implement in order to create a new input class.
  8650. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8651. */
  8652. export interface ICameraInput<TCamera extends Camera> {
  8653. /**
  8654. * Defines the camera the input is attached to.
  8655. */
  8656. camera: Nullable<TCamera>;
  8657. /**
  8658. * Gets the class name of the current intput.
  8659. * @returns the class name
  8660. */
  8661. getClassName(): string;
  8662. /**
  8663. * Get the friendly name associated with the input class.
  8664. * @returns the input friendly name
  8665. */
  8666. getSimpleName(): string;
  8667. /**
  8668. * Attach the input controls to a specific dom element to get the input from.
  8669. * @param element Defines the element the controls should be listened from
  8670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8671. */
  8672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8673. /**
  8674. * Detach the current controls from the specified dom element.
  8675. * @param element Defines the element to stop listening the inputs from
  8676. */
  8677. detachControl(element: Nullable<HTMLElement>): void;
  8678. /**
  8679. * Update the current camera state depending on the inputs that have been used this frame.
  8680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8681. */
  8682. checkInputs?: () => void;
  8683. }
  8684. /**
  8685. * Represents a map of input types to input instance or input index to input instance.
  8686. */
  8687. export interface CameraInputsMap<TCamera extends Camera> {
  8688. /**
  8689. * Accessor to the input by input type.
  8690. */
  8691. [name: string]: ICameraInput<TCamera>;
  8692. /**
  8693. * Accessor to the input by input index.
  8694. */
  8695. [idx: number]: ICameraInput<TCamera>;
  8696. }
  8697. /**
  8698. * This represents the input manager used within a camera.
  8699. * It helps dealing with all the different kind of input attached to a camera.
  8700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8701. */
  8702. export class CameraInputsManager<TCamera extends Camera> {
  8703. /**
  8704. * Defines the list of inputs attahed to the camera.
  8705. */
  8706. attached: CameraInputsMap<TCamera>;
  8707. /**
  8708. * Defines the dom element the camera is collecting inputs from.
  8709. * This is null if the controls have not been attached.
  8710. */
  8711. attachedElement: Nullable<HTMLElement>;
  8712. /**
  8713. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8714. */
  8715. noPreventDefault: boolean;
  8716. /**
  8717. * Defined the camera the input manager belongs to.
  8718. */
  8719. camera: TCamera;
  8720. /**
  8721. * Update the current camera state depending on the inputs that have been used this frame.
  8722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8723. */
  8724. checkInputs: () => void;
  8725. /**
  8726. * Instantiate a new Camera Input Manager.
  8727. * @param camera Defines the camera the input manager blongs to
  8728. */
  8729. constructor(camera: TCamera);
  8730. /**
  8731. * Add an input method to a camera
  8732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8733. * @param input camera input method
  8734. */
  8735. add(input: ICameraInput<TCamera>): void;
  8736. /**
  8737. * Remove a specific input method from a camera
  8738. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8739. * @param inputToRemove camera input method
  8740. */
  8741. remove(inputToRemove: ICameraInput<TCamera>): void;
  8742. /**
  8743. * Remove a specific input type from a camera
  8744. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8745. * @param inputType the type of the input to remove
  8746. */
  8747. removeByType(inputType: string): void;
  8748. private _addCheckInputs;
  8749. /**
  8750. * Attach the input controls to the currently attached dom element to listen the events from.
  8751. * @param input Defines the input to attach
  8752. */
  8753. attachInput(input: ICameraInput<TCamera>): void;
  8754. /**
  8755. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8756. * @param element Defines the dom element to collect the events from
  8757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8760. /**
  8761. * Detach the current manager inputs controls from a specific dom element.
  8762. * @param element Defines the dom element to collect the events from
  8763. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8764. */
  8765. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8766. /**
  8767. * Rebuild the dynamic inputCheck function from the current list of
  8768. * defined inputs in the manager.
  8769. */
  8770. rebuildInputCheck(): void;
  8771. /**
  8772. * Remove all attached input methods from a camera
  8773. */
  8774. clear(): void;
  8775. /**
  8776. * Serialize the current input manager attached to a camera.
  8777. * This ensures than once parsed,
  8778. * the input associated to the camera will be identical to the current ones
  8779. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8780. */
  8781. serialize(serializedCamera: any): void;
  8782. /**
  8783. * Parses an input manager serialized JSON to restore the previous list of inputs
  8784. * and states associated to a camera.
  8785. * @param parsedCamera Defines the JSON to parse
  8786. */
  8787. parse(parsedCamera: any): void;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Gather the list of keyboard event types as constants.
  8793. */
  8794. export class KeyboardEventTypes {
  8795. /**
  8796. * The keydown event is fired when a key becomes active (pressed).
  8797. */
  8798. static readonly KEYDOWN: number;
  8799. /**
  8800. * The keyup event is fired when a key has been released.
  8801. */
  8802. static readonly KEYUP: number;
  8803. }
  8804. /**
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. */
  8807. export class KeyboardInfo {
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number;
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent;
  8816. /**
  8817. * Instantiates a new keyboard info.
  8818. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8819. * @param type Defines the type of event (KeyboardEventTypes)
  8820. * @param event Defines the related dom event
  8821. */
  8822. constructor(
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number,
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent);
  8831. }
  8832. /**
  8833. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8834. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8835. */
  8836. export class KeyboardInfoPre extends KeyboardInfo {
  8837. /**
  8838. * Defines the type of event (KeyboardEventTypes)
  8839. */
  8840. type: number;
  8841. /**
  8842. * Defines the related dom event
  8843. */
  8844. event: KeyboardEvent;
  8845. /**
  8846. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8847. */
  8848. skipOnPointerObservable: boolean;
  8849. /**
  8850. * Instantiates a new keyboard pre info.
  8851. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8852. * @param type Defines the type of event (KeyboardEventTypes)
  8853. * @param event Defines the related dom event
  8854. */
  8855. constructor(
  8856. /**
  8857. * Defines the type of event (KeyboardEventTypes)
  8858. */
  8859. type: number,
  8860. /**
  8861. * Defines the related dom event
  8862. */
  8863. event: KeyboardEvent);
  8864. }
  8865. }
  8866. declare module BABYLON {
  8867. /**
  8868. * Manage the keyboard inputs to control the movement of a free camera.
  8869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8870. */
  8871. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8872. /**
  8873. * Defines the camera the input is attached to.
  8874. */
  8875. camera: FreeCamera;
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8878. */
  8879. keysUp: number[];
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8882. */
  8883. keysDown: number[];
  8884. /**
  8885. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8886. */
  8887. keysLeft: number[];
  8888. /**
  8889. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8890. */
  8891. keysRight: number[];
  8892. private _keys;
  8893. private _onCanvasBlurObserver;
  8894. private _onKeyboardObserver;
  8895. private _engine;
  8896. private _scene;
  8897. /**
  8898. * Attach the input controls to a specific dom element to get the input from.
  8899. * @param element Defines the element the controls should be listened from
  8900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8901. */
  8902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8903. /**
  8904. * Detach the current controls from the specified dom element.
  8905. * @param element Defines the element to stop listening the inputs from
  8906. */
  8907. detachControl(element: Nullable<HTMLElement>): void;
  8908. /**
  8909. * Update the current camera state depending on the inputs that have been used this frame.
  8910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8911. */
  8912. checkInputs(): void;
  8913. /**
  8914. * Gets the class name of the current intput.
  8915. * @returns the class name
  8916. */
  8917. getClassName(): string;
  8918. /** @hidden */ onLostFocus(): void;
  8919. /**
  8920. * Get the friendly name associated with the input class.
  8921. * @returns the input friendly name
  8922. */
  8923. getSimpleName(): string;
  8924. }
  8925. }
  8926. declare module BABYLON {
  8927. /**
  8928. * Interface describing all the common properties and methods a shadow light needs to implement.
  8929. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8930. * as well as binding the different shadow properties to the effects.
  8931. */
  8932. export interface IShadowLight extends Light {
  8933. /**
  8934. * The light id in the scene (used in scene.findLighById for instance)
  8935. */
  8936. id: string;
  8937. /**
  8938. * The position the shdow will be casted from.
  8939. */
  8940. position: Vector3;
  8941. /**
  8942. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8943. */
  8944. direction: Vector3;
  8945. /**
  8946. * The transformed position. Position of the light in world space taking parenting in account.
  8947. */
  8948. transformedPosition: Vector3;
  8949. /**
  8950. * The transformed direction. Direction of the light in world space taking parenting in account.
  8951. */
  8952. transformedDirection: Vector3;
  8953. /**
  8954. * The friendly name of the light in the scene.
  8955. */
  8956. name: string;
  8957. /**
  8958. * Defines the shadow projection clipping minimum z value.
  8959. */
  8960. shadowMinZ: number;
  8961. /**
  8962. * Defines the shadow projection clipping maximum z value.
  8963. */
  8964. shadowMaxZ: number;
  8965. /**
  8966. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8967. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8968. */
  8969. computeTransformedInformation(): boolean;
  8970. /**
  8971. * Gets the scene the light belongs to.
  8972. * @returns The scene
  8973. */
  8974. getScene(): Scene;
  8975. /**
  8976. * Callback defining a custom Projection Matrix Builder.
  8977. * This can be used to override the default projection matrix computation.
  8978. */
  8979. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8980. /**
  8981. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8982. * @param matrix The materix to updated with the projection information
  8983. * @param viewMatrix The transform matrix of the light
  8984. * @param renderList The list of mesh to render in the map
  8985. * @returns The current light
  8986. */
  8987. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8988. /**
  8989. * Gets the current depth scale used in ESM.
  8990. * @returns The scale
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8995. * @returns true if a cube texture needs to be use
  8996. */
  8997. needCube(): boolean;
  8998. /**
  8999. * Detects if the projection matrix requires to be recomputed this frame.
  9000. * @returns true if it requires to be recomputed otherwise, false.
  9001. */
  9002. needProjectionMatrixCompute(): boolean;
  9003. /**
  9004. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9005. */
  9006. forceProjectionMatrixCompute(): void;
  9007. /**
  9008. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9009. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9010. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9011. */
  9012. getShadowDirection(faceIndex?: number): Vector3;
  9013. /**
  9014. * Gets the minZ used for shadow according to both the scene and the light.
  9015. * @param activeCamera The camera we are returning the min for
  9016. * @returns the depth min z
  9017. */
  9018. getDepthMinZ(activeCamera: Camera): number;
  9019. /**
  9020. * Gets the maxZ used for shadow according to both the scene and the light.
  9021. * @param activeCamera The camera we are returning the max for
  9022. * @returns the depth max z
  9023. */
  9024. getDepthMaxZ(activeCamera: Camera): number;
  9025. }
  9026. /**
  9027. * Base implementation IShadowLight
  9028. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9029. */
  9030. export abstract class ShadowLight extends Light implements IShadowLight {
  9031. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9032. protected _position: Vector3;
  9033. protected _setPosition(value: Vector3): void;
  9034. /**
  9035. * Sets the position the shadow will be casted from. Also use as the light position for both
  9036. * point and spot lights.
  9037. */
  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. position: Vector3;
  9043. protected _direction: Vector3;
  9044. protected _setDirection(value: Vector3): void;
  9045. /**
  9046. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9047. * Also use as the light direction on spot and directional lights.
  9048. */
  9049. /**
  9050. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9051. * Also use as the light direction on spot and directional lights.
  9052. */
  9053. direction: Vector3;
  9054. private _shadowMinZ;
  9055. /**
  9056. * Gets the shadow projection clipping minimum z value.
  9057. */
  9058. /**
  9059. * Sets the shadow projection clipping minimum z value.
  9060. */
  9061. shadowMinZ: number;
  9062. private _shadowMaxZ;
  9063. /**
  9064. * Sets the shadow projection clipping maximum z value.
  9065. */
  9066. /**
  9067. * Gets the shadow projection clipping maximum z value.
  9068. */
  9069. shadowMaxZ: number;
  9070. /**
  9071. * Callback defining a custom Projection Matrix Builder.
  9072. * This can be used to override the default projection matrix computation.
  9073. */
  9074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9075. /**
  9076. * The transformed position. Position of the light in world space taking parenting in account.
  9077. */
  9078. transformedPosition: Vector3;
  9079. /**
  9080. * The transformed direction. Direction of the light in world space taking parenting in account.
  9081. */
  9082. transformedDirection: Vector3;
  9083. private _needProjectionMatrixCompute;
  9084. /**
  9085. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9086. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9087. */
  9088. computeTransformedInformation(): boolean;
  9089. /**
  9090. * Return the depth scale used for the shadow map.
  9091. * @returns the depth scale.
  9092. */
  9093. getDepthScale(): number;
  9094. /**
  9095. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9096. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9097. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9098. */
  9099. getShadowDirection(faceIndex?: number): Vector3;
  9100. /**
  9101. * Returns the ShadowLight absolute position in the World.
  9102. * @returns the position vector in world space
  9103. */
  9104. getAbsolutePosition(): Vector3;
  9105. /**
  9106. * Sets the ShadowLight direction toward the passed target.
  9107. * @param target The point to target in local space
  9108. * @returns the updated ShadowLight direction
  9109. */
  9110. setDirectionToTarget(target: Vector3): Vector3;
  9111. /**
  9112. * Returns the light rotation in euler definition.
  9113. * @returns the x y z rotation in local space.
  9114. */
  9115. getRotation(): Vector3;
  9116. /**
  9117. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9118. * @returns true if a cube texture needs to be use
  9119. */
  9120. needCube(): boolean;
  9121. /**
  9122. * Detects if the projection matrix requires to be recomputed this frame.
  9123. * @returns true if it requires to be recomputed otherwise, false.
  9124. */
  9125. needProjectionMatrixCompute(): boolean;
  9126. /**
  9127. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9128. */
  9129. forceProjectionMatrixCompute(): void;
  9130. /** @hidden */ initCache(): void;
  9131. /** @hidden */ isSynchronized(): boolean;
  9132. /**
  9133. * Computes the world matrix of the node
  9134. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9135. * @returns the world matrix
  9136. */
  9137. computeWorldMatrix(force?: boolean): Matrix;
  9138. /**
  9139. * Gets the minZ used for shadow according to both the scene and the light.
  9140. * @param activeCamera The camera we are returning the min for
  9141. * @returns the depth min z
  9142. */
  9143. getDepthMinZ(activeCamera: Camera): number;
  9144. /**
  9145. * Gets the maxZ used for shadow according to both the scene and the light.
  9146. * @param activeCamera The camera we are returning the max for
  9147. * @returns the depth max z
  9148. */
  9149. getDepthMaxZ(activeCamera: Camera): number;
  9150. /**
  9151. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9152. * @param matrix The materix to updated with the projection information
  9153. * @param viewMatrix The transform matrix of the light
  9154. * @param renderList The list of mesh to render in the map
  9155. * @returns The current light
  9156. */
  9157. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9158. }
  9159. }
  9160. declare module BABYLON {
  9161. /**
  9162. * "Static Class" containing the most commonly used helper while dealing with material for
  9163. * rendering purpose.
  9164. *
  9165. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9166. *
  9167. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9168. */
  9169. export class MaterialHelper {
  9170. /**
  9171. * Bind the current view position to an effect.
  9172. * @param effect The effect to be bound
  9173. * @param scene The scene the eyes position is used from
  9174. */
  9175. static BindEyePosition(effect: Effect, scene: Scene): void;
  9176. /**
  9177. * Helps preparing the defines values about the UVs in used in the effect.
  9178. * UVs are shared as much as we can accross channels in the shaders.
  9179. * @param texture The texture we are preparing the UVs for
  9180. * @param defines The defines to update
  9181. * @param key The channel key "diffuse", "specular"... used in the shader
  9182. */
  9183. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9184. /**
  9185. * Binds a texture matrix value to its corrsponding uniform
  9186. * @param texture The texture to bind the matrix for
  9187. * @param uniformBuffer The uniform buffer receivin the data
  9188. * @param key The channel key "diffuse", "specular"... used in the shader
  9189. */
  9190. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9191. /**
  9192. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9193. * @param mesh defines the current mesh
  9194. * @param scene defines the current scene
  9195. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9196. * @param pointsCloud defines if point cloud rendering has to be turned on
  9197. * @param fogEnabled defines if fog has to be turned on
  9198. * @param alphaTest defines if alpha testing has to be turned on
  9199. * @param defines defines the current list of defines
  9200. */
  9201. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9202. /**
  9203. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9204. * @param scene defines the current scene
  9205. * @param engine defines the current engine
  9206. * @param defines specifies the list of active defines
  9207. * @param useInstances defines if instances have to be turned on
  9208. * @param useClipPlane defines if clip plane have to be turned on
  9209. */
  9210. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9211. /**
  9212. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9213. * @param mesh The mesh containing the geometry data we will draw
  9214. * @param defines The defines to update
  9215. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9216. * @param useBones Precise whether bones should be used or not (override mesh info)
  9217. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9218. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9219. * @returns false if defines are considered not dirty and have not been checked
  9220. */
  9221. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9222. /**
  9223. * Prepares the defines related to multiview
  9224. * @param scene The scene we are intending to draw
  9225. * @param defines The defines to update
  9226. */
  9227. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9228. /**
  9229. * Prepares the defines related to the light information passed in parameter
  9230. * @param scene The scene we are intending to draw
  9231. * @param mesh The mesh the effect is compiling for
  9232. * @param defines The defines to update
  9233. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9234. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9235. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9236. * @returns true if normals will be required for the rest of the effect
  9237. */
  9238. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9239. /**
  9240. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9241. * that won t be acctive due to defines being turned off.
  9242. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9243. * @param samplersList The samplers list
  9244. * @param defines The defines helping in the list generation
  9245. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9246. */
  9247. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9248. /**
  9249. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9250. * @param defines The defines to update while falling back
  9251. * @param fallbacks The authorized effect fallbacks
  9252. * @param maxSimultaneousLights The maximum number of lights allowed
  9253. * @param rank the current rank of the Effect
  9254. * @returns The newly affected rank
  9255. */
  9256. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9257. /**
  9258. * Prepares the list of attributes required for morph targets according to the effect defines.
  9259. * @param attribs The current list of supported attribs
  9260. * @param mesh The mesh to prepare the morph targets attributes for
  9261. * @param defines The current Defines of the effect
  9262. */
  9263. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9264. /**
  9265. * Prepares the list of attributes required for bones according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param mesh The mesh to prepare the bones attributes for
  9268. * @param defines The current Defines of the effect
  9269. * @param fallbacks The current efffect fallback strategy
  9270. */
  9271. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9272. /**
  9273. * Prepares the list of attributes required for instances according to the effect defines.
  9274. * @param attribs The current list of supported attribs
  9275. * @param defines The current Defines of the effect
  9276. */
  9277. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9278. /**
  9279. * Binds the light shadow information to the effect for the given mesh.
  9280. * @param light The light containing the generator
  9281. * @param scene The scene the lights belongs to
  9282. * @param mesh The mesh we are binding the information to render
  9283. * @param lightIndex The light index in the effect used to render the mesh
  9284. * @param effect The effect we are binding the data to
  9285. */
  9286. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9287. /**
  9288. * Binds the light information to the effect.
  9289. * @param light The light containing the generator
  9290. * @param effect The effect we are binding the data to
  9291. * @param lightIndex The light index in the effect used to render
  9292. */
  9293. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9294. /**
  9295. * Binds the lights information from the scene to the effect for the given mesh.
  9296. * @param scene The scene the lights belongs to
  9297. * @param mesh The mesh we are binding the information to render
  9298. * @param effect The effect we are binding the data to
  9299. * @param defines The generated defines for the effect
  9300. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9301. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9302. */
  9303. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9304. private static _tempFogColor;
  9305. /**
  9306. * Binds the fog information from the scene to the effect for the given mesh.
  9307. * @param scene The scene the lights belongs to
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. * @param linearSpace Defines if the fog effect is applied in linear space
  9311. */
  9312. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9313. /**
  9314. * Binds the bones information from the mesh to the effect.
  9315. * @param mesh The mesh we are binding the information to render
  9316. * @param effect The effect we are binding the data to
  9317. */
  9318. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9319. /**
  9320. * Binds the morph targets information from the mesh to the effect.
  9321. * @param abstractMesh The mesh we are binding the information to render
  9322. * @param effect The effect we are binding the data to
  9323. */
  9324. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9325. /**
  9326. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9327. * @param defines The generated defines used in the effect
  9328. * @param effect The effect we are binding the data to
  9329. * @param scene The scene we are willing to render with logarithmic scale for
  9330. */
  9331. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9332. /**
  9333. * Binds the clip plane information from the scene to the effect.
  9334. * @param scene The scene the clip plane information are extracted from
  9335. * @param effect The effect we are binding the data to
  9336. */
  9337. static BindClipPlane(effect: Effect, scene: Scene): void;
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var kernelBlurVaryingDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var kernelBlurFragment: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var kernelBlurFragment2: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var kernelBlurPixelShader: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var kernelBlurVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var kernelBlurVertexShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /**
  9384. * The Blur Post Process which blurs an image based on a kernel and direction.
  9385. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9386. */
  9387. export class BlurPostProcess extends PostProcess {
  9388. /** The direction in which to blur the image. */
  9389. direction: Vector2;
  9390. private blockCompilation;
  9391. protected _kernel: number;
  9392. protected _idealKernel: number;
  9393. protected _packedFloat: boolean;
  9394. private _staticDefines;
  9395. /**
  9396. * Sets the length in pixels of the blur sample region
  9397. */
  9398. /**
  9399. * Gets the length in pixels of the blur sample region
  9400. */
  9401. kernel: number;
  9402. /**
  9403. * Sets wether or not the blur needs to unpack/repack floats
  9404. */
  9405. /**
  9406. * Gets wether or not the blur is unpacking/repacking floats
  9407. */
  9408. packedFloat: boolean;
  9409. /**
  9410. * Creates a new instance BlurPostProcess
  9411. * @param name The name of the effect.
  9412. * @param direction The direction in which to blur the image.
  9413. * @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.
  9414. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9415. * @param camera The camera to apply the render pass to.
  9416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9417. * @param engine The engine which the post process will be applied. (default: current engine)
  9418. * @param reusable If the post process can be reused on the same frame. (default: false)
  9419. * @param textureType Type of textures used when performing the post process. (default: 0)
  9420. * @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)
  9421. */
  9422. constructor(name: string,
  9423. /** The direction in which to blur the image. */
  9424. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9425. /**
  9426. * Updates the effect with the current post process compile time values and recompiles the shader.
  9427. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9428. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9429. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9430. * @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
  9431. * @param onCompiled Called when the shader has been compiled.
  9432. * @param onError Called if there is an error when compiling a shader.
  9433. */
  9434. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9435. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9436. /**
  9437. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9438. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9439. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9440. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9441. * The gaps between physical kernels are compensated for in the weighting of the samples
  9442. * @param idealKernel Ideal blur kernel.
  9443. * @return Nearest best kernel.
  9444. */
  9445. protected _nearestBestKernel(idealKernel: number): number;
  9446. /**
  9447. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9448. * @param x The point on the Gaussian distribution to sample.
  9449. * @return the value of the Gaussian function at x.
  9450. */
  9451. protected _gaussianWeight(x: number): number;
  9452. /**
  9453. * Generates a string that can be used as a floating point number in GLSL.
  9454. * @param x Value to print.
  9455. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9456. * @return GLSL float string.
  9457. */
  9458. protected _glslFloat(x: number, decimalFigures?: number): string;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. /** @hidden */
  9463. export var shadowMapPixelShader: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module BABYLON {
  9469. /** @hidden */
  9470. export var bonesDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module BABYLON {
  9476. /** @hidden */
  9477. export var morphTargetsVertexGlobalDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module BABYLON {
  9483. /** @hidden */
  9484. export var morphTargetsVertexDeclaration: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module BABYLON {
  9490. /** @hidden */
  9491. export var instancesDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module BABYLON {
  9497. /** @hidden */
  9498. export var helperFunctions: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module BABYLON {
  9504. /** @hidden */
  9505. export var morphTargetsVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module BABYLON {
  9511. /** @hidden */
  9512. export var instancesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module BABYLON {
  9518. /** @hidden */
  9519. export var bonesVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module BABYLON {
  9525. /** @hidden */
  9526. export var shadowMapVertexShader: {
  9527. name: string;
  9528. shader: string;
  9529. };
  9530. }
  9531. declare module BABYLON {
  9532. /** @hidden */
  9533. export var depthBoxBlurPixelShader: {
  9534. name: string;
  9535. shader: string;
  9536. };
  9537. }
  9538. declare module BABYLON {
  9539. /**
  9540. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9541. */
  9542. export interface ICustomShaderOptions {
  9543. /**
  9544. * Gets or sets the custom shader name to use
  9545. */
  9546. shaderName: string;
  9547. /**
  9548. * The list of attribute names used in the shader
  9549. */
  9550. attributes?: string[];
  9551. /**
  9552. * The list of unifrom names used in the shader
  9553. */
  9554. uniforms?: string[];
  9555. /**
  9556. * The list of sampler names used in the shader
  9557. */
  9558. samplers?: string[];
  9559. /**
  9560. * The list of defines used in the shader
  9561. */
  9562. defines?: string[];
  9563. }
  9564. /**
  9565. * Interface to implement to create a shadow generator compatible with BJS.
  9566. */
  9567. export interface IShadowGenerator {
  9568. /**
  9569. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9570. * @returns The render target texture if present otherwise, null
  9571. */
  9572. getShadowMap(): Nullable<RenderTargetTexture>;
  9573. /**
  9574. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9575. * @returns The render target texture if the shadow map is present otherwise, null
  9576. */
  9577. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9578. /**
  9579. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9580. * @param subMesh The submesh we want to render in the shadow map
  9581. * @param useInstances Defines wether will draw in the map using instances
  9582. * @returns true if ready otherwise, false
  9583. */
  9584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9585. /**
  9586. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9587. * @param defines Defines of the material we want to update
  9588. * @param lightIndex Index of the light in the enabled light list of the material
  9589. */
  9590. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9591. /**
  9592. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9593. * defined in the generator but impacting the effect).
  9594. * It implies the unifroms available on the materials are the standard BJS ones.
  9595. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9596. * @param effect The effect we are binfing the information for
  9597. */
  9598. bindShadowLight(lightIndex: string, effect: Effect): void;
  9599. /**
  9600. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9601. * (eq to shadow prjection matrix * light transform matrix)
  9602. * @returns The transform matrix used to create the shadow map
  9603. */
  9604. getTransformMatrix(): Matrix;
  9605. /**
  9606. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9607. * Cube and 2D textures for instance.
  9608. */
  9609. recreateShadowMap(): void;
  9610. /**
  9611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9612. * @param onCompiled Callback triggered at the and of the effects compilation
  9613. * @param options Sets of optional options forcing the compilation with different modes
  9614. */
  9615. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9616. useInstances: boolean;
  9617. }>): void;
  9618. /**
  9619. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9620. * @param options Sets of optional options forcing the compilation with different modes
  9621. * @returns A promise that resolves when the compilation completes
  9622. */
  9623. forceCompilationAsync(options?: Partial<{
  9624. useInstances: boolean;
  9625. }>): Promise<void>;
  9626. /**
  9627. * Serializes the shadow generator setup to a json object.
  9628. * @returns The serialized JSON object
  9629. */
  9630. serialize(): any;
  9631. /**
  9632. * Disposes the Shadow map and related Textures and effects.
  9633. */
  9634. dispose(): void;
  9635. }
  9636. /**
  9637. * Default implementation IShadowGenerator.
  9638. * This is the main object responsible of generating shadows in the framework.
  9639. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9640. */
  9641. export class ShadowGenerator implements IShadowGenerator {
  9642. /**
  9643. * Shadow generator mode None: no filtering applied.
  9644. */
  9645. static readonly FILTER_NONE: number;
  9646. /**
  9647. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9648. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9649. */
  9650. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9651. /**
  9652. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9653. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9654. */
  9655. static readonly FILTER_POISSONSAMPLING: number;
  9656. /**
  9657. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9658. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9659. */
  9660. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9661. /**
  9662. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9663. * edge artifacts on steep falloff.
  9664. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9665. */
  9666. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9667. /**
  9668. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9669. * edge artifacts on steep falloff.
  9670. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9671. */
  9672. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9673. /**
  9674. * Shadow generator mode PCF: Percentage Closer Filtering
  9675. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9676. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9677. */
  9678. static readonly FILTER_PCF: number;
  9679. /**
  9680. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9681. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9682. * Contact Hardening
  9683. */
  9684. static readonly FILTER_PCSS: number;
  9685. /**
  9686. * Reserved for PCF and PCSS
  9687. * Highest Quality.
  9688. *
  9689. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9690. *
  9691. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9692. */
  9693. static readonly QUALITY_HIGH: number;
  9694. /**
  9695. * Reserved for PCF and PCSS
  9696. * Good tradeoff for quality/perf cross devices
  9697. *
  9698. * Execute PCF on a 3*3 kernel.
  9699. *
  9700. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9701. */
  9702. static readonly QUALITY_MEDIUM: number;
  9703. /**
  9704. * Reserved for PCF and PCSS
  9705. * The lowest quality but the fastest.
  9706. *
  9707. * Execute PCF on a 1*1 kernel.
  9708. *
  9709. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9710. */
  9711. static readonly QUALITY_LOW: number;
  9712. /** Gets or sets the custom shader name to use */
  9713. customShaderOptions: ICustomShaderOptions;
  9714. /**
  9715. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9716. */
  9717. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9718. /**
  9719. * Observable triggered before a mesh is rendered in the shadow map.
  9720. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9721. */
  9722. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9723. private _bias;
  9724. /**
  9725. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9726. */
  9727. /**
  9728. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9729. */
  9730. bias: number;
  9731. private _normalBias;
  9732. /**
  9733. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9734. */
  9735. /**
  9736. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9737. */
  9738. normalBias: number;
  9739. private _blurBoxOffset;
  9740. /**
  9741. * Gets the blur box offset: offset applied during the blur pass.
  9742. * Only useful if useKernelBlur = false
  9743. */
  9744. /**
  9745. * Sets the blur box offset: offset applied during the blur pass.
  9746. * Only useful if useKernelBlur = false
  9747. */
  9748. blurBoxOffset: number;
  9749. private _blurScale;
  9750. /**
  9751. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9752. * 2 means half of the size.
  9753. */
  9754. /**
  9755. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9756. * 2 means half of the size.
  9757. */
  9758. blurScale: number;
  9759. private _blurKernel;
  9760. /**
  9761. * Gets the blur kernel: kernel size of the blur pass.
  9762. * Only useful if useKernelBlur = true
  9763. */
  9764. /**
  9765. * Sets the blur kernel: kernel size of the blur pass.
  9766. * Only useful if useKernelBlur = true
  9767. */
  9768. blurKernel: number;
  9769. private _useKernelBlur;
  9770. /**
  9771. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9772. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9773. */
  9774. /**
  9775. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9776. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9777. */
  9778. useKernelBlur: boolean;
  9779. private _depthScale;
  9780. /**
  9781. * Gets the depth scale used in ESM mode.
  9782. */
  9783. /**
  9784. * Sets the depth scale used in ESM mode.
  9785. * This can override the scale stored on the light.
  9786. */
  9787. depthScale: number;
  9788. private _filter;
  9789. /**
  9790. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9791. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9792. */
  9793. /**
  9794. * Sets 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. filter: number;
  9798. /**
  9799. * Gets if the current filter is set to Poisson Sampling.
  9800. */
  9801. /**
  9802. * Sets the current filter to Poisson Sampling.
  9803. */
  9804. usePoissonSampling: boolean;
  9805. /**
  9806. * Gets if the current filter is set to ESM.
  9807. */
  9808. /**
  9809. * Sets the current filter is to ESM.
  9810. */
  9811. useExponentialShadowMap: boolean;
  9812. /**
  9813. * Gets if the current filter is set to filtered ESM.
  9814. */
  9815. /**
  9816. * Gets if the current filter is set to filtered ESM.
  9817. */
  9818. useBlurExponentialShadowMap: boolean;
  9819. /**
  9820. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9821. * exponential to prevent steep falloff artifacts).
  9822. */
  9823. /**
  9824. * Sets the current filter to "close ESM" (using the inverse of the
  9825. * exponential to prevent steep falloff artifacts).
  9826. */
  9827. useCloseExponentialShadowMap: boolean;
  9828. /**
  9829. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9830. * exponential to prevent steep falloff artifacts).
  9831. */
  9832. /**
  9833. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. useBlurCloseExponentialShadowMap: boolean;
  9837. /**
  9838. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9839. */
  9840. /**
  9841. * Sets the current filter to "PCF" (percentage closer filtering).
  9842. */
  9843. usePercentageCloserFiltering: boolean;
  9844. private _filteringQuality;
  9845. /**
  9846. * Gets the PCF or PCSS Quality.
  9847. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9848. */
  9849. /**
  9850. * Sets the PCF or PCSS Quality.
  9851. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9852. */
  9853. filteringQuality: number;
  9854. /**
  9855. * Gets if the current filter is set to "PCSS" (contact hardening).
  9856. */
  9857. /**
  9858. * Sets the current filter to "PCSS" (contact hardening).
  9859. */
  9860. useContactHardeningShadow: boolean;
  9861. private _contactHardeningLightSizeUVRatio;
  9862. /**
  9863. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9864. * Using a ratio helps keeping shape stability independently of the map size.
  9865. *
  9866. * It does not account for the light projection as it was having too much
  9867. * instability during the light setup or during light position changes.
  9868. *
  9869. * Only valid if useContactHardeningShadow is true.
  9870. */
  9871. /**
  9872. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9873. * Using a ratio helps keeping shape stability independently of the map size.
  9874. *
  9875. * It does not account for the light projection as it was having too much
  9876. * instability during the light setup or during light position changes.
  9877. *
  9878. * Only valid if useContactHardeningShadow is true.
  9879. */
  9880. contactHardeningLightSizeUVRatio: number;
  9881. private _darkness;
  9882. /**
  9883. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9884. * 0 means strongest and 1 would means no shadow.
  9885. * @returns the darkness.
  9886. */
  9887. getDarkness(): number;
  9888. /**
  9889. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9890. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9891. * @returns the shadow generator allowing fluent coding.
  9892. */
  9893. setDarkness(darkness: number): ShadowGenerator;
  9894. private _transparencyShadow;
  9895. /**
  9896. * Sets the ability to have transparent shadow (boolean).
  9897. * @param transparent True if transparent else False
  9898. * @returns the shadow generator allowing fluent coding
  9899. */
  9900. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9901. private _shadowMap;
  9902. private _shadowMap2;
  9903. /**
  9904. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9905. * @returns The render target texture if present otherwise, null
  9906. */
  9907. getShadowMap(): Nullable<RenderTargetTexture>;
  9908. /**
  9909. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9910. * @returns The render target texture if the shadow map is present otherwise, null
  9911. */
  9912. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9913. /**
  9914. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9915. * @param mesh Mesh to add
  9916. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9917. * @returns the Shadow Generator itself
  9918. */
  9919. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9920. /**
  9921. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9922. * @param mesh Mesh to remove
  9923. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9924. * @returns the Shadow Generator itself
  9925. */
  9926. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9927. /**
  9928. * Controls the extent to which the shadows fade out at the edge of the frustum
  9929. * Used only by directionals and spots
  9930. */
  9931. frustumEdgeFalloff: number;
  9932. private _light;
  9933. /**
  9934. * Returns the associated light object.
  9935. * @returns the light generating the shadow
  9936. */
  9937. getLight(): IShadowLight;
  9938. /**
  9939. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9940. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9941. * It might on the other hand introduce peter panning.
  9942. */
  9943. forceBackFacesOnly: boolean;
  9944. private _scene;
  9945. private _lightDirection;
  9946. private _effect;
  9947. private _viewMatrix;
  9948. private _projectionMatrix;
  9949. private _transformMatrix;
  9950. private _cachedPosition;
  9951. private _cachedDirection;
  9952. private _cachedDefines;
  9953. private _currentRenderID;
  9954. private _boxBlurPostprocess;
  9955. private _kernelBlurXPostprocess;
  9956. private _kernelBlurYPostprocess;
  9957. private _blurPostProcesses;
  9958. private _mapSize;
  9959. private _currentFaceIndex;
  9960. private _currentFaceIndexCache;
  9961. private _textureType;
  9962. private _defaultTextureMatrix;
  9963. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9964. /**
  9965. * Creates a ShadowGenerator object.
  9966. * A ShadowGenerator is the required tool to use the shadows.
  9967. * Each light casting shadows needs to use its own ShadowGenerator.
  9968. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9969. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9970. * @param light The light object generating the shadows.
  9971. * @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.
  9972. */
  9973. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9974. private _initializeGenerator;
  9975. private _initializeShadowMap;
  9976. private _initializeBlurRTTAndPostProcesses;
  9977. private _renderForShadowMap;
  9978. private _renderSubMeshForShadowMap;
  9979. private _applyFilterValues;
  9980. /**
  9981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9982. * @param onCompiled Callback triggered at the and of the effects compilation
  9983. * @param options Sets of optional options forcing the compilation with different modes
  9984. */
  9985. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9986. useInstances: boolean;
  9987. }>): void;
  9988. /**
  9989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9990. * @param options Sets of optional options forcing the compilation with different modes
  9991. * @returns A promise that resolves when the compilation completes
  9992. */
  9993. forceCompilationAsync(options?: Partial<{
  9994. useInstances: boolean;
  9995. }>): Promise<void>;
  9996. /**
  9997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9998. * @param subMesh The submesh we want to render in the shadow map
  9999. * @param useInstances Defines wether will draw in the map using instances
  10000. * @returns true if ready otherwise, false
  10001. */
  10002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10003. /**
  10004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10005. * @param defines Defines of the material we want to update
  10006. * @param lightIndex Index of the light in the enabled light list of the material
  10007. */
  10008. prepareDefines(defines: any, lightIndex: number): void;
  10009. /**
  10010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10011. * defined in the generator but impacting the effect).
  10012. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10013. * @param effect The effect we are binfing the information for
  10014. */
  10015. bindShadowLight(lightIndex: string, effect: Effect): void;
  10016. /**
  10017. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10018. * (eq to shadow prjection matrix * light transform matrix)
  10019. * @returns The transform matrix used to create the shadow map
  10020. */
  10021. getTransformMatrix(): Matrix;
  10022. /**
  10023. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10024. * Cube and 2D textures for instance.
  10025. */
  10026. recreateShadowMap(): void;
  10027. private _disposeBlurPostProcesses;
  10028. private _disposeRTTandPostProcesses;
  10029. /**
  10030. * Disposes the ShadowGenerator.
  10031. * Returns nothing.
  10032. */
  10033. dispose(): void;
  10034. /**
  10035. * Serializes the shadow generator setup to a json object.
  10036. * @returns The serialized JSON object
  10037. */
  10038. serialize(): any;
  10039. /**
  10040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10041. * @param parsedShadowGenerator The JSON object to parse
  10042. * @param scene The scene to create the shadow map for
  10043. * @returns The parsed shadow generator
  10044. */
  10045. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10046. }
  10047. }
  10048. declare module BABYLON {
  10049. /**
  10050. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10051. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10052. * 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.
  10053. */
  10054. export abstract class Light extends Node {
  10055. /**
  10056. * Falloff Default: light is falling off following the material specification:
  10057. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10058. */
  10059. static readonly FALLOFF_DEFAULT: number;
  10060. /**
  10061. * Falloff Physical: light is falling off following the inverse squared distance law.
  10062. */
  10063. static readonly FALLOFF_PHYSICAL: number;
  10064. /**
  10065. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10066. * to enhance interoperability with other engines.
  10067. */
  10068. static readonly FALLOFF_GLTF: number;
  10069. /**
  10070. * Falloff Standard: light is falling off like in the standard material
  10071. * to enhance interoperability with other materials.
  10072. */
  10073. static readonly FALLOFF_STANDARD: number;
  10074. /**
  10075. * If every light affecting the material is in this lightmapMode,
  10076. * material.lightmapTexture adds or multiplies
  10077. * (depends on material.useLightmapAsShadowmap)
  10078. * after every other light calculations.
  10079. */
  10080. static readonly LIGHTMAP_DEFAULT: number;
  10081. /**
  10082. * material.lightmapTexture as only diffuse lighting from this light
  10083. * adds only specular lighting from this light
  10084. * adds dynamic shadows
  10085. */
  10086. static readonly LIGHTMAP_SPECULAR: number;
  10087. /**
  10088. * material.lightmapTexture as only lighting
  10089. * no light calculation from this light
  10090. * only adds dynamic shadows from this light
  10091. */
  10092. static readonly LIGHTMAP_SHADOWSONLY: number;
  10093. /**
  10094. * Each light type uses the default quantity according to its type:
  10095. * point/spot lights use luminous intensity
  10096. * directional lights use illuminance
  10097. */
  10098. static readonly INTENSITYMODE_AUTOMATIC: number;
  10099. /**
  10100. * lumen (lm)
  10101. */
  10102. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10103. /**
  10104. * candela (lm/sr)
  10105. */
  10106. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10107. /**
  10108. * lux (lm/m^2)
  10109. */
  10110. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10111. /**
  10112. * nit (cd/m^2)
  10113. */
  10114. static readonly INTENSITYMODE_LUMINANCE: number;
  10115. /**
  10116. * Light type const id of the point light.
  10117. */
  10118. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10119. /**
  10120. * Light type const id of the directional light.
  10121. */
  10122. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10123. /**
  10124. * Light type const id of the spot light.
  10125. */
  10126. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10127. /**
  10128. * Light type const id of the hemispheric light.
  10129. */
  10130. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10131. /**
  10132. * Diffuse gives the basic color to an object.
  10133. */
  10134. diffuse: Color3;
  10135. /**
  10136. * Specular produces a highlight color on an object.
  10137. * Note: This is note affecting PBR materials.
  10138. */
  10139. specular: Color3;
  10140. /**
  10141. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10142. * falling off base on range or angle.
  10143. * This can be set to any values in Light.FALLOFF_x.
  10144. *
  10145. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10146. * other types of materials.
  10147. */
  10148. falloffType: number;
  10149. /**
  10150. * Strength of the light.
  10151. * Note: By default it is define in the framework own unit.
  10152. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10153. */
  10154. intensity: number;
  10155. private _range;
  10156. protected _inverseSquaredRange: number;
  10157. /**
  10158. * Defines how far from the source the light is impacting in scene units.
  10159. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10160. */
  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. range: number;
  10166. /**
  10167. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10168. * of light.
  10169. */
  10170. private _photometricScale;
  10171. private _intensityMode;
  10172. /**
  10173. * Gets the photometric scale used to interpret the intensity.
  10174. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10175. */
  10176. /**
  10177. * Sets 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. intensityMode: number;
  10181. private _radius;
  10182. /**
  10183. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10184. */
  10185. /**
  10186. * sets the light radius used by PBR Materials to simulate soft area lights.
  10187. */
  10188. radius: number;
  10189. private _renderPriority;
  10190. /**
  10191. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10192. * exceeding the number allowed of the materials.
  10193. */
  10194. renderPriority: number;
  10195. private _shadowEnabled;
  10196. /**
  10197. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10198. * the current shadow generator.
  10199. */
  10200. /**
  10201. * Sets 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. shadowEnabled: boolean;
  10205. private _includedOnlyMeshes;
  10206. /**
  10207. * Gets the only meshes impacted by this light.
  10208. */
  10209. /**
  10210. * Sets the only meshes impacted by this light.
  10211. */
  10212. includedOnlyMeshes: AbstractMesh[];
  10213. private _excludedMeshes;
  10214. /**
  10215. * Gets the meshes not impacted by this light.
  10216. */
  10217. /**
  10218. * Sets the meshes not impacted by this light.
  10219. */
  10220. excludedMeshes: AbstractMesh[];
  10221. private _excludeWithLayerMask;
  10222. /**
  10223. * Gets the layer id use to find what meshes are not impacted by the light.
  10224. * Inactive if 0
  10225. */
  10226. /**
  10227. * Sets the layer id use to find what meshes are not impacted by the light.
  10228. * Inactive if 0
  10229. */
  10230. excludeWithLayerMask: number;
  10231. private _includeOnlyWithLayerMask;
  10232. /**
  10233. * Gets the layer id use to find what meshes are impacted by the light.
  10234. * Inactive if 0
  10235. */
  10236. /**
  10237. * Sets the layer id use to find what meshes are impacted by the light.
  10238. * Inactive if 0
  10239. */
  10240. includeOnlyWithLayerMask: number;
  10241. private _lightmapMode;
  10242. /**
  10243. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10244. */
  10245. /**
  10246. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10247. */
  10248. lightmapMode: number;
  10249. /**
  10250. * Shadow generator associted to the light.
  10251. * @hidden Internal use only.
  10252. */ shadowGenerator: Nullable<IShadowGenerator>;
  10253. /**
  10254. * @hidden Internal use only.
  10255. */ excludedMeshesIds: string[];
  10256. /**
  10257. * @hidden Internal use only.
  10258. */ includedOnlyMeshesIds: string[];
  10259. /**
  10260. * The current light unifom buffer.
  10261. * @hidden Internal use only.
  10262. */ uniformBuffer: UniformBuffer;
  10263. /**
  10264. * Creates a Light object in the scene.
  10265. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10266. * @param name The firendly name of the light
  10267. * @param scene The scene the light belongs too
  10268. */
  10269. constructor(name: string, scene: Scene);
  10270. protected abstract _buildUniformLayout(): void;
  10271. /**
  10272. * Sets the passed Effect "effect" with the Light information.
  10273. * @param effect The effect to update
  10274. * @param lightIndex The index of the light in the effect to update
  10275. * @returns The light
  10276. */
  10277. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10278. /**
  10279. * Returns the string "Light".
  10280. * @returns the class name
  10281. */
  10282. getClassName(): string;
  10283. /** @hidden */ protected readonly _isLight: boolean;
  10284. /**
  10285. * Converts the light information to a readable string for debug purpose.
  10286. * @param fullDetails Supports for multiple levels of logging within scene loading
  10287. * @returns the human readable light info
  10288. */
  10289. toString(fullDetails?: boolean): string;
  10290. /** @hidden */
  10291. protected _syncParentEnabledState(): void;
  10292. /**
  10293. * Set the enabled state of this node.
  10294. * @param value - the new enabled state
  10295. */
  10296. setEnabled(value: boolean): void;
  10297. /**
  10298. * Returns the Light associated shadow generator if any.
  10299. * @return the associated shadow generator.
  10300. */
  10301. getShadowGenerator(): Nullable<IShadowGenerator>;
  10302. /**
  10303. * Returns a Vector3, the absolute light position in the World.
  10304. * @returns the world space position of the light
  10305. */
  10306. getAbsolutePosition(): Vector3;
  10307. /**
  10308. * Specifies if the light will affect the passed mesh.
  10309. * @param mesh The mesh to test against the light
  10310. * @return true the mesh is affected otherwise, false.
  10311. */
  10312. canAffectMesh(mesh: AbstractMesh): boolean;
  10313. /**
  10314. * Sort function to order lights for rendering.
  10315. * @param a First Light object to compare to second.
  10316. * @param b Second Light object to compare first.
  10317. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10318. */
  10319. static CompareLightsPriority(a: Light, b: Light): number;
  10320. /**
  10321. * Releases resources associated with this node.
  10322. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10323. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10324. */
  10325. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10326. /**
  10327. * Returns the light type ID (integer).
  10328. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10329. */
  10330. getTypeID(): number;
  10331. /**
  10332. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10333. * @returns the scaled intensity in intensity mode unit
  10334. */
  10335. getScaledIntensity(): number;
  10336. /**
  10337. * Returns a new Light object, named "name", from the current one.
  10338. * @param name The name of the cloned light
  10339. * @returns the new created light
  10340. */
  10341. clone(name: string): Nullable<Light>;
  10342. /**
  10343. * Serializes the current light into a Serialization object.
  10344. * @returns the serialized object.
  10345. */
  10346. serialize(): any;
  10347. /**
  10348. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10349. * This new light is named "name" and added to the passed scene.
  10350. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10351. * @param name The friendly name of the light
  10352. * @param scene The scene the new light will belong to
  10353. * @returns the constructor function
  10354. */
  10355. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10356. /**
  10357. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10358. * @param parsedLight The JSON representation of the light
  10359. * @param scene The scene to create the parsed light in
  10360. * @returns the created light after parsing
  10361. */
  10362. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10363. private _hookArrayForExcluded;
  10364. private _hookArrayForIncludedOnly;
  10365. private _resyncMeshes;
  10366. /**
  10367. * Forces the meshes to update their light related information in their rendering used effects
  10368. * @hidden Internal Use Only
  10369. */ markMeshesAsLightDirty(): void;
  10370. /**
  10371. * Recomputes the cached photometric scale if needed.
  10372. */
  10373. private _computePhotometricScale;
  10374. /**
  10375. * Returns the Photometric Scale according to the light type and intensity mode.
  10376. */
  10377. private _getPhotometricScale;
  10378. /**
  10379. * Reorder the light in the scene according to their defined priority.
  10380. * @hidden Internal Use Only
  10381. */ reorderLightsInScene(): void;
  10382. /**
  10383. * Prepares the list of defines specific to the light type.
  10384. * @param defines the list of defines
  10385. * @param lightIndex defines the index of the light for the effect
  10386. */
  10387. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10388. }
  10389. }
  10390. declare module BABYLON {
  10391. /**
  10392. * Interface used to define Action
  10393. */
  10394. export interface IAction {
  10395. /**
  10396. * Trigger for the action
  10397. */
  10398. trigger: number;
  10399. /** Options of the trigger */
  10400. triggerOptions: any;
  10401. /**
  10402. * Gets the trigger parameters
  10403. * @returns the trigger parameters
  10404. */
  10405. getTriggerParameter(): any;
  10406. /**
  10407. * Internal only - executes current action event
  10408. * @hidden
  10409. */ executeCurrent(evt?: ActionEvent): void;
  10410. /**
  10411. * Serialize placeholder for child classes
  10412. * @param parent of child
  10413. * @returns the serialized object
  10414. */
  10415. serialize(parent: any): any;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */ prepare(): void;
  10420. /**
  10421. * Internal only - manager for action
  10422. * @hidden
  10423. */ actionManager: AbstractActionManager;
  10424. }
  10425. /**
  10426. * The action to be carried out following a trigger
  10427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10428. */
  10429. export class Action implements IAction {
  10430. /** the trigger, with or without parameters, for the action */
  10431. triggerOptions: any;
  10432. /**
  10433. * Trigger for the action
  10434. */
  10435. trigger: number;
  10436. /**
  10437. * Internal only - manager for action
  10438. * @hidden
  10439. */ actionManager: ActionManager;
  10440. private _nextActiveAction;
  10441. private _child;
  10442. private _condition?;
  10443. private _triggerParameter;
  10444. /**
  10445. * An event triggered prior to action being executed.
  10446. */
  10447. onBeforeExecuteObservable: Observable<Action>;
  10448. /**
  10449. * Creates a new Action
  10450. * @param triggerOptions the trigger, with or without parameters, for the action
  10451. * @param condition an optional determinant of action
  10452. */
  10453. constructor(
  10454. /** the trigger, with or without parameters, for the action */
  10455. triggerOptions: any, condition?: Condition);
  10456. /**
  10457. * Internal only
  10458. * @hidden
  10459. */ prepare(): void;
  10460. /**
  10461. * Gets the trigger parameters
  10462. * @returns the trigger parameters
  10463. */
  10464. getTriggerParameter(): any;
  10465. /**
  10466. * Internal only - executes current action event
  10467. * @hidden
  10468. */ executeCurrent(evt?: ActionEvent): void;
  10469. /**
  10470. * Execute placeholder for child classes
  10471. * @param evt optional action event
  10472. */
  10473. execute(evt?: ActionEvent): void;
  10474. /**
  10475. * Skips to next active action
  10476. */
  10477. skipToNextActiveAction(): void;
  10478. /**
  10479. * Adds action to chain of actions, may be a DoNothingAction
  10480. * @param action defines the next action to execute
  10481. * @returns The action passed in
  10482. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10483. */
  10484. then(action: Action): Action;
  10485. /**
  10486. * Internal only
  10487. * @hidden
  10488. */ getProperty(propertyPath: string): string;
  10489. /**
  10490. * Internal only
  10491. * @hidden
  10492. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10493. /**
  10494. * Serialize placeholder for child classes
  10495. * @param parent of child
  10496. * @returns the serialized object
  10497. */
  10498. serialize(parent: any): any;
  10499. /**
  10500. * Internal only called by serialize
  10501. * @hidden
  10502. */
  10503. protected _serialize(serializedAction: any, parent?: any): any;
  10504. /**
  10505. * Internal only
  10506. * @hidden
  10507. */ private static _SerializeValueAsString: (value: any) => string;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10512. name: string;
  10513. targetType: string;
  10514. value: string;
  10515. };
  10516. }
  10517. }
  10518. declare module BABYLON {
  10519. /**
  10520. * A Condition applied to an Action
  10521. */
  10522. export class Condition {
  10523. /**
  10524. * Internal only - manager for action
  10525. * @hidden
  10526. */ actionManager: ActionManager;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */ evaluationId: number;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */ currentResult: boolean;
  10535. /**
  10536. * Creates a new Condition
  10537. * @param actionManager the manager of the action the condition is applied to
  10538. */
  10539. constructor(actionManager: ActionManager);
  10540. /**
  10541. * Check if the current condition is valid
  10542. * @returns a boolean
  10543. */
  10544. isValid(): boolean;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */ getProperty(propertyPath: string): string;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10553. /**
  10554. * Serialize placeholder for child classes
  10555. * @returns the serialized object
  10556. */
  10557. serialize(): any;
  10558. /**
  10559. * Internal only
  10560. * @hidden
  10561. */
  10562. protected _serialize(serializedCondition: any): any;
  10563. }
  10564. /**
  10565. * Defines specific conditional operators as extensions of Condition
  10566. */
  10567. export class ValueCondition extends Condition {
  10568. /** path to specify the property of the target the conditional operator uses */
  10569. propertyPath: string;
  10570. /** the value compared by the conditional operator against the current value of the property */
  10571. value: any;
  10572. /** the conditional operator, default ValueCondition.IsEqual */
  10573. operator: number;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsEqual;
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. private static _IsDifferent;
  10584. /**
  10585. * Internal only
  10586. * @hidden
  10587. */
  10588. private static _IsGreater;
  10589. /**
  10590. * Internal only
  10591. * @hidden
  10592. */
  10593. private static _IsLesser;
  10594. /**
  10595. * returns the number for IsEqual
  10596. */
  10597. static readonly IsEqual: number;
  10598. /**
  10599. * Returns the number for IsDifferent
  10600. */
  10601. static readonly IsDifferent: number;
  10602. /**
  10603. * Returns the number for IsGreater
  10604. */
  10605. static readonly IsGreater: number;
  10606. /**
  10607. * Returns the number for IsLesser
  10608. */
  10609. static readonly IsLesser: number;
  10610. /**
  10611. * Internal only The action manager for the condition
  10612. * @hidden
  10613. */ actionManager: ActionManager;
  10614. /**
  10615. * Internal only
  10616. * @hidden
  10617. */
  10618. private _target;
  10619. /**
  10620. * Internal only
  10621. * @hidden
  10622. */
  10623. private _effectiveTarget;
  10624. /**
  10625. * Internal only
  10626. * @hidden
  10627. */
  10628. private _property;
  10629. /**
  10630. * Creates a new ValueCondition
  10631. * @param actionManager manager for the action the condition applies to
  10632. * @param target for the action
  10633. * @param propertyPath path to specify the property of the target the conditional operator uses
  10634. * @param value the value compared by the conditional operator against the current value of the property
  10635. * @param operator the conditional operator, default ValueCondition.IsEqual
  10636. */
  10637. constructor(actionManager: ActionManager, target: any,
  10638. /** path to specify the property of the target the conditional operator uses */
  10639. propertyPath: string,
  10640. /** the value compared by the conditional operator against the current value of the property */
  10641. value: any,
  10642. /** the conditional operator, default ValueCondition.IsEqual */
  10643. operator?: number);
  10644. /**
  10645. * Compares the given value with the property value for the specified conditional operator
  10646. * @returns the result of the comparison
  10647. */
  10648. isValid(): boolean;
  10649. /**
  10650. * Serialize the ValueCondition into a JSON compatible object
  10651. * @returns serialization object
  10652. */
  10653. serialize(): any;
  10654. /**
  10655. * Gets the name of the conditional operator for the ValueCondition
  10656. * @param operator the conditional operator
  10657. * @returns the name
  10658. */
  10659. static GetOperatorName(operator: number): string;
  10660. }
  10661. /**
  10662. * Defines a predicate condition as an extension of Condition
  10663. */
  10664. export class PredicateCondition extends Condition {
  10665. /** defines the predicate function used to validate the condition */
  10666. predicate: () => boolean;
  10667. /**
  10668. * Internal only - manager for action
  10669. * @hidden
  10670. */ actionManager: ActionManager;
  10671. /**
  10672. * Creates a new PredicateCondition
  10673. * @param actionManager manager for the action the condition applies to
  10674. * @param predicate defines the predicate function used to validate the condition
  10675. */
  10676. constructor(actionManager: ActionManager,
  10677. /** defines the predicate function used to validate the condition */
  10678. predicate: () => boolean);
  10679. /**
  10680. * @returns the validity of the predicate condition
  10681. */
  10682. isValid(): boolean;
  10683. }
  10684. /**
  10685. * Defines a state condition as an extension of Condition
  10686. */
  10687. export class StateCondition extends Condition {
  10688. /** Value to compare with target state */
  10689. value: string;
  10690. /**
  10691. * Internal only - manager for action
  10692. * @hidden
  10693. */ actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private _target;
  10699. /**
  10700. * Creates a new StateCondition
  10701. * @param actionManager manager for the action the condition applies to
  10702. * @param target of the condition
  10703. * @param value to compare with target state
  10704. */
  10705. constructor(actionManager: ActionManager, target: any,
  10706. /** Value to compare with target state */
  10707. value: string);
  10708. /**
  10709. * Gets a boolean indicating if the current condition is met
  10710. * @returns the validity of the state
  10711. */
  10712. isValid(): boolean;
  10713. /**
  10714. * Serialize the StateCondition into a JSON compatible object
  10715. * @returns serialization object
  10716. */
  10717. serialize(): any;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /**
  10722. * This defines an action responsible to toggle a boolean once triggered.
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10724. */
  10725. export class SwitchBooleanAction extends Action {
  10726. /**
  10727. * The path to the boolean property in the target object
  10728. */
  10729. propertyPath: string;
  10730. private _target;
  10731. private _effectiveTarget;
  10732. private _property;
  10733. /**
  10734. * Instantiate the action
  10735. * @param triggerOptions defines the trigger options
  10736. * @param target defines the object containing the boolean
  10737. * @param propertyPath defines the path to the boolean property in the target object
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10741. /** @hidden */ prepare(): void;
  10742. /**
  10743. * Execute the action toggle the boolean value.
  10744. */
  10745. execute(): void;
  10746. /**
  10747. * Serializes the actions and its related information.
  10748. * @param parent defines the object to serialize in
  10749. * @returns the serialized object
  10750. */
  10751. serialize(parent: any): any;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set a the state field of the target
  10755. * to a desired value once triggered.
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10757. */
  10758. export class SetStateAction extends Action {
  10759. /**
  10760. * The value to store in the state field.
  10761. */
  10762. value: string;
  10763. private _target;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param target defines the object containing the state property
  10768. * @param value defines the value to store in the state field
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10772. /**
  10773. * Execute the action and store the value on the target state property.
  10774. */
  10775. execute(): void;
  10776. /**
  10777. * Serializes the actions and its related information.
  10778. * @param parent defines the object to serialize in
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. }
  10783. /**
  10784. * This defines an action responsible to set a property of the target
  10785. * to a desired value once triggered.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10787. */
  10788. export class SetValueAction extends Action {
  10789. /**
  10790. * The path of the property to set in the target.
  10791. */
  10792. propertyPath: string;
  10793. /**
  10794. * The value to set in the property
  10795. */
  10796. value: any;
  10797. private _target;
  10798. private _effectiveTarget;
  10799. private _property;
  10800. /**
  10801. * Instantiate the action
  10802. * @param triggerOptions defines the trigger options
  10803. * @param target defines the object containing the property
  10804. * @param propertyPath defines the path of the property to set in the target
  10805. * @param value defines the value to set in the property
  10806. * @param condition defines the trigger related conditions
  10807. */
  10808. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10809. /** @hidden */ prepare(): void;
  10810. /**
  10811. * Execute the action and set the targetted property to the desired value.
  10812. */
  10813. execute(): void;
  10814. /**
  10815. * Serializes the actions and its related information.
  10816. * @param parent defines the object to serialize in
  10817. * @returns the serialized object
  10818. */
  10819. serialize(parent: any): any;
  10820. }
  10821. /**
  10822. * This defines an action responsible to increment the target value
  10823. * to a desired value once triggered.
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10825. */
  10826. export class IncrementValueAction extends Action {
  10827. /**
  10828. * The path of the property to increment in the target.
  10829. */
  10830. propertyPath: string;
  10831. /**
  10832. * The value we should increment the property by.
  10833. */
  10834. value: any;
  10835. private _target;
  10836. private _effectiveTarget;
  10837. private _property;
  10838. /**
  10839. * Instantiate the action
  10840. * @param triggerOptions defines the trigger options
  10841. * @param target defines the object containing the property
  10842. * @param propertyPath defines the path of the property to increment in the target
  10843. * @param value defines the value value we should increment the property by
  10844. * @param condition defines the trigger related conditions
  10845. */
  10846. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10847. /** @hidden */ prepare(): void;
  10848. /**
  10849. * Execute the action and increment the target of the value amount.
  10850. */
  10851. execute(): void;
  10852. /**
  10853. * Serializes the actions and its related information.
  10854. * @param parent defines the object to serialize in
  10855. * @returns the serialized object
  10856. */
  10857. serialize(parent: any): any;
  10858. }
  10859. /**
  10860. * This defines an action responsible to start an animation once triggered.
  10861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10862. */
  10863. export class PlayAnimationAction extends Action {
  10864. /**
  10865. * Where the animation should start (animation frame)
  10866. */
  10867. from: number;
  10868. /**
  10869. * Where the animation should stop (animation frame)
  10870. */
  10871. to: number;
  10872. /**
  10873. * Define if the animation should loop or stop after the first play.
  10874. */
  10875. loop?: boolean;
  10876. private _target;
  10877. /**
  10878. * Instantiate the action
  10879. * @param triggerOptions defines the trigger options
  10880. * @param target defines the target animation or animation name
  10881. * @param from defines from where the animation should start (animation frame)
  10882. * @param end defines where the animation should stop (animation frame)
  10883. * @param loop defines if the animation should loop or stop after the first play
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10887. /** @hidden */ prepare(): void;
  10888. /**
  10889. * Execute the action and play the animation.
  10890. */
  10891. execute(): void;
  10892. /**
  10893. * Serializes the actions and its related information.
  10894. * @param parent defines the object to serialize in
  10895. * @returns the serialized object
  10896. */
  10897. serialize(parent: any): any;
  10898. }
  10899. /**
  10900. * This defines an action responsible to stop an animation once triggered.
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10902. */
  10903. export class StopAnimationAction extends Action {
  10904. private _target;
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param target defines the target animation or animation name
  10909. * @param condition defines the trigger related conditions
  10910. */
  10911. constructor(triggerOptions: any, target: any, condition?: Condition);
  10912. /** @hidden */ prepare(): void;
  10913. /**
  10914. * Execute the action and stop the animation.
  10915. */
  10916. execute(): void;
  10917. /**
  10918. * Serializes the actions and its related information.
  10919. * @param parent defines the object to serialize in
  10920. * @returns the serialized object
  10921. */
  10922. serialize(parent: any): any;
  10923. }
  10924. /**
  10925. * This defines an action responsible that does nothing once triggered.
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10927. */
  10928. export class DoNothingAction extends Action {
  10929. /**
  10930. * Instantiate the action
  10931. * @param triggerOptions defines the trigger options
  10932. * @param condition defines the trigger related conditions
  10933. */
  10934. constructor(triggerOptions?: any, condition?: Condition);
  10935. /**
  10936. * Execute the action and do nothing.
  10937. */
  10938. execute(): void;
  10939. /**
  10940. * Serializes the actions and its related information.
  10941. * @param parent defines the object to serialize in
  10942. * @returns the serialized object
  10943. */
  10944. serialize(parent: any): any;
  10945. }
  10946. /**
  10947. * This defines an action responsible to trigger several actions once triggered.
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10949. */
  10950. export class CombineAction extends Action {
  10951. /**
  10952. * The list of aggregated animations to run.
  10953. */
  10954. children: Action[];
  10955. /**
  10956. * Instantiate the action
  10957. * @param triggerOptions defines the trigger options
  10958. * @param children defines the list of aggregated animations to run
  10959. * @param condition defines the trigger related conditions
  10960. */
  10961. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10962. /** @hidden */ prepare(): void;
  10963. /**
  10964. * Execute the action and executes all the aggregated actions.
  10965. */
  10966. execute(evt: ActionEvent): void;
  10967. /**
  10968. * Serializes the actions and its related information.
  10969. * @param parent defines the object to serialize in
  10970. * @returns the serialized object
  10971. */
  10972. serialize(parent: any): any;
  10973. }
  10974. /**
  10975. * This defines an action responsible to run code (external event) once triggered.
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10977. */
  10978. export class ExecuteCodeAction extends Action {
  10979. /**
  10980. * The callback function to run.
  10981. */
  10982. func: (evt: ActionEvent) => void;
  10983. /**
  10984. * Instantiate the action
  10985. * @param triggerOptions defines the trigger options
  10986. * @param func defines the callback function to run
  10987. * @param condition defines the trigger related conditions
  10988. */
  10989. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10990. /**
  10991. * Execute the action and run the attached code.
  10992. */
  10993. execute(evt: ActionEvent): void;
  10994. }
  10995. /**
  10996. * This defines an action responsible to set the parent property of the target once triggered.
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10998. */
  10999. export class SetParentAction extends Action {
  11000. private _parent;
  11001. private _target;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param target defines the target containing the parent property
  11006. * @param parent defines from where the animation should start (animation frame)
  11007. * @param condition defines the trigger related conditions
  11008. */
  11009. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11010. /** @hidden */ prepare(): void;
  11011. /**
  11012. * Execute the action and set the parent property.
  11013. */
  11014. execute(): void;
  11015. /**
  11016. * Serializes the actions and its related information.
  11017. * @param parent defines the object to serialize in
  11018. * @returns the serialized object
  11019. */
  11020. serialize(parent: any): any;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /**
  11025. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11026. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class ActionManager extends AbstractActionManager {
  11030. /**
  11031. * Nothing
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly NothingTrigger: number;
  11035. /**
  11036. * On pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickTrigger: number;
  11040. /**
  11041. * On left pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLeftPickTrigger: number;
  11045. /**
  11046. * On right pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnRightPickTrigger: number;
  11050. /**
  11051. * On center pick
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnCenterPickTrigger: number;
  11055. /**
  11056. * On pick down
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickDownTrigger: number;
  11060. /**
  11061. * On double pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnDoublePickTrigger: number;
  11065. /**
  11066. * On pick up
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickUpTrigger: number;
  11070. /**
  11071. * On pick out.
  11072. * This trigger will only be raised if you also declared a OnPickDown
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickOutTrigger: number;
  11076. /**
  11077. * On long press
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnLongPressTrigger: number;
  11081. /**
  11082. * On pointer over
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOverTrigger: number;
  11086. /**
  11087. * On pointer out
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPointerOutTrigger: number;
  11091. /**
  11092. * On every frame
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnEveryFrameTrigger: number;
  11096. /**
  11097. * On intersection enter
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionEnterTrigger: number;
  11101. /**
  11102. * On intersection exit
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnIntersectionExitTrigger: number;
  11106. /**
  11107. * On key down
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyDownTrigger: number;
  11111. /**
  11112. * On key up
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnKeyUpTrigger: number;
  11116. private _scene;
  11117. /**
  11118. * Creates a new action manager
  11119. * @param scene defines the hosting scene
  11120. */
  11121. constructor(scene: Scene);
  11122. /**
  11123. * Releases all associated resources
  11124. */
  11125. dispose(): void;
  11126. /**
  11127. * Gets hosting scene
  11128. * @returns the hosting scene
  11129. */
  11130. getScene(): Scene;
  11131. /**
  11132. * Does this action manager handles actions of any of the given triggers
  11133. * @param triggers defines the triggers to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers(triggers: number[]): boolean;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11139. * speed.
  11140. * @param triggerA defines the trigger to be tested
  11141. * @param triggerB defines the trigger to be tested
  11142. * @return a boolean indicating whether one (or more) of the triggers is handled
  11143. */
  11144. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11145. /**
  11146. * Does this action manager handles actions of a given trigger
  11147. * @param trigger defines the trigger to be tested
  11148. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11149. * @return whether the trigger is handled
  11150. */
  11151. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11152. /**
  11153. * Does this action manager has pointer triggers
  11154. */
  11155. readonly hasPointerTriggers: boolean;
  11156. /**
  11157. * Does this action manager has pick triggers
  11158. */
  11159. readonly hasPickTriggers: boolean;
  11160. /**
  11161. * Registers an action to this action manager
  11162. * @param action defines the action to be registered
  11163. * @return the action amended (prepared) after registration
  11164. */
  11165. registerAction(action: IAction): Nullable<IAction>;
  11166. /**
  11167. * Unregisters an action to this action manager
  11168. * @param action defines the action to be unregistered
  11169. * @return a boolean indicating whether the action has been unregistered
  11170. */
  11171. unregisterAction(action: IAction): Boolean;
  11172. /**
  11173. * Process a specific trigger
  11174. * @param trigger defines the trigger to process
  11175. * @param evt defines the event details to be processed
  11176. */
  11177. processTrigger(trigger: number, evt?: IActionEvent): void;
  11178. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11179. /** @hidden */ getProperty(propertyPath: string): string;
  11180. /**
  11181. * Serialize this manager to a JSON object
  11182. * @param name defines the property name to store this manager
  11183. * @returns a JSON representation of this manager
  11184. */
  11185. serialize(name: string): any;
  11186. /**
  11187. * Creates a new ActionManager from a JSON data
  11188. * @param parsedActions defines the JSON data to read from
  11189. * @param object defines the hosting mesh
  11190. * @param scene defines the hosting scene
  11191. */
  11192. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11193. /**
  11194. * Get a trigger name by index
  11195. * @param trigger defines the trigger index
  11196. * @returns a trigger name
  11197. */
  11198. static GetTriggerName(trigger: number): string;
  11199. }
  11200. }
  11201. declare module BABYLON {
  11202. /**
  11203. * Class representing a ray with position and direction
  11204. */
  11205. export class Ray {
  11206. /** origin point */
  11207. origin: Vector3;
  11208. /** direction */
  11209. direction: Vector3;
  11210. /** length of the ray */
  11211. length: number;
  11212. private static readonly TmpVector3;
  11213. private _tmpRay;
  11214. /**
  11215. * Creates a new ray
  11216. * @param origin origin point
  11217. * @param direction direction
  11218. * @param length length of the ray
  11219. */
  11220. constructor(
  11221. /** origin point */
  11222. origin: Vector3,
  11223. /** direction */
  11224. direction: Vector3,
  11225. /** length of the ray */
  11226. length?: number);
  11227. /**
  11228. * Checks if the ray intersects a box
  11229. * @param minimum bound of the box
  11230. * @param maximum bound of the box
  11231. * @param intersectionTreshold extra extend to be added to the box in all direction
  11232. * @returns if the box was hit
  11233. */
  11234. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param box the bounding box to check
  11238. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11239. * @returns if the box was hit
  11240. */
  11241. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11242. /**
  11243. * If the ray hits a sphere
  11244. * @param sphere the bounding sphere to check
  11245. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11246. * @returns true if it hits the sphere
  11247. */
  11248. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * If the ray hits a triange
  11251. * @param vertex0 triangle vertex
  11252. * @param vertex1 triangle vertex
  11253. * @param vertex2 triangle vertex
  11254. * @returns intersection information if hit
  11255. */
  11256. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11257. /**
  11258. * Checks if ray intersects a plane
  11259. * @param plane the plane to check
  11260. * @returns the distance away it was hit
  11261. */
  11262. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11263. /**
  11264. * Checks if ray intersects a mesh
  11265. * @param mesh the mesh to check
  11266. * @param fastCheck if only the bounding box should checked
  11267. * @returns picking info of the intersecton
  11268. */
  11269. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11270. /**
  11271. * Checks if ray intersects a mesh
  11272. * @param meshes the meshes to check
  11273. * @param fastCheck if only the bounding box should checked
  11274. * @param results array to store result in
  11275. * @returns Array of picking infos
  11276. */
  11277. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11278. private _comparePickingInfo;
  11279. private static smallnum;
  11280. private static rayl;
  11281. /**
  11282. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11283. * @param sega the first point of the segment to test the intersection against
  11284. * @param segb the second point of the segment to test the intersection against
  11285. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11286. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11287. */
  11288. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11289. /**
  11290. * Update the ray from viewport position
  11291. * @param x position
  11292. * @param y y position
  11293. * @param viewportWidth viewport width
  11294. * @param viewportHeight viewport height
  11295. * @param world world matrix
  11296. * @param view view matrix
  11297. * @param projection projection matrix
  11298. * @returns this ray updated
  11299. */
  11300. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11301. /**
  11302. * Creates a ray with origin and direction of 0,0,0
  11303. * @returns the new ray
  11304. */
  11305. static Zero(): Ray;
  11306. /**
  11307. * Creates a new ray from screen space and viewport
  11308. * @param x position
  11309. * @param y y position
  11310. * @param viewportWidth viewport width
  11311. * @param viewportHeight viewport height
  11312. * @param world world matrix
  11313. * @param view view matrix
  11314. * @param projection projection matrix
  11315. * @returns new ray
  11316. */
  11317. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11318. /**
  11319. * 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
  11320. * transformed to the given world matrix.
  11321. * @param origin The origin point
  11322. * @param end The end point
  11323. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11324. * @returns the new ray
  11325. */
  11326. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11327. /**
  11328. * Transforms a ray by a matrix
  11329. * @param ray ray to transform
  11330. * @param matrix matrix to apply
  11331. * @returns the resulting new ray
  11332. */
  11333. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11334. /**
  11335. * Transforms a ray by a matrix
  11336. * @param ray ray to transform
  11337. * @param matrix matrix to apply
  11338. * @param result ray to store result in
  11339. */
  11340. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11341. /**
  11342. * Unproject a ray from screen space to object space
  11343. * @param sourceX defines the screen space x coordinate to use
  11344. * @param sourceY defines the screen space y coordinate to use
  11345. * @param viewportWidth defines the current width of the viewport
  11346. * @param viewportHeight defines the current height of the viewport
  11347. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11348. * @param view defines the view matrix to use
  11349. * @param projection defines the projection matrix to use
  11350. */
  11351. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11352. }
  11353. /**
  11354. * Type used to define predicate used to select faces when a mesh intersection is detected
  11355. */
  11356. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11357. interface Scene {
  11358. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11359. /** @hidden */ cachedRayForTransform: Ray;
  11360. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11361. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11362. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11363. }
  11364. }
  11365. declare module BABYLON {
  11366. /**
  11367. * Groups all the scene component constants in one place to ease maintenance.
  11368. * @hidden
  11369. */
  11370. export class SceneComponentConstants {
  11371. static readonly NAME_EFFECTLAYER: string;
  11372. static readonly NAME_LAYER: string;
  11373. static readonly NAME_LENSFLARESYSTEM: string;
  11374. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11375. static readonly NAME_PARTICLESYSTEM: string;
  11376. static readonly NAME_GAMEPAD: string;
  11377. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11378. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11379. static readonly NAME_DEPTHRENDERER: string;
  11380. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11381. static readonly NAME_SPRITE: string;
  11382. static readonly NAME_OUTLINERENDERER: string;
  11383. static readonly NAME_PROCEDURALTEXTURE: string;
  11384. static readonly NAME_SHADOWGENERATOR: string;
  11385. static readonly NAME_OCTREE: string;
  11386. static readonly NAME_PHYSICSENGINE: string;
  11387. static readonly NAME_AUDIO: string;
  11388. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11389. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11390. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11391. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11392. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11393. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11394. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11395. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11396. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11397. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11398. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11399. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11400. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11401. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11402. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11403. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11404. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11405. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11406. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11407. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11408. static readonly STEP_AFTERRENDER_AUDIO: number;
  11409. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11410. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11411. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11412. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11413. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11414. static readonly STEP_POINTERMOVE_SPRITE: number;
  11415. static readonly STEP_POINTERDOWN_SPRITE: number;
  11416. static readonly STEP_POINTERUP_SPRITE: number;
  11417. }
  11418. /**
  11419. * This represents a scene component.
  11420. *
  11421. * This is used to decouple the dependency the scene is having on the different workloads like
  11422. * layers, post processes...
  11423. */
  11424. export interface ISceneComponent {
  11425. /**
  11426. * The name of the component. Each component must have a unique name.
  11427. */
  11428. name: string;
  11429. /**
  11430. * The scene the component belongs to.
  11431. */
  11432. scene: Scene;
  11433. /**
  11434. * Register the component to one instance of a scene.
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. }
  11447. /**
  11448. * This represents a SERIALIZABLE scene component.
  11449. *
  11450. * This extends Scene Component to add Serialization methods on top.
  11451. */
  11452. export interface ISceneSerializableComponent extends ISceneComponent {
  11453. /**
  11454. * Adds all the element from the container to the scene
  11455. * @param container the container holding the elements
  11456. */
  11457. addFromContainer(container: AbstractScene): void;
  11458. /**
  11459. * Removes all the elements in the container from the scene
  11460. * @param container contains the elements to remove
  11461. * @param dispose if the removed element should be disposed (default: false)
  11462. */
  11463. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11464. /**
  11465. * Serializes the component data to the specified json object
  11466. * @param serializationObject The object to serialize to
  11467. */
  11468. serialize(serializationObject: any): void;
  11469. }
  11470. /**
  11471. * Strong typing of a Mesh related stage step action
  11472. */
  11473. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11474. /**
  11475. * Strong typing of a Evaluate Sub Mesh related stage step action
  11476. */
  11477. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11478. /**
  11479. * Strong typing of a Active Mesh related stage step action
  11480. */
  11481. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11482. /**
  11483. * Strong typing of a Camera related stage step action
  11484. */
  11485. export type CameraStageAction = (camera: Camera) => void;
  11486. /**
  11487. * Strong typing of a Camera Frame buffer related stage step action
  11488. */
  11489. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11490. /**
  11491. * Strong typing of a Render Target related stage step action
  11492. */
  11493. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11494. /**
  11495. * Strong typing of a RenderingGroup related stage step action
  11496. */
  11497. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11498. /**
  11499. * Strong typing of a Mesh Render related stage step action
  11500. */
  11501. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11502. /**
  11503. * Strong typing of a simple stage step action
  11504. */
  11505. export type SimpleStageAction = () => void;
  11506. /**
  11507. * Strong typing of a render target action.
  11508. */
  11509. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11510. /**
  11511. * Strong typing of a pointer move action.
  11512. */
  11513. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11514. /**
  11515. * Strong typing of a pointer up/down action.
  11516. */
  11517. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11518. /**
  11519. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11520. * @hidden
  11521. */
  11522. export class Stage<T extends Function> extends Array<{
  11523. index: number;
  11524. component: ISceneComponent;
  11525. action: T;
  11526. }> {
  11527. /**
  11528. * Hide ctor from the rest of the world.
  11529. * @param items The items to add.
  11530. */
  11531. private constructor();
  11532. /**
  11533. * Creates a new Stage.
  11534. * @returns A new instance of a Stage
  11535. */
  11536. static Create<T extends Function>(): Stage<T>;
  11537. /**
  11538. * Registers a step in an ordered way in the targeted stage.
  11539. * @param index Defines the position to register the step in
  11540. * @param component Defines the component attached to the step
  11541. * @param action Defines the action to launch during the step
  11542. */
  11543. registerStep(index: number, component: ISceneComponent, action: T): void;
  11544. /**
  11545. * Clears all the steps from the stage.
  11546. */
  11547. clear(): void;
  11548. }
  11549. }
  11550. declare module BABYLON {
  11551. interface Scene {
  11552. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11553. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11554. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11555. /**
  11556. * All of the sprite managers added to this scene
  11557. * @see http://doc.babylonjs.com/babylon101/sprites
  11558. */
  11559. spriteManagers: Array<ISpriteManager>;
  11560. /**
  11561. * An event triggered when sprites rendering is about to start
  11562. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11563. */
  11564. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11565. /**
  11566. * An event triggered when sprites rendering is done
  11567. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11568. */
  11569. onAfterSpritesRenderingObservable: Observable<Scene>;
  11570. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11571. /** Launch a ray to try to pick a sprite in the scene
  11572. * @param x position on screen
  11573. * @param y position on screen
  11574. * @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
  11575. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11576. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11577. * @returns a PickingInfo
  11578. */
  11579. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11580. /** Use the given ray to pick a sprite in the scene
  11581. * @param ray The ray (in world space) to use to pick meshes
  11582. * @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
  11583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11584. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11585. * @returns a PickingInfo
  11586. */
  11587. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11588. /**
  11589. * Force the sprite under the pointer
  11590. * @param sprite defines the sprite to use
  11591. */
  11592. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11593. /**
  11594. * Gets the sprite under the pointer
  11595. * @returns a Sprite or null if no sprite is under the pointer
  11596. */
  11597. getPointerOverSprite(): Nullable<Sprite>;
  11598. }
  11599. /**
  11600. * Defines the sprite scene component responsible to manage sprites
  11601. * in a given scene.
  11602. */
  11603. export class SpriteSceneComponent implements ISceneComponent {
  11604. /**
  11605. * The component name helpfull to identify the component in the list of scene components.
  11606. */
  11607. readonly name: string;
  11608. /**
  11609. * The scene the component belongs to.
  11610. */
  11611. scene: Scene;
  11612. /** @hidden */
  11613. private _spritePredicate;
  11614. /**
  11615. * Creates a new instance of the component for the given scene
  11616. * @param scene Defines the scene to register the component in
  11617. */
  11618. constructor(scene: Scene);
  11619. /**
  11620. * Registers the component in a given scene
  11621. */
  11622. register(): void;
  11623. /**
  11624. * Rebuilds the elements related to this component in case of
  11625. * context lost for instance.
  11626. */
  11627. rebuild(): void;
  11628. /**
  11629. * Disposes the component and the associated ressources.
  11630. */
  11631. dispose(): void;
  11632. private _pickSpriteButKeepRay;
  11633. private _pointerMove;
  11634. private _pointerDown;
  11635. private _pointerUp;
  11636. }
  11637. }
  11638. declare module BABYLON {
  11639. /** @hidden */
  11640. export var fogFragmentDeclaration: {
  11641. name: string;
  11642. shader: string;
  11643. };
  11644. }
  11645. declare module BABYLON {
  11646. /** @hidden */
  11647. export var fogFragment: {
  11648. name: string;
  11649. shader: string;
  11650. };
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var spritesPixelShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /** @hidden */
  11661. export var fogVertexDeclaration: {
  11662. name: string;
  11663. shader: string;
  11664. };
  11665. }
  11666. declare module BABYLON {
  11667. /** @hidden */
  11668. export var spritesVertexShader: {
  11669. name: string;
  11670. shader: string;
  11671. };
  11672. }
  11673. declare module BABYLON {
  11674. /**
  11675. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11676. */
  11677. export interface ISpriteManager extends IDisposable {
  11678. /**
  11679. * Restricts the camera to viewing objects with the same layerMask.
  11680. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11681. */
  11682. layerMask: number;
  11683. /**
  11684. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11685. */
  11686. isPickable: boolean;
  11687. /**
  11688. * Specifies the rendering group id for this mesh (0 by default)
  11689. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11690. */
  11691. renderingGroupId: number;
  11692. /**
  11693. * Defines the list of sprites managed by the manager.
  11694. */
  11695. sprites: Array<Sprite>;
  11696. /**
  11697. * Tests the intersection of a sprite with a specific ray.
  11698. * @param ray The ray we are sending to test the collision
  11699. * @param camera The camera space we are sending rays in
  11700. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11701. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11702. * @returns picking info or null.
  11703. */
  11704. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11705. /**
  11706. * Renders the list of sprites on screen.
  11707. */
  11708. render(): void;
  11709. }
  11710. /**
  11711. * Class used to manage multiple sprites on the same spritesheet
  11712. * @see http://doc.babylonjs.com/babylon101/sprites
  11713. */
  11714. export class SpriteManager implements ISpriteManager {
  11715. /** defines the manager's name */
  11716. name: string;
  11717. /** Gets the list of sprites */
  11718. sprites: Sprite[];
  11719. /** Gets or sets the rendering group id (0 by default) */
  11720. renderingGroupId: number;
  11721. /** Gets or sets camera layer mask */
  11722. layerMask: number;
  11723. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11724. fogEnabled: boolean;
  11725. /** Gets or sets a boolean indicating if the sprites are pickable */
  11726. isPickable: boolean;
  11727. /** Defines the default width of a cell in the spritesheet */
  11728. cellWidth: number;
  11729. /** Defines the default height of a cell in the spritesheet */
  11730. cellHeight: number;
  11731. /**
  11732. * An event triggered when the manager is disposed.
  11733. */
  11734. onDisposeObservable: Observable<SpriteManager>;
  11735. private _onDisposeObserver;
  11736. /**
  11737. * Callback called when the manager is disposed
  11738. */
  11739. onDispose: () => void;
  11740. private _capacity;
  11741. private _spriteTexture;
  11742. private _epsilon;
  11743. private _scene;
  11744. private _vertexData;
  11745. private _buffer;
  11746. private _vertexBuffers;
  11747. private _indexBuffer;
  11748. private _effectBase;
  11749. private _effectFog;
  11750. /**
  11751. * Gets or sets the spritesheet texture
  11752. */
  11753. texture: Texture;
  11754. /**
  11755. * Creates a new sprite manager
  11756. * @param name defines the manager's name
  11757. * @param imgUrl defines the sprite sheet url
  11758. * @param capacity defines the maximum allowed number of sprites
  11759. * @param cellSize defines the size of a sprite cell
  11760. * @param scene defines the hosting scene
  11761. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11762. * @param samplingMode defines the smapling mode to use with spritesheet
  11763. */
  11764. constructor(
  11765. /** defines the manager's name */
  11766. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11767. private _appendSpriteVertex;
  11768. /**
  11769. * Intersects the sprites with a ray
  11770. * @param ray defines the ray to intersect with
  11771. * @param camera defines the current active camera
  11772. * @param predicate defines a predicate used to select candidate sprites
  11773. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11774. * @returns null if no hit or a PickingInfo
  11775. */
  11776. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11777. /**
  11778. * Render all child sprites
  11779. */
  11780. render(): void;
  11781. /**
  11782. * Release associated resources
  11783. */
  11784. dispose(): void;
  11785. }
  11786. }
  11787. declare module BABYLON {
  11788. /**
  11789. * Class used to represent a sprite
  11790. * @see http://doc.babylonjs.com/babylon101/sprites
  11791. */
  11792. export class Sprite {
  11793. /** defines the name */
  11794. name: string;
  11795. /** Gets or sets the current world position */
  11796. position: Vector3;
  11797. /** Gets or sets the main color */
  11798. color: Color4;
  11799. /** Gets or sets the width */
  11800. width: number;
  11801. /** Gets or sets the height */
  11802. height: number;
  11803. /** Gets or sets rotation angle */
  11804. angle: number;
  11805. /** Gets or sets the cell index in the sprite sheet */
  11806. cellIndex: number;
  11807. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11808. invertU: number;
  11809. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11810. invertV: number;
  11811. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11812. disposeWhenFinishedAnimating: boolean;
  11813. /** Gets the list of attached animations */
  11814. animations: Animation[];
  11815. /** Gets or sets a boolean indicating if the sprite can be picked */
  11816. isPickable: boolean;
  11817. /**
  11818. * Gets or sets the associated action manager
  11819. */
  11820. actionManager: Nullable<ActionManager>;
  11821. private _animationStarted;
  11822. private _loopAnimation;
  11823. private _fromIndex;
  11824. private _toIndex;
  11825. private _delay;
  11826. private _direction;
  11827. private _manager;
  11828. private _time;
  11829. private _onAnimationEnd;
  11830. /**
  11831. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11832. */
  11833. isVisible: boolean;
  11834. /**
  11835. * Gets or sets the sprite size
  11836. */
  11837. size: number;
  11838. /**
  11839. * Creates a new Sprite
  11840. * @param name defines the name
  11841. * @param manager defines the manager
  11842. */
  11843. constructor(
  11844. /** defines the name */
  11845. name: string, manager: ISpriteManager);
  11846. /**
  11847. * Starts an animation
  11848. * @param from defines the initial key
  11849. * @param to defines the end key
  11850. * @param loop defines if the animation must loop
  11851. * @param delay defines the start delay (in ms)
  11852. * @param onAnimationEnd defines a callback to call when animation ends
  11853. */
  11854. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11855. /** Stops current animation (if any) */
  11856. stopAnimation(): void;
  11857. /** @hidden */ animate(deltaTime: number): void;
  11858. /** Release associated resources */
  11859. dispose(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * Information about the result of picking within a scene
  11865. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11866. */
  11867. export class PickingInfo {
  11868. /** @hidden */ pickingUnavailable: boolean;
  11869. /**
  11870. * If the pick collided with an object
  11871. */
  11872. hit: boolean;
  11873. /**
  11874. * Distance away where the pick collided
  11875. */
  11876. distance: number;
  11877. /**
  11878. * The location of pick collision
  11879. */
  11880. pickedPoint: Nullable<Vector3>;
  11881. /**
  11882. * The mesh corresponding the the pick collision
  11883. */
  11884. pickedMesh: Nullable<AbstractMesh>;
  11885. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11886. bu: number;
  11887. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11888. bv: number;
  11889. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11890. faceId: number;
  11891. /** Id of the the submesh that was picked */
  11892. subMeshId: number;
  11893. /** If a sprite was picked, this will be the sprite the pick collided with */
  11894. pickedSprite: Nullable<Sprite>;
  11895. /**
  11896. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11897. */
  11898. originMesh: Nullable<AbstractMesh>;
  11899. /**
  11900. * The ray that was used to perform the picking.
  11901. */
  11902. ray: Nullable<Ray>;
  11903. /**
  11904. * Gets the normal correspodning to the face the pick collided with
  11905. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11906. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11907. * @returns The normal correspodning to the face the pick collided with
  11908. */
  11909. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11910. /**
  11911. * Gets the texture coordinates of where the pick occured
  11912. * @returns the vector containing the coordnates of the texture
  11913. */
  11914. getTextureCoordinates(): Nullable<Vector2>;
  11915. }
  11916. }
  11917. declare module BABYLON {
  11918. /**
  11919. * Gather the list of pointer event types as constants.
  11920. */
  11921. export class PointerEventTypes {
  11922. /**
  11923. * 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.
  11924. */
  11925. static readonly POINTERDOWN: number;
  11926. /**
  11927. * The pointerup event is fired when a pointer is no longer active.
  11928. */
  11929. static readonly POINTERUP: number;
  11930. /**
  11931. * The pointermove event is fired when a pointer changes coordinates.
  11932. */
  11933. static readonly POINTERMOVE: number;
  11934. /**
  11935. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11936. */
  11937. static readonly POINTERWHEEL: number;
  11938. /**
  11939. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11940. */
  11941. static readonly POINTERPICK: number;
  11942. /**
  11943. * The pointertap event is fired when a the object has been touched and released without drag.
  11944. */
  11945. static readonly POINTERTAP: number;
  11946. /**
  11947. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11948. */
  11949. static readonly POINTERDOUBLETAP: number;
  11950. }
  11951. /**
  11952. * Base class of pointer info types.
  11953. */
  11954. export class PointerInfoBase {
  11955. /**
  11956. * Defines the type of event (PointerEventTypes)
  11957. */
  11958. type: number;
  11959. /**
  11960. * Defines the related dom event
  11961. */
  11962. event: PointerEvent | MouseWheelEvent;
  11963. /**
  11964. * Instantiates the base class of pointers info.
  11965. * @param type Defines the type of event (PointerEventTypes)
  11966. * @param event Defines the related dom event
  11967. */
  11968. constructor(
  11969. /**
  11970. * Defines the type of event (PointerEventTypes)
  11971. */
  11972. type: number,
  11973. /**
  11974. * Defines the related dom event
  11975. */
  11976. event: PointerEvent | MouseWheelEvent);
  11977. }
  11978. /**
  11979. * This class is used to store pointer related info for the onPrePointerObservable event.
  11980. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11981. */
  11982. export class PointerInfoPre extends PointerInfoBase {
  11983. /**
  11984. * Ray from a pointer if availible (eg. 6dof controller)
  11985. */
  11986. ray: Nullable<Ray>;
  11987. /**
  11988. * Defines the local position of the pointer on the canvas.
  11989. */
  11990. localPosition: Vector2;
  11991. /**
  11992. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11993. */
  11994. skipOnPointerObservable: boolean;
  11995. /**
  11996. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11997. * @param type Defines the type of event (PointerEventTypes)
  11998. * @param event Defines the related dom event
  11999. * @param localX Defines the local x coordinates of the pointer when the event occured
  12000. * @param localY Defines the local y coordinates of the pointer when the event occured
  12001. */
  12002. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12003. }
  12004. /**
  12005. * This type contains all the data related to a pointer event in Babylon.js.
  12006. * 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.
  12007. */
  12008. export class PointerInfo extends PointerInfoBase {
  12009. /**
  12010. * Defines the picking info associated to the info (if any)\
  12011. */
  12012. pickInfo: Nullable<PickingInfo>;
  12013. /**
  12014. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12015. * @param type Defines the type of event (PointerEventTypes)
  12016. * @param event Defines the related dom event
  12017. * @param pickInfo Defines the picking info associated to the info (if any)\
  12018. */
  12019. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12020. /**
  12021. * Defines the picking info associated to the info (if any)\
  12022. */
  12023. pickInfo: Nullable<PickingInfo>);
  12024. }
  12025. /**
  12026. * Data relating to a touch event on the screen.
  12027. */
  12028. export interface PointerTouch {
  12029. /**
  12030. * X coordinate of touch.
  12031. */
  12032. x: number;
  12033. /**
  12034. * Y coordinate of touch.
  12035. */
  12036. y: number;
  12037. /**
  12038. * Id of touch. Unique for each finger.
  12039. */
  12040. pointerId: number;
  12041. /**
  12042. * Event type passed from DOM.
  12043. */
  12044. type: any;
  12045. }
  12046. }
  12047. declare module BABYLON {
  12048. /**
  12049. * Manage the mouse inputs to control the movement of a free camera.
  12050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12051. */
  12052. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12053. /**
  12054. * Define if touch is enabled in the mouse input
  12055. */
  12056. touchEnabled: boolean;
  12057. /**
  12058. * Defines the camera the input is attached to.
  12059. */
  12060. camera: FreeCamera;
  12061. /**
  12062. * Defines the buttons associated with the input to handle camera move.
  12063. */
  12064. buttons: number[];
  12065. /**
  12066. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12067. */
  12068. angularSensibility: number;
  12069. private _pointerInput;
  12070. private _onMouseMove;
  12071. private _observer;
  12072. private previousPosition;
  12073. /**
  12074. * Observable for when a pointer move event occurs containing the move offset
  12075. */
  12076. onPointerMovedObservable: Observable<{
  12077. offsetX: number;
  12078. offsetY: number;
  12079. }>;
  12080. /**
  12081. * @hidden
  12082. * If the camera should be rotated automatically based on pointer movement
  12083. */ allowCameraRotation: boolean;
  12084. /**
  12085. * Manage the mouse inputs to control the movement of a free camera.
  12086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12087. * @param touchEnabled Defines if touch is enabled or not
  12088. */
  12089. constructor(
  12090. /**
  12091. * Define if touch is enabled in the mouse input
  12092. */
  12093. touchEnabled?: boolean);
  12094. /**
  12095. * Attach the input controls to a specific dom element to get the input from.
  12096. * @param element Defines the element the controls should be listened from
  12097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12098. */
  12099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12100. /**
  12101. * Called on JS contextmenu event.
  12102. * Override this method to provide functionality.
  12103. */
  12104. protected onContextMenu(evt: PointerEvent): void;
  12105. /**
  12106. * Detach the current controls from the specified dom element.
  12107. * @param element Defines the element to stop listening the inputs from
  12108. */
  12109. detachControl(element: Nullable<HTMLElement>): void;
  12110. /**
  12111. * Gets the class name of the current intput.
  12112. * @returns the class name
  12113. */
  12114. getClassName(): string;
  12115. /**
  12116. * Get the friendly name associated with the input class.
  12117. * @returns the input friendly name
  12118. */
  12119. getSimpleName(): string;
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /**
  12124. * Manage the touch inputs to control the movement of a free camera.
  12125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12126. */
  12127. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12128. /**
  12129. * Defines the camera the input is attached to.
  12130. */
  12131. camera: FreeCamera;
  12132. /**
  12133. * Defines the touch sensibility for rotation.
  12134. * The higher the faster.
  12135. */
  12136. touchAngularSensibility: number;
  12137. /**
  12138. * Defines the touch sensibility for move.
  12139. * The higher the faster.
  12140. */
  12141. touchMoveSensibility: number;
  12142. private _offsetX;
  12143. private _offsetY;
  12144. private _pointerPressed;
  12145. private _pointerInput;
  12146. private _observer;
  12147. private _onLostFocus;
  12148. /**
  12149. * Attach the input controls to a specific dom element to get the input from.
  12150. * @param element Defines the element the controls should be listened from
  12151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12152. */
  12153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12154. /**
  12155. * Detach the current controls from the specified dom element.
  12156. * @param element Defines the element to stop listening the inputs from
  12157. */
  12158. detachControl(element: Nullable<HTMLElement>): void;
  12159. /**
  12160. * Update the current camera state depending on the inputs that have been used this frame.
  12161. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12162. */
  12163. checkInputs(): void;
  12164. /**
  12165. * Gets the class name of the current intput.
  12166. * @returns the class name
  12167. */
  12168. getClassName(): string;
  12169. /**
  12170. * Get the friendly name associated with the input class.
  12171. * @returns the input friendly name
  12172. */
  12173. getSimpleName(): string;
  12174. }
  12175. }
  12176. declare module BABYLON {
  12177. /**
  12178. * Default Inputs manager for the FreeCamera.
  12179. * It groups all the default supported inputs for ease of use.
  12180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12181. */
  12182. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12183. /**
  12184. * @hidden
  12185. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12186. /**
  12187. * @hidden
  12188. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12189. /**
  12190. * Instantiates a new FreeCameraInputsManager.
  12191. * @param camera Defines the camera the inputs belong to
  12192. */
  12193. constructor(camera: FreeCamera);
  12194. /**
  12195. * Add keyboard input support to the input manager.
  12196. * @returns the current input manager
  12197. */
  12198. addKeyboard(): FreeCameraInputsManager;
  12199. /**
  12200. * Add mouse input support to the input manager.
  12201. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12202. * @returns the current input manager
  12203. */
  12204. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12205. /**
  12206. * Removes the mouse input support from the manager
  12207. * @returns the current input manager
  12208. */
  12209. removeMouse(): FreeCameraInputsManager;
  12210. /**
  12211. * Add touch input support to the input manager.
  12212. * @returns the current input manager
  12213. */
  12214. addTouch(): FreeCameraInputsManager;
  12215. }
  12216. }
  12217. declare module BABYLON {
  12218. /**
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. */
  12223. export class FreeCamera extends TargetCamera {
  12224. /**
  12225. * Define the collision ellipsoid of the camera.
  12226. * This is helpful to simulate a camera body like the player body around the camera
  12227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12228. */
  12229. ellipsoid: Vector3;
  12230. /**
  12231. * Define an offset for the position of the ellipsoid around the camera.
  12232. * This can be helpful to determine the center of the body near the gravity center of the body
  12233. * instead of its head.
  12234. */
  12235. ellipsoidOffset: Vector3;
  12236. /**
  12237. * Enable or disable collisions of the camera with the rest of the scene objects.
  12238. */
  12239. checkCollisions: boolean;
  12240. /**
  12241. * Enable or disable gravity on the camera.
  12242. */
  12243. applyGravity: boolean;
  12244. /**
  12245. * Define the input manager associated to the camera.
  12246. */
  12247. inputs: FreeCameraInputsManager;
  12248. /**
  12249. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12250. * Higher values reduce sensitivity.
  12251. */
  12252. /**
  12253. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12254. * Higher values reduce sensitivity.
  12255. */
  12256. angularSensibility: number;
  12257. /**
  12258. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12259. */
  12260. keysUp: number[];
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12263. */
  12264. keysDown: number[];
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12267. */
  12268. keysLeft: number[];
  12269. /**
  12270. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12271. */
  12272. keysRight: number[];
  12273. /**
  12274. * Event raised when the camera collide with a mesh in the scene.
  12275. */
  12276. onCollide: (collidedMesh: AbstractMesh) => void;
  12277. private _collider;
  12278. private _needMoveForGravity;
  12279. private _oldPosition;
  12280. private _diffPosition;
  12281. private _newPosition;
  12282. /** @hidden */ localDirection: Vector3;
  12283. /** @hidden */ transformedDirection: Vector3;
  12284. /**
  12285. * Instantiates a Free Camera.
  12286. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12287. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12289. * @param name Define the name of the camera in the scene
  12290. * @param position Define the start position of the camera in the scene
  12291. * @param scene Define the scene the camera belongs to
  12292. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12293. */
  12294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12295. /**
  12296. * Attached controls to the current camera.
  12297. * @param element Defines the element the controls should be listened from
  12298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12299. */
  12300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12301. /**
  12302. * Detach the current controls from the camera.
  12303. * The camera will stop reacting to inputs.
  12304. * @param element Defines the element to stop listening the inputs from
  12305. */
  12306. detachControl(element: HTMLElement): void;
  12307. private _collisionMask;
  12308. /**
  12309. * Define a collision mask to limit the list of object the camera can collide with
  12310. */
  12311. collisionMask: number;
  12312. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12313. private _onCollisionPositionChange;
  12314. /** @hidden */ checkInputs(): void;
  12315. /** @hidden */ decideIfNeedsToMove(): boolean;
  12316. /** @hidden */ updatePosition(): void;
  12317. /**
  12318. * Destroy the camera and release the current resources hold by it.
  12319. */
  12320. dispose(): void;
  12321. /**
  12322. * Gets the current object class name.
  12323. * @return the class name
  12324. */
  12325. getClassName(): string;
  12326. }
  12327. }
  12328. declare module BABYLON {
  12329. /**
  12330. * Represents a gamepad control stick position
  12331. */
  12332. export class StickValues {
  12333. /**
  12334. * The x component of the control stick
  12335. */
  12336. x: number;
  12337. /**
  12338. * The y component of the control stick
  12339. */
  12340. y: number;
  12341. /**
  12342. * Initializes the gamepad x and y control stick values
  12343. * @param x The x component of the gamepad control stick value
  12344. * @param y The y component of the gamepad control stick value
  12345. */
  12346. constructor(
  12347. /**
  12348. * The x component of the control stick
  12349. */
  12350. x: number,
  12351. /**
  12352. * The y component of the control stick
  12353. */
  12354. y: number);
  12355. }
  12356. /**
  12357. * An interface which manages callbacks for gamepad button changes
  12358. */
  12359. export interface GamepadButtonChanges {
  12360. /**
  12361. * Called when a gamepad has been changed
  12362. */
  12363. changed: boolean;
  12364. /**
  12365. * Called when a gamepad press event has been triggered
  12366. */
  12367. pressChanged: boolean;
  12368. /**
  12369. * Called when a touch event has been triggered
  12370. */
  12371. touchChanged: boolean;
  12372. /**
  12373. * Called when a value has changed
  12374. */
  12375. valueChanged: boolean;
  12376. }
  12377. /**
  12378. * Represents a gamepad
  12379. */
  12380. export class Gamepad {
  12381. /**
  12382. * The id of the gamepad
  12383. */
  12384. id: string;
  12385. /**
  12386. * The index of the gamepad
  12387. */
  12388. index: number;
  12389. /**
  12390. * The browser gamepad
  12391. */
  12392. browserGamepad: any;
  12393. /**
  12394. * Specifies what type of gamepad this represents
  12395. */
  12396. type: number;
  12397. private _leftStick;
  12398. private _rightStick;
  12399. /** @hidden */ isConnected: boolean;
  12400. private _leftStickAxisX;
  12401. private _leftStickAxisY;
  12402. private _rightStickAxisX;
  12403. private _rightStickAxisY;
  12404. /**
  12405. * Triggered when the left control stick has been changed
  12406. */
  12407. private _onleftstickchanged;
  12408. /**
  12409. * Triggered when the right control stick has been changed
  12410. */
  12411. private _onrightstickchanged;
  12412. /**
  12413. * Represents a gamepad controller
  12414. */
  12415. static GAMEPAD: number;
  12416. /**
  12417. * Represents a generic controller
  12418. */
  12419. static GENERIC: number;
  12420. /**
  12421. * Represents an XBox controller
  12422. */
  12423. static XBOX: number;
  12424. /**
  12425. * Represents a pose-enabled controller
  12426. */
  12427. static POSE_ENABLED: number;
  12428. /**
  12429. * Specifies whether the left control stick should be Y-inverted
  12430. */
  12431. protected _invertLeftStickY: boolean;
  12432. /**
  12433. * Specifies if the gamepad has been connected
  12434. */
  12435. readonly isConnected: boolean;
  12436. /**
  12437. * Initializes the gamepad
  12438. * @param id The id of the gamepad
  12439. * @param index The index of the gamepad
  12440. * @param browserGamepad The browser gamepad
  12441. * @param leftStickX The x component of the left joystick
  12442. * @param leftStickY The y component of the left joystick
  12443. * @param rightStickX The x component of the right joystick
  12444. * @param rightStickY The y component of the right joystick
  12445. */
  12446. constructor(
  12447. /**
  12448. * The id of the gamepad
  12449. */
  12450. id: string,
  12451. /**
  12452. * The index of the gamepad
  12453. */
  12454. index: number,
  12455. /**
  12456. * The browser gamepad
  12457. */
  12458. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12459. /**
  12460. * Callback triggered when the left joystick has changed
  12461. * @param callback
  12462. */
  12463. onleftstickchanged(callback: (values: StickValues) => void): void;
  12464. /**
  12465. * Callback triggered when the right joystick has changed
  12466. * @param callback
  12467. */
  12468. onrightstickchanged(callback: (values: StickValues) => void): void;
  12469. /**
  12470. * Gets the left joystick
  12471. */
  12472. /**
  12473. * Sets the left joystick values
  12474. */
  12475. leftStick: StickValues;
  12476. /**
  12477. * Gets the right joystick
  12478. */
  12479. /**
  12480. * Sets the right joystick value
  12481. */
  12482. rightStick: StickValues;
  12483. /**
  12484. * Updates the gamepad joystick positions
  12485. */
  12486. update(): void;
  12487. /**
  12488. * Disposes the gamepad
  12489. */
  12490. dispose(): void;
  12491. }
  12492. /**
  12493. * Represents a generic gamepad
  12494. */
  12495. export class GenericPad extends Gamepad {
  12496. private _buttons;
  12497. private _onbuttondown;
  12498. private _onbuttonup;
  12499. /**
  12500. * Observable triggered when a button has been pressed
  12501. */
  12502. onButtonDownObservable: Observable<number>;
  12503. /**
  12504. * Observable triggered when a button has been released
  12505. */
  12506. onButtonUpObservable: Observable<number>;
  12507. /**
  12508. * Callback triggered when a button has been pressed
  12509. * @param callback Called when a button has been pressed
  12510. */
  12511. onbuttondown(callback: (buttonPressed: number) => void): void;
  12512. /**
  12513. * Callback triggered when a button has been released
  12514. * @param callback Called when a button has been released
  12515. */
  12516. onbuttonup(callback: (buttonReleased: number) => void): void;
  12517. /**
  12518. * Initializes the generic gamepad
  12519. * @param id The id of the generic gamepad
  12520. * @param index The index of the generic gamepad
  12521. * @param browserGamepad The browser gamepad
  12522. */
  12523. constructor(id: string, index: number, browserGamepad: any);
  12524. private _setButtonValue;
  12525. /**
  12526. * Updates the generic gamepad
  12527. */
  12528. update(): void;
  12529. /**
  12530. * Disposes the generic gamepad
  12531. */
  12532. dispose(): void;
  12533. }
  12534. }
  12535. declare module BABYLON {
  12536. /**
  12537. * Defines the types of pose enabled controllers that are supported
  12538. */
  12539. export enum PoseEnabledControllerType {
  12540. /**
  12541. * HTC Vive
  12542. */
  12543. VIVE = 0,
  12544. /**
  12545. * Oculus Rift
  12546. */
  12547. OCULUS = 1,
  12548. /**
  12549. * Windows mixed reality
  12550. */
  12551. WINDOWS = 2,
  12552. /**
  12553. * Samsung gear VR
  12554. */
  12555. GEAR_VR = 3,
  12556. /**
  12557. * Google Daydream
  12558. */
  12559. DAYDREAM = 4,
  12560. /**
  12561. * Generic
  12562. */
  12563. GENERIC = 5
  12564. }
  12565. /**
  12566. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12567. */
  12568. export interface MutableGamepadButton {
  12569. /**
  12570. * Value of the button/trigger
  12571. */
  12572. value: number;
  12573. /**
  12574. * If the button/trigger is currently touched
  12575. */
  12576. touched: boolean;
  12577. /**
  12578. * If the button/trigger is currently pressed
  12579. */
  12580. pressed: boolean;
  12581. }
  12582. /**
  12583. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12584. * @hidden
  12585. */
  12586. export interface ExtendedGamepadButton extends GamepadButton {
  12587. /**
  12588. * If the button/trigger is currently pressed
  12589. */
  12590. readonly pressed: boolean;
  12591. /**
  12592. * If the button/trigger is currently touched
  12593. */
  12594. readonly touched: boolean;
  12595. /**
  12596. * Value of the button/trigger
  12597. */
  12598. readonly value: number;
  12599. }
  12600. /** @hidden */
  12601. export interface _GamePadFactory {
  12602. /**
  12603. * Returns wether or not the current gamepad can be created for this type of controller.
  12604. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12605. * @returns true if it can be created, otherwise false
  12606. */
  12607. canCreate(gamepadInfo: any): boolean;
  12608. /**
  12609. * Creates a new instance of the Gamepad.
  12610. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12611. * @returns the new gamepad instance
  12612. */
  12613. create(gamepadInfo: any): Gamepad;
  12614. }
  12615. /**
  12616. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12617. */
  12618. export class PoseEnabledControllerHelper {
  12619. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12620. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12621. /**
  12622. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12623. * @param vrGamepad the gamepad to initialized
  12624. * @returns a vr controller of the type the gamepad identified as
  12625. */
  12626. static InitiateController(vrGamepad: any): Gamepad;
  12627. }
  12628. /**
  12629. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12630. */
  12631. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12632. private _deviceRoomPosition;
  12633. private _deviceRoomRotationQuaternion;
  12634. /**
  12635. * The device position in babylon space
  12636. */
  12637. devicePosition: Vector3;
  12638. /**
  12639. * The device rotation in babylon space
  12640. */
  12641. deviceRotationQuaternion: Quaternion;
  12642. /**
  12643. * The scale factor of the device in babylon space
  12644. */
  12645. deviceScaleFactor: number;
  12646. /**
  12647. * (Likely devicePosition should be used instead) The device position in its room space
  12648. */
  12649. position: Vector3;
  12650. /**
  12651. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12652. */
  12653. rotationQuaternion: Quaternion;
  12654. /**
  12655. * The type of controller (Eg. Windows mixed reality)
  12656. */
  12657. controllerType: PoseEnabledControllerType;
  12658. protected _calculatedPosition: Vector3;
  12659. private _calculatedRotation;
  12660. /**
  12661. * The raw pose from the device
  12662. */
  12663. rawPose: DevicePose;
  12664. private _trackPosition;
  12665. private _maxRotationDistFromHeadset;
  12666. private _draggedRoomRotation;
  12667. /**
  12668. * @hidden
  12669. */ disableTrackPosition(fixedPosition: Vector3): void;
  12670. /**
  12671. * Internal, the mesh attached to the controller
  12672. * @hidden
  12673. */ mesh: Nullable<AbstractMesh>;
  12674. private _poseControlledCamera;
  12675. private _leftHandSystemQuaternion;
  12676. /**
  12677. * Internal, matrix used to convert room space to babylon space
  12678. * @hidden
  12679. */ deviceToWorld: Matrix;
  12680. /**
  12681. * Node to be used when casting a ray from the controller
  12682. * @hidden
  12683. */ pointingPoseNode: Nullable<TransformNode>;
  12684. /**
  12685. * Name of the child mesh that can be used to cast a ray from the controller
  12686. */
  12687. static readonly POINTING_POSE: string;
  12688. /**
  12689. * Creates a new PoseEnabledController from a gamepad
  12690. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12691. */
  12692. constructor(browserGamepad: any);
  12693. private _workingMatrix;
  12694. /**
  12695. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12696. */
  12697. update(): void;
  12698. /**
  12699. * Updates only the pose device and mesh without doing any button event checking
  12700. */
  12701. protected _updatePoseAndMesh(): void;
  12702. /**
  12703. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12704. * @param poseData raw pose fromthe device
  12705. */
  12706. updateFromDevice(poseData: DevicePose): void;
  12707. /**
  12708. * @hidden
  12709. */ meshAttachedObservable: Observable<AbstractMesh>;
  12710. /**
  12711. * Attaches a mesh to the controller
  12712. * @param mesh the mesh to be attached
  12713. */
  12714. attachToMesh(mesh: AbstractMesh): void;
  12715. /**
  12716. * Attaches the controllers mesh to a camera
  12717. * @param camera the camera the mesh should be attached to
  12718. */
  12719. attachToPoseControlledCamera(camera: TargetCamera): void;
  12720. /**
  12721. * Disposes of the controller
  12722. */
  12723. dispose(): void;
  12724. /**
  12725. * The mesh that is attached to the controller
  12726. */
  12727. readonly mesh: Nullable<AbstractMesh>;
  12728. /**
  12729. * Gets the ray of the controller in the direction the controller is pointing
  12730. * @param length the length the resulting ray should be
  12731. * @returns a ray in the direction the controller is pointing
  12732. */
  12733. getForwardRay(length?: number): Ray;
  12734. }
  12735. }
  12736. declare module BABYLON {
  12737. /**
  12738. * Defines the WebVRController object that represents controllers tracked in 3D space
  12739. */
  12740. export abstract class WebVRController extends PoseEnabledController {
  12741. /**
  12742. * Internal, the default controller model for the controller
  12743. */
  12744. protected _defaultModel: AbstractMesh;
  12745. /**
  12746. * Fired when the trigger state has changed
  12747. */
  12748. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12749. /**
  12750. * Fired when the main button state has changed
  12751. */
  12752. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12753. /**
  12754. * Fired when the secondary button state has changed
  12755. */
  12756. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12757. /**
  12758. * Fired when the pad state has changed
  12759. */
  12760. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12761. /**
  12762. * Fired when controllers stick values have changed
  12763. */
  12764. onPadValuesChangedObservable: Observable<StickValues>;
  12765. /**
  12766. * Array of button availible on the controller
  12767. */
  12768. protected _buttons: Array<MutableGamepadButton>;
  12769. private _onButtonStateChange;
  12770. /**
  12771. * Fired when a controller button's state has changed
  12772. * @param callback the callback containing the button that was modified
  12773. */
  12774. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12775. /**
  12776. * X and Y axis corrisponding to the controllers joystick
  12777. */
  12778. pad: StickValues;
  12779. /**
  12780. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12781. */
  12782. hand: string;
  12783. /**
  12784. * The default controller model for the controller
  12785. */
  12786. readonly defaultModel: AbstractMesh;
  12787. /**
  12788. * Creates a new WebVRController from a gamepad
  12789. * @param vrGamepad the gamepad that the WebVRController should be created from
  12790. */
  12791. constructor(vrGamepad: any);
  12792. /**
  12793. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12794. */
  12795. update(): void;
  12796. /**
  12797. * Function to be called when a button is modified
  12798. */
  12799. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12800. /**
  12801. * Loads a mesh and attaches it to the controller
  12802. * @param scene the scene the mesh should be added to
  12803. * @param meshLoaded callback for when the mesh has been loaded
  12804. */
  12805. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12806. private _setButtonValue;
  12807. private _changes;
  12808. private _checkChanges;
  12809. /**
  12810. * Disposes of th webVRCOntroller
  12811. */
  12812. dispose(): void;
  12813. }
  12814. }
  12815. declare module BABYLON {
  12816. /**
  12817. * The HemisphericLight simulates the ambient environment light,
  12818. * so the passed direction is the light reflection direction, not the incoming direction.
  12819. */
  12820. export class HemisphericLight extends Light {
  12821. /**
  12822. * The groundColor is the light in the opposite direction to the one specified during creation.
  12823. * 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.
  12824. */
  12825. groundColor: Color3;
  12826. /**
  12827. * The light reflection direction, not the incoming direction.
  12828. */
  12829. direction: Vector3;
  12830. /**
  12831. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12832. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12833. * The HemisphericLight can't cast shadows.
  12834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12835. * @param name The friendly name of the light
  12836. * @param direction The direction of the light reflection
  12837. * @param scene The scene the light belongs to
  12838. */
  12839. constructor(name: string, direction: Vector3, scene: Scene);
  12840. protected _buildUniformLayout(): void;
  12841. /**
  12842. * Returns the string "HemisphericLight".
  12843. * @return The class name
  12844. */
  12845. getClassName(): string;
  12846. /**
  12847. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12848. * Returns the updated direction.
  12849. * @param target The target the direction should point to
  12850. * @return The computed direction
  12851. */
  12852. setDirectionToTarget(target: Vector3): Vector3;
  12853. /**
  12854. * Returns the shadow generator associated to the light.
  12855. * @returns Always null for hemispheric lights because it does not support shadows.
  12856. */
  12857. getShadowGenerator(): Nullable<IShadowGenerator>;
  12858. /**
  12859. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12860. * @param effect The effect to update
  12861. * @param lightIndex The index of the light in the effect to update
  12862. * @returns The hemispheric light
  12863. */
  12864. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12865. /**
  12866. * Computes the world matrix of the node
  12867. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12868. * @param useWasUpdatedFlag defines a reserved property
  12869. * @returns the world matrix
  12870. */
  12871. computeWorldMatrix(): Matrix;
  12872. /**
  12873. * Returns the integer 3.
  12874. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12875. */
  12876. getTypeID(): number;
  12877. /**
  12878. * Prepares the list of defines specific to the light type.
  12879. * @param defines the list of defines
  12880. * @param lightIndex defines the index of the light for the effect
  12881. */
  12882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12883. }
  12884. }
  12885. declare module BABYLON {
  12886. /** @hidden */
  12887. export var vrMultiviewToSingleviewPixelShader: {
  12888. name: string;
  12889. shader: string;
  12890. };
  12891. }
  12892. declare module BABYLON {
  12893. /**
  12894. * Renders to multiple views with a single draw call
  12895. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12896. */
  12897. export class MultiviewRenderTarget extends RenderTargetTexture {
  12898. /**
  12899. * Creates a multiview render target
  12900. * @param scene scene used with the render target
  12901. * @param size the size of the render target (used for each view)
  12902. */
  12903. constructor(scene: Scene, size?: number | {
  12904. width: number;
  12905. height: number;
  12906. } | {
  12907. ratio: number;
  12908. });
  12909. /**
  12910. * @hidden
  12911. * @param faceIndex the face index, if its a cube texture
  12912. */ bindFrameBuffer(faceIndex?: number): void;
  12913. /**
  12914. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12915. * @returns the view count
  12916. */
  12917. getViewCount(): number;
  12918. }
  12919. }
  12920. declare module BABYLON {
  12921. interface Engine {
  12922. /**
  12923. * Creates a new multiview render target
  12924. * @param width defines the width of the texture
  12925. * @param height defines the height of the texture
  12926. * @returns the created multiview texture
  12927. */
  12928. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12929. /**
  12930. * Binds a multiview framebuffer to be drawn to
  12931. * @param multiviewTexture texture to bind
  12932. */
  12933. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12934. }
  12935. interface Camera {
  12936. /**
  12937. * @hidden
  12938. * 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)
  12939. */ useMultiviewToSingleView: boolean;
  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. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12944. /**
  12945. * @hidden
  12946. * ensures the multiview texture of the camera exists and has the specified width/height
  12947. * @param width height to set on the multiview texture
  12948. * @param height width to set on the multiview texture
  12949. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12950. }
  12951. interface Scene {
  12952. /** @hidden */ transformMatrixR: Matrix;
  12953. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12954. /** @hidden */ createMultiviewUbo(): void;
  12955. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12956. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12957. }
  12958. }
  12959. declare module BABYLON {
  12960. /**
  12961. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12962. * This will not be used for webXR as it supports displaying texture arrays directly
  12963. */
  12964. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12965. /**
  12966. * Initializes a VRMultiviewToSingleview
  12967. * @param name name of the post process
  12968. * @param camera camera to be applied to
  12969. * @param scaleFactor scaling factor to the size of the output texture
  12970. */
  12971. constructor(name: string, camera: Camera, scaleFactor: number);
  12972. }
  12973. }
  12974. declare module BABYLON {
  12975. /**
  12976. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12977. * IMPORTANT!! The data is right-hand data.
  12978. * @export
  12979. * @interface DevicePose
  12980. */
  12981. export interface DevicePose {
  12982. /**
  12983. * The position of the device, values in array are [x,y,z].
  12984. */
  12985. readonly position: Nullable<Float32Array>;
  12986. /**
  12987. * The linearVelocity of the device, values in array are [x,y,z].
  12988. */
  12989. readonly linearVelocity: Nullable<Float32Array>;
  12990. /**
  12991. * The linearAcceleration of the device, values in array are [x,y,z].
  12992. */
  12993. readonly linearAcceleration: Nullable<Float32Array>;
  12994. /**
  12995. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12996. */
  12997. readonly orientation: Nullable<Float32Array>;
  12998. /**
  12999. * The angularVelocity of the device, values in array are [x,y,z].
  13000. */
  13001. readonly angularVelocity: Nullable<Float32Array>;
  13002. /**
  13003. * The angularAcceleration of the device, values in array are [x,y,z].
  13004. */
  13005. readonly angularAcceleration: Nullable<Float32Array>;
  13006. }
  13007. /**
  13008. * Interface representing a pose controlled object in Babylon.
  13009. * A pose controlled object has both regular pose values as well as pose values
  13010. * from an external device such as a VR head mounted display
  13011. */
  13012. export interface PoseControlled {
  13013. /**
  13014. * The position of the object in babylon space.
  13015. */
  13016. position: Vector3;
  13017. /**
  13018. * The rotation quaternion of the object in babylon space.
  13019. */
  13020. rotationQuaternion: Quaternion;
  13021. /**
  13022. * The position of the device in babylon space.
  13023. */
  13024. devicePosition?: Vector3;
  13025. /**
  13026. * The rotation quaternion of the device in babylon space.
  13027. */
  13028. deviceRotationQuaternion: Quaternion;
  13029. /**
  13030. * The raw pose coming from the device.
  13031. */
  13032. rawPose: Nullable<DevicePose>;
  13033. /**
  13034. * The scale of the device to be used when translating from device space to babylon space.
  13035. */
  13036. deviceScaleFactor: number;
  13037. /**
  13038. * Updates the poseControlled values based on the input device pose.
  13039. * @param poseData the pose data to update the object with
  13040. */
  13041. updateFromDevice(poseData: DevicePose): void;
  13042. }
  13043. /**
  13044. * Set of options to customize the webVRCamera
  13045. */
  13046. export interface WebVROptions {
  13047. /**
  13048. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13049. */
  13050. trackPosition?: boolean;
  13051. /**
  13052. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13053. */
  13054. positionScale?: number;
  13055. /**
  13056. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13057. */
  13058. displayName?: string;
  13059. /**
  13060. * Should the native controller meshes be initialized. (default: true)
  13061. */
  13062. controllerMeshes?: boolean;
  13063. /**
  13064. * Creating a default HemiLight only on controllers. (default: true)
  13065. */
  13066. defaultLightingOnControllers?: boolean;
  13067. /**
  13068. * If you don't want to use the default VR button of the helper. (default: false)
  13069. */
  13070. useCustomVRButton?: boolean;
  13071. /**
  13072. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13073. */
  13074. customVRButton?: HTMLButtonElement;
  13075. /**
  13076. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13077. */
  13078. rayLength?: number;
  13079. /**
  13080. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13081. */
  13082. defaultHeight?: number;
  13083. /**
  13084. * If multiview should be used if availible (default: false)
  13085. */
  13086. useMultiview?: boolean;
  13087. }
  13088. /**
  13089. * This represents a WebVR camera.
  13090. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13091. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13092. */
  13093. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13094. private webVROptions;
  13095. /**
  13096. * @hidden
  13097. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13098. */ vrDevice: any;
  13099. /**
  13100. * The rawPose of the vrDevice.
  13101. */
  13102. rawPose: Nullable<DevicePose>;
  13103. private _onVREnabled;
  13104. private _specsVersion;
  13105. private _attached;
  13106. private _frameData;
  13107. protected _descendants: Array<Node>;
  13108. private _deviceRoomPosition;
  13109. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13110. private _standingMatrix;
  13111. /**
  13112. * Represents device position in babylon space.
  13113. */
  13114. devicePosition: Vector3;
  13115. /**
  13116. * Represents device rotation in babylon space.
  13117. */
  13118. deviceRotationQuaternion: Quaternion;
  13119. /**
  13120. * The scale of the device to be used when translating from device space to babylon space.
  13121. */
  13122. deviceScaleFactor: number;
  13123. private _deviceToWorld;
  13124. private _worldToDevice;
  13125. /**
  13126. * References to the webVR controllers for the vrDevice.
  13127. */
  13128. controllers: Array<WebVRController>;
  13129. /**
  13130. * Emits an event when a controller is attached.
  13131. */
  13132. onControllersAttachedObservable: Observable<WebVRController[]>;
  13133. /**
  13134. * Emits an event when a controller's mesh has been loaded;
  13135. */
  13136. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13137. /**
  13138. * Emits an event when the HMD's pose has been updated.
  13139. */
  13140. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13141. private _poseSet;
  13142. /**
  13143. * If the rig cameras be used as parent instead of this camera.
  13144. */
  13145. rigParenting: boolean;
  13146. private _lightOnControllers;
  13147. private _defaultHeight?;
  13148. /**
  13149. * Instantiates a WebVRFreeCamera.
  13150. * @param name The name of the WebVRFreeCamera
  13151. * @param position The starting anchor position for the camera
  13152. * @param scene The scene the camera belongs to
  13153. * @param webVROptions a set of customizable options for the webVRCamera
  13154. */
  13155. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13156. /**
  13157. * Gets the device distance from the ground in meters.
  13158. * @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.
  13159. */
  13160. deviceDistanceToRoomGround(): number;
  13161. /**
  13162. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13163. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13164. */
  13165. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13166. /**
  13167. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13168. * @returns A promise with a boolean set to if the standing matrix is supported.
  13169. */
  13170. useStandingMatrixAsync(): Promise<boolean>;
  13171. /**
  13172. * Disposes the camera
  13173. */
  13174. dispose(): void;
  13175. /**
  13176. * Gets a vrController by name.
  13177. * @param name The name of the controller to retreive
  13178. * @returns the controller matching the name specified or null if not found
  13179. */
  13180. getControllerByName(name: string): Nullable<WebVRController>;
  13181. private _leftController;
  13182. /**
  13183. * The controller corrisponding to the users left hand.
  13184. */
  13185. readonly leftController: Nullable<WebVRController>;
  13186. private _rightController;
  13187. /**
  13188. * The controller corrisponding to the users right hand.
  13189. */
  13190. readonly rightController: Nullable<WebVRController>;
  13191. /**
  13192. * Casts a ray forward from the vrCamera's gaze.
  13193. * @param length Length of the ray (default: 100)
  13194. * @returns the ray corrisponding to the gaze
  13195. */
  13196. getForwardRay(length?: number): Ray;
  13197. /**
  13198. * @hidden
  13199. * Updates the camera based on device's frame data
  13200. */ checkInputs(): void;
  13201. /**
  13202. * Updates the poseControlled values based on the input device pose.
  13203. * @param poseData Pose coming from the device
  13204. */
  13205. updateFromDevice(poseData: DevicePose): void;
  13206. private _htmlElementAttached;
  13207. private _detachIfAttached;
  13208. /**
  13209. * WebVR's attach control will start broadcasting frames to the device.
  13210. * Note that in certain browsers (chrome for example) this function must be called
  13211. * within a user-interaction callback. Example:
  13212. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13213. *
  13214. * @param element html element to attach the vrDevice to
  13215. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13216. */
  13217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13218. /**
  13219. * Detaches the camera from the html element and disables VR
  13220. *
  13221. * @param element html element to detach from
  13222. */
  13223. detachControl(element: HTMLElement): void;
  13224. /**
  13225. * @returns the name of this class
  13226. */
  13227. getClassName(): string;
  13228. /**
  13229. * Calls resetPose on the vrDisplay
  13230. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13231. */
  13232. resetToCurrentRotation(): void;
  13233. /**
  13234. * @hidden
  13235. * Updates the rig cameras (left and right eye)
  13236. */ updateRigCameras(): void;
  13237. private _workingVector;
  13238. private _oneVector;
  13239. private _workingMatrix;
  13240. private updateCacheCalled;
  13241. private _correctPositionIfNotTrackPosition;
  13242. /**
  13243. * @hidden
  13244. * Updates the cached values of the camera
  13245. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13246. */ updateCache(ignoreParentClass?: boolean): void;
  13247. /**
  13248. * @hidden
  13249. * Get current device position in babylon world
  13250. */ computeDevicePosition(): void;
  13251. /**
  13252. * Updates the current device position and rotation in the babylon world
  13253. */
  13254. update(): void;
  13255. /**
  13256. * @hidden
  13257. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13258. * @returns an identity matrix
  13259. */ getViewMatrix(): Matrix;
  13260. private _tmpMatrix;
  13261. /**
  13262. * This function is called by the two RIG cameras.
  13263. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13264. * @hidden
  13265. */ getWebVRViewMatrix(): Matrix;
  13266. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13267. private _onGamepadConnectedObserver;
  13268. private _onGamepadDisconnectedObserver;
  13269. private _updateCacheWhenTrackingDisabledObserver;
  13270. /**
  13271. * Initializes the controllers and their meshes
  13272. */
  13273. initControllers(): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Size options for a post process
  13279. */
  13280. export type PostProcessOptions = {
  13281. width: number;
  13282. height: number;
  13283. };
  13284. /**
  13285. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13286. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13287. */
  13288. export class PostProcess {
  13289. /** Name of the PostProcess. */
  13290. name: string;
  13291. /**
  13292. * Gets or sets the unique id of the post process
  13293. */
  13294. uniqueId: number;
  13295. /**
  13296. * Width of the texture to apply the post process on
  13297. */
  13298. width: number;
  13299. /**
  13300. * Height of the texture to apply the post process on
  13301. */
  13302. height: number;
  13303. /**
  13304. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13305. * @hidden
  13306. */ outputTexture: Nullable<InternalTexture>;
  13307. /**
  13308. * Sampling mode used by the shader
  13309. * See https://doc.babylonjs.com/classes/3.1/texture
  13310. */
  13311. renderTargetSamplingMode: number;
  13312. /**
  13313. * Clear color to use when screen clearing
  13314. */
  13315. clearColor: Color4;
  13316. /**
  13317. * If the buffer needs to be cleared before applying the post process. (default: true)
  13318. * Should be set to false if shader will overwrite all previous pixels.
  13319. */
  13320. autoClear: boolean;
  13321. /**
  13322. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13323. */
  13324. alphaMode: number;
  13325. /**
  13326. * Sets the setAlphaBlendConstants of the babylon engine
  13327. */
  13328. alphaConstants: Color4;
  13329. /**
  13330. * Animations to be used for the post processing
  13331. */
  13332. animations: Animation[];
  13333. /**
  13334. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13335. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13336. */
  13337. enablePixelPerfectMode: boolean;
  13338. /**
  13339. * Force the postprocess to be applied without taking in account viewport
  13340. */
  13341. forceFullscreenViewport: boolean;
  13342. /**
  13343. * List of inspectable custom properties (used by the Inspector)
  13344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13345. */
  13346. inspectableCustomProperties: IInspectable[];
  13347. /**
  13348. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13349. *
  13350. * | Value | Type | Description |
  13351. * | ----- | ----------------------------------- | ----------- |
  13352. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13353. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13354. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13355. *
  13356. */
  13357. scaleMode: number;
  13358. /**
  13359. * Force textures to be a power of two (default: false)
  13360. */
  13361. alwaysForcePOT: boolean;
  13362. private _samples;
  13363. /**
  13364. * Number of sample textures (default: 1)
  13365. */
  13366. samples: number;
  13367. /**
  13368. * Modify the scale of the post process to be the same as the viewport (default: false)
  13369. */
  13370. adaptScaleToCurrentViewport: boolean;
  13371. private _camera;
  13372. private _scene;
  13373. private _engine;
  13374. private _options;
  13375. private _reusable;
  13376. private _textureType;
  13377. /**
  13378. * Smart array of input and output textures for the post process.
  13379. * @hidden
  13380. */ textures: SmartArray<InternalTexture>;
  13381. /**
  13382. * The index in _textures that corresponds to the output texture.
  13383. * @hidden
  13384. */ currentRenderTextureInd: number;
  13385. private _effect;
  13386. private _samplers;
  13387. private _fragmentUrl;
  13388. private _vertexUrl;
  13389. private _parameters;
  13390. private _scaleRatio;
  13391. protected _indexParameters: any;
  13392. private _shareOutputWithPostProcess;
  13393. private _texelSize;
  13394. private _forcedOutputTexture;
  13395. /**
  13396. * Returns the fragment url or shader name used in the post process.
  13397. * @returns the fragment url or name in the shader store.
  13398. */
  13399. getEffectName(): string;
  13400. /**
  13401. * An event triggered when the postprocess is activated.
  13402. */
  13403. onActivateObservable: Observable<Camera>;
  13404. private _onActivateObserver;
  13405. /**
  13406. * A function that is added to the onActivateObservable
  13407. */
  13408. onActivate: Nullable<(camera: Camera) => void>;
  13409. /**
  13410. * An event triggered when the postprocess changes its size.
  13411. */
  13412. onSizeChangedObservable: Observable<PostProcess>;
  13413. private _onSizeChangedObserver;
  13414. /**
  13415. * A function that is added to the onSizeChangedObservable
  13416. */
  13417. onSizeChanged: (postProcess: PostProcess) => void;
  13418. /**
  13419. * An event triggered when the postprocess applies its effect.
  13420. */
  13421. onApplyObservable: Observable<Effect>;
  13422. private _onApplyObserver;
  13423. /**
  13424. * A function that is added to the onApplyObservable
  13425. */
  13426. onApply: (effect: Effect) => void;
  13427. /**
  13428. * An event triggered before rendering the postprocess
  13429. */
  13430. onBeforeRenderObservable: Observable<Effect>;
  13431. private _onBeforeRenderObserver;
  13432. /**
  13433. * A function that is added to the onBeforeRenderObservable
  13434. */
  13435. onBeforeRender: (effect: Effect) => void;
  13436. /**
  13437. * An event triggered after rendering the postprocess
  13438. */
  13439. onAfterRenderObservable: Observable<Effect>;
  13440. private _onAfterRenderObserver;
  13441. /**
  13442. * A function that is added to the onAfterRenderObservable
  13443. */
  13444. onAfterRender: (efect: Effect) => void;
  13445. /**
  13446. * 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
  13447. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13448. */
  13449. inputTexture: InternalTexture;
  13450. /**
  13451. * Gets the camera which post process is applied to.
  13452. * @returns The camera the post process is applied to.
  13453. */
  13454. getCamera(): Camera;
  13455. /**
  13456. * Gets the texel size of the postprocess.
  13457. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13458. */
  13459. readonly texelSize: Vector2;
  13460. /**
  13461. * Creates a new instance PostProcess
  13462. * @param name The name of the PostProcess.
  13463. * @param fragmentUrl The url of the fragment shader to be used.
  13464. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13465. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13466. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13467. * @param camera The camera to apply the render pass to.
  13468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13469. * @param engine The engine which the post process will be applied. (default: current engine)
  13470. * @param reusable If the post process can be reused on the same frame. (default: false)
  13471. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13472. * @param textureType Type of textures used when performing the post process. (default: 0)
  13473. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13474. * @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
  13475. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13476. */
  13477. constructor(
  13478. /** Name of the PostProcess. */
  13479. 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);
  13480. /**
  13481. * Gets a string idenfifying the name of the class
  13482. * @returns "PostProcess" string
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Gets the engine which this post process belongs to.
  13487. * @returns The engine the post process was enabled with.
  13488. */
  13489. getEngine(): Engine;
  13490. /**
  13491. * The effect that is created when initializing the post process.
  13492. * @returns The created effect corrisponding the the postprocess.
  13493. */
  13494. getEffect(): Effect;
  13495. /**
  13496. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13497. * @param postProcess The post process to share the output with.
  13498. * @returns This post process.
  13499. */
  13500. shareOutputWith(postProcess: PostProcess): PostProcess;
  13501. /**
  13502. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13503. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13504. */
  13505. useOwnOutput(): void;
  13506. /**
  13507. * Updates the effect with the current post process compile time values and recompiles the shader.
  13508. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13509. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13510. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13511. * @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
  13512. * @param onCompiled Called when the shader has been compiled.
  13513. * @param onError Called if there is an error when compiling a shader.
  13514. */
  13515. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13516. /**
  13517. * The post process is reusable if it can be used multiple times within one frame.
  13518. * @returns If the post process is reusable
  13519. */
  13520. isReusable(): boolean;
  13521. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13522. markTextureDirty(): void;
  13523. /**
  13524. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13525. * 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.
  13526. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13527. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13528. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13529. * @returns The target texture that was bound to be written to.
  13530. */
  13531. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13532. /**
  13533. * If the post process is supported.
  13534. */
  13535. readonly isSupported: boolean;
  13536. /**
  13537. * The aspect ratio of the output texture.
  13538. */
  13539. readonly aspectRatio: number;
  13540. /**
  13541. * Get a value indicating if the post-process is ready to be used
  13542. * @returns true if the post-process is ready (shader is compiled)
  13543. */
  13544. isReady(): boolean;
  13545. /**
  13546. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13547. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13548. */
  13549. apply(): Nullable<Effect>;
  13550. private _disposeTextures;
  13551. /**
  13552. * Disposes the post process.
  13553. * @param camera The camera to dispose the post process on.
  13554. */
  13555. dispose(camera?: Camera): void;
  13556. }
  13557. }
  13558. declare module BABYLON {
  13559. /**
  13560. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13561. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13562. */
  13563. export class PostProcessManager {
  13564. private _scene;
  13565. private _indexBuffer;
  13566. private _vertexBuffers;
  13567. /**
  13568. * Creates a new instance PostProcess
  13569. * @param scene The scene that the post process is associated with.
  13570. */
  13571. constructor(scene: Scene);
  13572. private _prepareBuffers;
  13573. private _buildIndexBuffer;
  13574. /**
  13575. * Rebuilds the vertex buffers of the manager.
  13576. * @hidden
  13577. */ rebuild(): void;
  13578. /**
  13579. * Prepares a frame to be run through a post process.
  13580. * @param sourceTexture The input texture to the post procesess. (default: null)
  13581. * @param postProcesses An array of post processes to be run. (default: null)
  13582. * @returns True if the post processes were able to be run.
  13583. * @hidden
  13584. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13585. /**
  13586. * Manually render a set of post processes to a texture.
  13587. * @param postProcesses An array of post processes to be run.
  13588. * @param targetTexture The target texture to render to.
  13589. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13590. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13591. * @param lodLevel defines which lod of the texture to render to
  13592. */
  13593. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13594. /**
  13595. * Finalize the result of the output of the postprocesses.
  13596. * @param doNotPresent If true the result will not be displayed to the screen.
  13597. * @param targetTexture The target texture to render to.
  13598. * @param faceIndex The index of the face to bind the target texture to.
  13599. * @param postProcesses The array of post processes to render.
  13600. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13601. * @hidden
  13602. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13603. /**
  13604. * Disposes of the post process manager.
  13605. */
  13606. dispose(): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. interface AbstractScene {
  13611. /**
  13612. * The list of layers (background and foreground) of the scene
  13613. */
  13614. layers: Array<Layer>;
  13615. }
  13616. /**
  13617. * Defines the layer scene component responsible to manage any layers
  13618. * in a given scene.
  13619. */
  13620. export class LayerSceneComponent implements ISceneComponent {
  13621. /**
  13622. * The component name helpfull to identify the component in the list of scene components.
  13623. */
  13624. readonly name: string;
  13625. /**
  13626. * The scene the component belongs to.
  13627. */
  13628. scene: Scene;
  13629. private _engine;
  13630. /**
  13631. * Creates a new instance of the component for the given scene
  13632. * @param scene Defines the scene to register the component in
  13633. */
  13634. constructor(scene: Scene);
  13635. /**
  13636. * Registers the component in a given scene
  13637. */
  13638. register(): void;
  13639. /**
  13640. * Rebuilds the elements related to this component in case of
  13641. * context lost for instance.
  13642. */
  13643. rebuild(): void;
  13644. /**
  13645. * Disposes the component and the associated ressources.
  13646. */
  13647. dispose(): void;
  13648. private _draw;
  13649. private _drawCameraPredicate;
  13650. private _drawCameraBackground;
  13651. private _drawCameraForeground;
  13652. private _drawRenderTargetPredicate;
  13653. private _drawRenderTargetBackground;
  13654. private _drawRenderTargetForeground;
  13655. }
  13656. }
  13657. declare module BABYLON {
  13658. /** @hidden */
  13659. export var layerPixelShader: {
  13660. name: string;
  13661. shader: string;
  13662. };
  13663. }
  13664. declare module BABYLON {
  13665. /** @hidden */
  13666. export var layerVertexShader: {
  13667. name: string;
  13668. shader: string;
  13669. };
  13670. }
  13671. declare module BABYLON {
  13672. /**
  13673. * This represents a full screen 2d layer.
  13674. * This can be useful to display a picture in the background of your scene for instance.
  13675. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13676. */
  13677. export class Layer {
  13678. /**
  13679. * Define the name of the layer.
  13680. */
  13681. name: string;
  13682. /**
  13683. * Define the texture the layer should display.
  13684. */
  13685. texture: Nullable<Texture>;
  13686. /**
  13687. * Is the layer in background or foreground.
  13688. */
  13689. isBackground: boolean;
  13690. /**
  13691. * Define the color of the layer (instead of texture).
  13692. */
  13693. color: Color4;
  13694. /**
  13695. * Define the scale of the layer in order to zoom in out of the texture.
  13696. */
  13697. scale: Vector2;
  13698. /**
  13699. * Define an offset for the layer in order to shift the texture.
  13700. */
  13701. offset: Vector2;
  13702. /**
  13703. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13704. */
  13705. alphaBlendingMode: number;
  13706. /**
  13707. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13708. * Alpha test will not mix with the background color in case of transparency.
  13709. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13710. */
  13711. alphaTest: boolean;
  13712. /**
  13713. * Define a mask to restrict the layer to only some of the scene cameras.
  13714. */
  13715. layerMask: number;
  13716. /**
  13717. * Define the list of render target the layer is visible into.
  13718. */
  13719. renderTargetTextures: RenderTargetTexture[];
  13720. /**
  13721. * Define if the layer is only used in renderTarget or if it also
  13722. * renders in the main frame buffer of the canvas.
  13723. */
  13724. renderOnlyInRenderTargetTextures: boolean;
  13725. private _scene;
  13726. private _vertexBuffers;
  13727. private _indexBuffer;
  13728. private _effect;
  13729. private _alphaTestEffect;
  13730. /**
  13731. * An event triggered when the layer is disposed.
  13732. */
  13733. onDisposeObservable: Observable<Layer>;
  13734. private _onDisposeObserver;
  13735. /**
  13736. * Back compatibility with callback before the onDisposeObservable existed.
  13737. * The set callback will be triggered when the layer has been disposed.
  13738. */
  13739. onDispose: () => void;
  13740. /**
  13741. * An event triggered before rendering the scene
  13742. */
  13743. onBeforeRenderObservable: Observable<Layer>;
  13744. private _onBeforeRenderObserver;
  13745. /**
  13746. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13747. * The set callback will be triggered just before rendering the layer.
  13748. */
  13749. onBeforeRender: () => void;
  13750. /**
  13751. * An event triggered after rendering the scene
  13752. */
  13753. onAfterRenderObservable: Observable<Layer>;
  13754. private _onAfterRenderObserver;
  13755. /**
  13756. * Back compatibility with callback before the onAfterRenderObservable existed.
  13757. * The set callback will be triggered just after rendering the layer.
  13758. */
  13759. onAfterRender: () => void;
  13760. /**
  13761. * Instantiates a new layer.
  13762. * This represents a full screen 2d layer.
  13763. * This can be useful to display a picture in the background of your scene for instance.
  13764. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13765. * @param name Define the name of the layer in the scene
  13766. * @param imgUrl Define the url of the texture to display in the layer
  13767. * @param scene Define the scene the layer belongs to
  13768. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13769. * @param color Defines a color for the layer
  13770. */
  13771. constructor(
  13772. /**
  13773. * Define the name of the layer.
  13774. */
  13775. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13776. private _createIndexBuffer;
  13777. /** @hidden */ rebuild(): void;
  13778. /**
  13779. * Renders the layer in the scene.
  13780. */
  13781. render(): void;
  13782. /**
  13783. * Disposes and releases the associated ressources.
  13784. */
  13785. dispose(): void;
  13786. }
  13787. }
  13788. declare module BABYLON {
  13789. interface AbstractScene {
  13790. /**
  13791. * The list of procedural textures added to the scene
  13792. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13793. */
  13794. proceduralTextures: Array<ProceduralTexture>;
  13795. }
  13796. /**
  13797. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13798. * in a given scene.
  13799. */
  13800. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13801. /**
  13802. * The component name helpfull to identify the component in the list of scene components.
  13803. */
  13804. readonly name: string;
  13805. /**
  13806. * The scene the component belongs to.
  13807. */
  13808. scene: Scene;
  13809. /**
  13810. * Creates a new instance of the component for the given scene
  13811. * @param scene Defines the scene to register the component in
  13812. */
  13813. constructor(scene: Scene);
  13814. /**
  13815. * Registers the component in a given scene
  13816. */
  13817. register(): void;
  13818. /**
  13819. * Rebuilds the elements related to this component in case of
  13820. * context lost for instance.
  13821. */
  13822. rebuild(): void;
  13823. /**
  13824. * Disposes the component and the associated ressources.
  13825. */
  13826. dispose(): void;
  13827. private _beforeClear;
  13828. }
  13829. }
  13830. declare module BABYLON {
  13831. interface Engine {
  13832. /**
  13833. * Creates a new render target cube texture
  13834. * @param size defines the size of the texture
  13835. * @param options defines the options used to create the texture
  13836. * @returns a new render target cube texture stored in an InternalTexture
  13837. */
  13838. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13839. }
  13840. }
  13841. declare module BABYLON {
  13842. /** @hidden */
  13843. export var proceduralVertexShader: {
  13844. name: string;
  13845. shader: string;
  13846. };
  13847. }
  13848. declare module BABYLON {
  13849. /**
  13850. * 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.
  13851. * This is the base class of any Procedural texture and contains most of the shareable code.
  13852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13853. */
  13854. export class ProceduralTexture extends Texture {
  13855. isCube: boolean;
  13856. /**
  13857. * Define if the texture is enabled or not (disabled texture will not render)
  13858. */
  13859. isEnabled: boolean;
  13860. /**
  13861. * Define if the texture must be cleared before rendering (default is true)
  13862. */
  13863. autoClear: boolean;
  13864. /**
  13865. * Callback called when the texture is generated
  13866. */
  13867. onGenerated: () => void;
  13868. /**
  13869. * Event raised when the texture is generated
  13870. */
  13871. onGeneratedObservable: Observable<ProceduralTexture>;
  13872. /** @hidden */ generateMipMaps: boolean;
  13873. /** @hidden **/ effect: Effect;
  13874. /** @hidden */ textures: {
  13875. [key: string]: Texture;
  13876. };
  13877. private _size;
  13878. private _currentRefreshId;
  13879. private _refreshRate;
  13880. private _vertexBuffers;
  13881. private _indexBuffer;
  13882. private _uniforms;
  13883. private _samplers;
  13884. private _fragment;
  13885. private _floats;
  13886. private _ints;
  13887. private _floatsArrays;
  13888. private _colors3;
  13889. private _colors4;
  13890. private _vectors2;
  13891. private _vectors3;
  13892. private _matrices;
  13893. private _fallbackTexture;
  13894. private _fallbackTextureUsed;
  13895. private _engine;
  13896. private _cachedDefines;
  13897. private _contentUpdateId;
  13898. private _contentData;
  13899. /**
  13900. * Instantiates a new procedural texture.
  13901. * 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.
  13902. * This is the base class of any Procedural texture and contains most of the shareable code.
  13903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13904. * @param name Define the name of the texture
  13905. * @param size Define the size of the texture to create
  13906. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13907. * @param scene Define the scene the texture belongs to
  13908. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13909. * @param generateMipMaps Define if the texture should creates mip maps or not
  13910. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13911. */
  13912. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13913. /**
  13914. * The effect that is created when initializing the post process.
  13915. * @returns The created effect corrisponding the the postprocess.
  13916. */
  13917. getEffect(): Effect;
  13918. /**
  13919. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13920. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13921. */
  13922. getContent(): Nullable<ArrayBufferView>;
  13923. private _createIndexBuffer;
  13924. /** @hidden */ rebuild(): void;
  13925. /**
  13926. * Resets the texture in order to recreate its associated resources.
  13927. * This can be called in case of context loss
  13928. */
  13929. reset(): void;
  13930. protected _getDefines(): string;
  13931. /**
  13932. * Is the texture ready to be used ? (rendered at least once)
  13933. * @returns true if ready, otherwise, false.
  13934. */
  13935. isReady(): boolean;
  13936. /**
  13937. * Resets the refresh counter of the texture and start bak from scratch.
  13938. * Could be useful to regenerate the texture if it is setup to render only once.
  13939. */
  13940. resetRefreshCounter(): void;
  13941. /**
  13942. * Set the fragment shader to use in order to render the texture.
  13943. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13944. */
  13945. setFragment(fragment: any): void;
  13946. /**
  13947. * Define the refresh rate of the texture or the rendering frequency.
  13948. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13949. */
  13950. refreshRate: number;
  13951. /** @hidden */ shouldRender(): boolean;
  13952. /**
  13953. * Get the size the texture is rendering at.
  13954. * @returns the size (texture is always squared)
  13955. */
  13956. getRenderSize(): number;
  13957. /**
  13958. * Resize the texture to new value.
  13959. * @param size Define the new size the texture should have
  13960. * @param generateMipMaps Define whether the new texture should create mip maps
  13961. */
  13962. resize(size: number, generateMipMaps: boolean): void;
  13963. private _checkUniform;
  13964. /**
  13965. * Set a texture in the shader program used to render.
  13966. * @param name Define the name of the uniform samplers as defined in the shader
  13967. * @param texture Define the texture to bind to this sampler
  13968. * @return the texture itself allowing "fluent" like uniform updates
  13969. */
  13970. setTexture(name: string, texture: Texture): ProceduralTexture;
  13971. /**
  13972. * Set a float in the shader.
  13973. * @param name Define the name of the uniform as defined in the shader
  13974. * @param value Define the value to give to the uniform
  13975. * @return the texture itself allowing "fluent" like uniform updates
  13976. */
  13977. setFloat(name: string, value: number): ProceduralTexture;
  13978. /**
  13979. * Set a int in the shader.
  13980. * @param name Define the name of the uniform as defined in the shader
  13981. * @param value Define the value to give to the uniform
  13982. * @return the texture itself allowing "fluent" like uniform updates
  13983. */
  13984. setInt(name: string, value: number): ProceduralTexture;
  13985. /**
  13986. * Set an array of floats in the shader.
  13987. * @param name Define the name of the uniform as defined in the shader
  13988. * @param value Define the value to give to the uniform
  13989. * @return the texture itself allowing "fluent" like uniform updates
  13990. */
  13991. setFloats(name: string, value: number[]): ProceduralTexture;
  13992. /**
  13993. * Set a vec3 in the shader from a Color3.
  13994. * @param name Define the name of the uniform as defined in the shader
  13995. * @param value Define the value to give to the uniform
  13996. * @return the texture itself allowing "fluent" like uniform updates
  13997. */
  13998. setColor3(name: string, value: Color3): ProceduralTexture;
  13999. /**
  14000. * Set a vec4 in the shader from a Color4.
  14001. * @param name Define the name of the uniform as defined in the shader
  14002. * @param value Define the value to give to the uniform
  14003. * @return the texture itself allowing "fluent" like uniform updates
  14004. */
  14005. setColor4(name: string, value: Color4): ProceduralTexture;
  14006. /**
  14007. * Set a vec2 in the shader from a Vector2.
  14008. * @param name Define the name of the uniform as defined in the shader
  14009. * @param value Define the value to give to the uniform
  14010. * @return the texture itself allowing "fluent" like uniform updates
  14011. */
  14012. setVector2(name: string, value: Vector2): ProceduralTexture;
  14013. /**
  14014. * Set a vec3 in the shader from a Vector3.
  14015. * @param name Define the name of the uniform as defined in the shader
  14016. * @param value Define the value to give to the uniform
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setVector3(name: string, value: Vector3): ProceduralTexture;
  14020. /**
  14021. * Set a mat4 in the shader from a MAtrix.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14027. /**
  14028. * Render the texture to its associated render target.
  14029. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14030. */
  14031. render(useCameraPostProcess?: boolean): void;
  14032. /**
  14033. * Clone the texture.
  14034. * @returns the cloned texture
  14035. */
  14036. clone(): ProceduralTexture;
  14037. /**
  14038. * Dispose the texture and release its asoociated resources.
  14039. */
  14040. dispose(): void;
  14041. }
  14042. }
  14043. declare module BABYLON {
  14044. /**
  14045. * This represents the base class for particle system in Babylon.
  14046. * 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.
  14047. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14048. * @example https://doc.babylonjs.com/babylon101/particles
  14049. */
  14050. export class BaseParticleSystem {
  14051. /**
  14052. * Source color is added to the destination color without alpha affecting the result
  14053. */
  14054. static BLENDMODE_ONEONE: number;
  14055. /**
  14056. * Blend current color and particle color using particle’s alpha
  14057. */
  14058. static BLENDMODE_STANDARD: number;
  14059. /**
  14060. * Add current color and particle color multiplied by particle’s alpha
  14061. */
  14062. static BLENDMODE_ADD: number;
  14063. /**
  14064. * Multiply current color with particle color
  14065. */
  14066. static BLENDMODE_MULTIPLY: number;
  14067. /**
  14068. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14069. */
  14070. static BLENDMODE_MULTIPLYADD: number;
  14071. /**
  14072. * List of animations used by the particle system.
  14073. */
  14074. animations: Animation[];
  14075. /**
  14076. * The id of the Particle system.
  14077. */
  14078. id: string;
  14079. /**
  14080. * The friendly name of the Particle system.
  14081. */
  14082. name: string;
  14083. /**
  14084. * The rendering group used by the Particle system to chose when to render.
  14085. */
  14086. renderingGroupId: number;
  14087. /**
  14088. * The emitter represents the Mesh or position we are attaching the particle system to.
  14089. */
  14090. emitter: Nullable<AbstractMesh | Vector3>;
  14091. /**
  14092. * The maximum number of particles to emit per frame
  14093. */
  14094. emitRate: number;
  14095. /**
  14096. * If you want to launch only a few particles at once, that can be done, as well.
  14097. */
  14098. manualEmitCount: number;
  14099. /**
  14100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14101. */
  14102. updateSpeed: number;
  14103. /**
  14104. * The amount of time the particle system is running (depends of the overall update speed).
  14105. */
  14106. targetStopDuration: number;
  14107. /**
  14108. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14109. */
  14110. disposeOnStop: boolean;
  14111. /**
  14112. * Minimum power of emitting particles.
  14113. */
  14114. minEmitPower: number;
  14115. /**
  14116. * Maximum power of emitting particles.
  14117. */
  14118. maxEmitPower: number;
  14119. /**
  14120. * Minimum life time of emitting particles.
  14121. */
  14122. minLifeTime: number;
  14123. /**
  14124. * Maximum life time of emitting particles.
  14125. */
  14126. maxLifeTime: number;
  14127. /**
  14128. * Minimum Size of emitting particles.
  14129. */
  14130. minSize: number;
  14131. /**
  14132. * Maximum Size of emitting particles.
  14133. */
  14134. maxSize: number;
  14135. /**
  14136. * Minimum scale of emitting particles on X axis.
  14137. */
  14138. minScaleX: number;
  14139. /**
  14140. * Maximum scale of emitting particles on X axis.
  14141. */
  14142. maxScaleX: number;
  14143. /**
  14144. * Minimum scale of emitting particles on Y axis.
  14145. */
  14146. minScaleY: number;
  14147. /**
  14148. * Maximum scale of emitting particles on Y axis.
  14149. */
  14150. maxScaleY: number;
  14151. /**
  14152. * Gets or sets the minimal initial rotation in radians.
  14153. */
  14154. minInitialRotation: number;
  14155. /**
  14156. * Gets or sets the maximal initial rotation in radians.
  14157. */
  14158. maxInitialRotation: number;
  14159. /**
  14160. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14161. */
  14162. minAngularSpeed: number;
  14163. /**
  14164. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14165. */
  14166. maxAngularSpeed: number;
  14167. /**
  14168. * The texture used to render each particle. (this can be a spritesheet)
  14169. */
  14170. particleTexture: Nullable<Texture>;
  14171. /**
  14172. * The layer mask we are rendering the particles through.
  14173. */
  14174. layerMask: number;
  14175. /**
  14176. * This can help using your own shader to render the particle system.
  14177. * The according effect will be created
  14178. */
  14179. customShader: any;
  14180. /**
  14181. * By default particle system starts as soon as they are created. This prevents the
  14182. * automatic start to happen and let you decide when to start emitting particles.
  14183. */
  14184. preventAutoStart: boolean;
  14185. private _noiseTexture;
  14186. /**
  14187. * Gets or sets a texture used to add random noise to particle positions
  14188. */
  14189. noiseTexture: Nullable<ProceduralTexture>;
  14190. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14191. noiseStrength: Vector3;
  14192. /**
  14193. * Callback triggered when the particle animation is ending.
  14194. */
  14195. onAnimationEnd: Nullable<() => void>;
  14196. /**
  14197. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14198. */
  14199. blendMode: number;
  14200. /**
  14201. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14202. * to override the particles.
  14203. */
  14204. forceDepthWrite: boolean;
  14205. /** 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 */
  14206. preWarmCycles: number;
  14207. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14208. preWarmStepOffset: number;
  14209. /**
  14210. * 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)
  14211. */
  14212. spriteCellChangeSpeed: number;
  14213. /**
  14214. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14215. */
  14216. startSpriteCellID: number;
  14217. /**
  14218. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14219. */
  14220. endSpriteCellID: number;
  14221. /**
  14222. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14223. */
  14224. spriteCellWidth: number;
  14225. /**
  14226. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14227. */
  14228. spriteCellHeight: number;
  14229. /**
  14230. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14231. */
  14232. spriteRandomStartCell: boolean;
  14233. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14234. translationPivot: Vector2;
  14235. /** @hidden */
  14236. protected _isAnimationSheetEnabled: boolean;
  14237. /**
  14238. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14239. */
  14240. beginAnimationOnStart: boolean;
  14241. /**
  14242. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14243. */
  14244. beginAnimationFrom: number;
  14245. /**
  14246. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14247. */
  14248. beginAnimationTo: number;
  14249. /**
  14250. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14251. */
  14252. beginAnimationLoop: boolean;
  14253. /**
  14254. * Gets or sets a world offset applied to all particles
  14255. */
  14256. worldOffset: Vector3;
  14257. /**
  14258. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14259. */
  14260. isAnimationSheetEnabled: boolean;
  14261. /**
  14262. * Get hosting scene
  14263. * @returns the scene
  14264. */
  14265. getScene(): Scene;
  14266. /**
  14267. * You can use gravity if you want to give an orientation to your particles.
  14268. */
  14269. gravity: Vector3;
  14270. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14271. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14272. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14273. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14274. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14275. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14276. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14277. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14278. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14279. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14280. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14281. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14282. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14283. /**
  14284. * Defines the delay in milliseconds before starting the system (0 by default)
  14285. */
  14286. startDelay: number;
  14287. /**
  14288. * Gets the current list of drag gradients.
  14289. * You must use addDragGradient and removeDragGradient to udpate this list
  14290. * @returns the list of drag gradients
  14291. */
  14292. getDragGradients(): Nullable<Array<FactorGradient>>;
  14293. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14294. limitVelocityDamping: number;
  14295. /**
  14296. * Gets the current list of limit velocity gradients.
  14297. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14298. * @returns the list of limit velocity gradients
  14299. */
  14300. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14301. /**
  14302. * Gets the current list of color gradients.
  14303. * You must use addColorGradient and removeColorGradient to udpate this list
  14304. * @returns the list of color gradients
  14305. */
  14306. getColorGradients(): Nullable<Array<ColorGradient>>;
  14307. /**
  14308. * Gets the current list of size gradients.
  14309. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14310. * @returns the list of size gradients
  14311. */
  14312. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14313. /**
  14314. * Gets the current list of color remap gradients.
  14315. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14316. * @returns the list of color remap gradients
  14317. */
  14318. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14319. /**
  14320. * Gets the current list of alpha remap gradients.
  14321. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14322. * @returns the list of alpha remap gradients
  14323. */
  14324. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Gets the current list of life time gradients.
  14327. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14328. * @returns the list of life time gradients
  14329. */
  14330. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Gets the current list of angular speed gradients.
  14333. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14334. * @returns the list of angular speed gradients
  14335. */
  14336. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14337. /**
  14338. * Gets the current list of velocity gradients.
  14339. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14340. * @returns the list of velocity gradients
  14341. */
  14342. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Gets the current list of start size gradients.
  14345. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14346. * @returns the list of start size gradients
  14347. */
  14348. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14349. /**
  14350. * Gets the current list of emit rate gradients.
  14351. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14352. * @returns the list of emit rate gradients
  14353. */
  14354. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14355. /**
  14356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14357. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14358. */
  14359. direction1: Vector3;
  14360. /**
  14361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14362. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14363. */
  14364. direction2: Vector3;
  14365. /**
  14366. * 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.
  14367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14368. */
  14369. minEmitBox: Vector3;
  14370. /**
  14371. * 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.
  14372. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14373. */
  14374. maxEmitBox: Vector3;
  14375. /**
  14376. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14377. */
  14378. color1: Color4;
  14379. /**
  14380. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14381. */
  14382. color2: Color4;
  14383. /**
  14384. * Color the particle will have at the end of its lifetime
  14385. */
  14386. colorDead: Color4;
  14387. /**
  14388. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14389. */
  14390. textureMask: Color4;
  14391. /**
  14392. * The particle emitter type defines the emitter used by the particle system.
  14393. * It can be for example box, sphere, or cone...
  14394. */
  14395. particleEmitterType: IParticleEmitterType;
  14396. /** @hidden */ isSubEmitter: boolean;
  14397. /**
  14398. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14399. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14400. */
  14401. billboardMode: number;
  14402. protected _isBillboardBased: boolean;
  14403. /**
  14404. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14405. */
  14406. isBillboardBased: boolean;
  14407. /**
  14408. * The scene the particle system belongs to.
  14409. */
  14410. protected _scene: Scene;
  14411. /**
  14412. * Local cache of defines for image processing.
  14413. */
  14414. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14415. /**
  14416. * Default configuration related to image processing available in the standard Material.
  14417. */
  14418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14419. /**
  14420. * Gets the image processing configuration used either in this material.
  14421. */
  14422. /**
  14423. * Sets the Default image processing configuration used either in the this material.
  14424. *
  14425. * If sets to null, the scene one is in use.
  14426. */
  14427. imageProcessingConfiguration: ImageProcessingConfiguration;
  14428. /**
  14429. * Attaches a new image processing configuration to the Standard Material.
  14430. * @param configuration
  14431. */
  14432. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14433. /** @hidden */
  14434. protected _reset(): void;
  14435. /** @hidden */
  14436. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14437. /**
  14438. * Instantiates a particle system.
  14439. * 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.
  14440. * @param name The name of the particle system
  14441. */
  14442. constructor(name: string);
  14443. /**
  14444. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @returns the emitter
  14448. */
  14449. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14450. /**
  14451. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14452. * @param radius The radius of the hemisphere to emit from
  14453. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14454. * @returns the emitter
  14455. */
  14456. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14457. /**
  14458. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14459. * @param radius The radius of the sphere to emit from
  14460. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14461. * @returns the emitter
  14462. */
  14463. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14464. /**
  14465. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14466. * @param radius The radius of the sphere to emit from
  14467. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @returns the emitter
  14470. */
  14471. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14472. /**
  14473. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14474. * @param radius The radius of the emission cylinder
  14475. * @param height The height of the emission cylinder
  14476. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14477. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14478. * @returns the emitter
  14479. */
  14480. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14481. /**
  14482. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14483. * @param radius The radius of the cylinder to emit from
  14484. * @param height The height of the emission cylinder
  14485. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @returns the emitter
  14489. */
  14490. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14491. /**
  14492. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14493. * @param radius The radius of the cone to emit from
  14494. * @param angle The base angle of the cone
  14495. * @returns the emitter
  14496. */
  14497. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14498. /**
  14499. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14500. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @returns the emitter
  14505. */
  14506. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14507. }
  14508. }
  14509. declare module BABYLON {
  14510. /**
  14511. * Type of sub emitter
  14512. */
  14513. export enum SubEmitterType {
  14514. /**
  14515. * Attached to the particle over it's lifetime
  14516. */
  14517. ATTACHED = 0,
  14518. /**
  14519. * Created when the particle dies
  14520. */
  14521. END = 1
  14522. }
  14523. /**
  14524. * Sub emitter class used to emit particles from an existing particle
  14525. */
  14526. export class SubEmitter {
  14527. /**
  14528. * the particle system to be used by the sub emitter
  14529. */
  14530. particleSystem: ParticleSystem;
  14531. /**
  14532. * Type of the submitter (Default: END)
  14533. */
  14534. type: SubEmitterType;
  14535. /**
  14536. * 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)
  14537. * Note: This only is supported when using an emitter of type Mesh
  14538. */
  14539. inheritDirection: boolean;
  14540. /**
  14541. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14542. */
  14543. inheritedVelocityAmount: number;
  14544. /**
  14545. * Creates a sub emitter
  14546. * @param particleSystem the particle system to be used by the sub emitter
  14547. */
  14548. constructor(
  14549. /**
  14550. * the particle system to be used by the sub emitter
  14551. */
  14552. particleSystem: ParticleSystem);
  14553. /**
  14554. * Clones the sub emitter
  14555. * @returns the cloned sub emitter
  14556. */
  14557. clone(): SubEmitter;
  14558. /**
  14559. * Serialize current object to a JSON object
  14560. * @returns the serialized object
  14561. */
  14562. serialize(): any;
  14563. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14564. /**
  14565. * Creates a new SubEmitter from a serialized JSON version
  14566. * @param serializationObject defines the JSON object to read from
  14567. * @param scene defines the hosting scene
  14568. * @param rootUrl defines the rootUrl for data loading
  14569. * @returns a new SubEmitter
  14570. */
  14571. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14572. /** Release associated resources */
  14573. dispose(): void;
  14574. }
  14575. }
  14576. declare module BABYLON {
  14577. /** @hidden */
  14578. export var clipPlaneFragmentDeclaration: {
  14579. name: string;
  14580. shader: string;
  14581. };
  14582. }
  14583. declare module BABYLON {
  14584. /** @hidden */
  14585. export var imageProcessingDeclaration: {
  14586. name: string;
  14587. shader: string;
  14588. };
  14589. }
  14590. declare module BABYLON {
  14591. /** @hidden */
  14592. export var imageProcessingFunctions: {
  14593. name: string;
  14594. shader: string;
  14595. };
  14596. }
  14597. declare module BABYLON {
  14598. /** @hidden */
  14599. export var clipPlaneFragment: {
  14600. name: string;
  14601. shader: string;
  14602. };
  14603. }
  14604. declare module BABYLON {
  14605. /** @hidden */
  14606. export var particlesPixelShader: {
  14607. name: string;
  14608. shader: string;
  14609. };
  14610. }
  14611. declare module BABYLON {
  14612. /** @hidden */
  14613. export var clipPlaneVertexDeclaration: {
  14614. name: string;
  14615. shader: string;
  14616. };
  14617. }
  14618. declare module BABYLON {
  14619. /** @hidden */
  14620. export var clipPlaneVertex: {
  14621. name: string;
  14622. shader: string;
  14623. };
  14624. }
  14625. declare module BABYLON {
  14626. /** @hidden */
  14627. export var particlesVertexShader: {
  14628. name: string;
  14629. shader: string;
  14630. };
  14631. }
  14632. declare module BABYLON {
  14633. /**
  14634. * This represents a particle system in Babylon.
  14635. * 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.
  14636. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14637. * @example https://doc.babylonjs.com/babylon101/particles
  14638. */
  14639. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14640. /**
  14641. * Billboard mode will only apply to Y axis
  14642. */
  14643. static readonly BILLBOARDMODE_Y: number;
  14644. /**
  14645. * Billboard mode will apply to all axes
  14646. */
  14647. static readonly BILLBOARDMODE_ALL: number;
  14648. /**
  14649. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14650. */
  14651. static readonly BILLBOARDMODE_STRETCHED: number;
  14652. /**
  14653. * This function can be defined to provide custom update for active particles.
  14654. * This function will be called instead of regular update (age, position, color, etc.).
  14655. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14656. */
  14657. updateFunction: (particles: Particle[]) => void;
  14658. private _emitterWorldMatrix;
  14659. /**
  14660. * This function can be defined to specify initial direction for every new particle.
  14661. * It by default use the emitterType defined function
  14662. */
  14663. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14664. /**
  14665. * This function can be defined to specify initial position for every new particle.
  14666. * It by default use the emitterType defined function
  14667. */
  14668. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14669. /**
  14670. * @hidden
  14671. */ inheritedVelocityOffset: Vector3;
  14672. /**
  14673. * An event triggered when the system is disposed
  14674. */
  14675. onDisposeObservable: Observable<ParticleSystem>;
  14676. private _onDisposeObserver;
  14677. /**
  14678. * Sets a callback that will be triggered when the system is disposed
  14679. */
  14680. onDispose: () => void;
  14681. private _particles;
  14682. private _epsilon;
  14683. private _capacity;
  14684. private _stockParticles;
  14685. private _newPartsExcess;
  14686. private _vertexData;
  14687. private _vertexBuffer;
  14688. private _vertexBuffers;
  14689. private _spriteBuffer;
  14690. private _indexBuffer;
  14691. private _effect;
  14692. private _customEffect;
  14693. private _cachedDefines;
  14694. private _scaledColorStep;
  14695. private _colorDiff;
  14696. private _scaledDirection;
  14697. private _scaledGravity;
  14698. private _currentRenderId;
  14699. private _alive;
  14700. private _useInstancing;
  14701. private _started;
  14702. private _stopped;
  14703. private _actualFrame;
  14704. private _scaledUpdateSpeed;
  14705. private _vertexBufferSize;
  14706. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14707. /** @hidden */ currentEmitRate1: number;
  14708. /** @hidden */ currentEmitRate2: number;
  14709. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14710. /** @hidden */ currentStartSize1: number;
  14711. /** @hidden */ currentStartSize2: number;
  14712. private readonly _rawTextureWidth;
  14713. private _rampGradientsTexture;
  14714. private _useRampGradients;
  14715. /** Gets or sets a boolean indicating that ramp gradients must be used
  14716. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14717. */
  14718. useRampGradients: boolean;
  14719. /**
  14720. * 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.
  14721. * 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: [])
  14722. */
  14723. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14724. private _subEmitters;
  14725. /**
  14726. * @hidden
  14727. * If the particle systems emitter should be disposed when the particle system is disposed
  14728. */ disposeEmitterOnDispose: boolean;
  14729. /**
  14730. * The current active Sub-systems, this property is used by the root particle system only.
  14731. */
  14732. activeSubSystems: Array<ParticleSystem>;
  14733. private _rootParticleSystem;
  14734. /**
  14735. * Gets the current list of active particles
  14736. */
  14737. readonly particles: Particle[];
  14738. /**
  14739. * Returns the string "ParticleSystem"
  14740. * @returns a string containing the class name
  14741. */
  14742. getClassName(): string;
  14743. /**
  14744. * Instantiates a particle system.
  14745. * 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.
  14746. * @param name The name of the particle system
  14747. * @param capacity The max number of particles alive at the same time
  14748. * @param scene The scene the particle system belongs to
  14749. * @param customEffect a custom effect used to change the way particles are rendered by default
  14750. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14751. * @param epsilon Offset used to render the particles
  14752. */
  14753. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14754. private _addFactorGradient;
  14755. private _removeFactorGradient;
  14756. /**
  14757. * Adds a new life time gradient
  14758. * @param gradient defines the gradient to use (between 0 and 1)
  14759. * @param factor defines the life time factor to affect to the specified gradient
  14760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14761. * @returns the current particle system
  14762. */
  14763. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14764. /**
  14765. * Remove a specific life time gradient
  14766. * @param gradient defines the gradient to remove
  14767. * @returns the current particle system
  14768. */
  14769. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14770. /**
  14771. * Adds a new size gradient
  14772. * @param gradient defines the gradient to use (between 0 and 1)
  14773. * @param factor defines the size factor to affect to the specified gradient
  14774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14775. * @returns the current particle system
  14776. */
  14777. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14778. /**
  14779. * Remove a specific size gradient
  14780. * @param gradient defines the gradient to remove
  14781. * @returns the current particle system
  14782. */
  14783. removeSizeGradient(gradient: number): IParticleSystem;
  14784. /**
  14785. * Adds a new color remap gradient
  14786. * @param gradient defines the gradient to use (between 0 and 1)
  14787. * @param min defines the color remap minimal range
  14788. * @param max defines the color remap maximal range
  14789. * @returns the current particle system
  14790. */
  14791. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14792. /**
  14793. * Remove a specific color remap gradient
  14794. * @param gradient defines the gradient to remove
  14795. * @returns the current particle system
  14796. */
  14797. removeColorRemapGradient(gradient: number): IParticleSystem;
  14798. /**
  14799. * Adds a new alpha remap gradient
  14800. * @param gradient defines the gradient to use (between 0 and 1)
  14801. * @param min defines the alpha remap minimal range
  14802. * @param max defines the alpha remap maximal range
  14803. * @returns the current particle system
  14804. */
  14805. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14806. /**
  14807. * Remove a specific alpha remap gradient
  14808. * @param gradient defines the gradient to remove
  14809. * @returns the current particle system
  14810. */
  14811. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14812. /**
  14813. * Adds a new angular speed gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the angular speed to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific angular speed gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Adds a new velocity gradient
  14828. * @param gradient defines the gradient to use (between 0 and 1)
  14829. * @param factor defines the velocity to affect to the specified gradient
  14830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14831. * @returns the current particle system
  14832. */
  14833. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14834. /**
  14835. * Remove a specific velocity gradient
  14836. * @param gradient defines the gradient to remove
  14837. * @returns the current particle system
  14838. */
  14839. removeVelocityGradient(gradient: number): IParticleSystem;
  14840. /**
  14841. * Adds a new limit velocity gradient
  14842. * @param gradient defines the gradient to use (between 0 and 1)
  14843. * @param factor defines the limit velocity value to affect to the specified gradient
  14844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14845. * @returns the current particle system
  14846. */
  14847. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14848. /**
  14849. * Remove a specific limit velocity gradient
  14850. * @param gradient defines the gradient to remove
  14851. * @returns the current particle system
  14852. */
  14853. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14854. /**
  14855. * Adds a new drag gradient
  14856. * @param gradient defines the gradient to use (between 0 and 1)
  14857. * @param factor defines the drag value to affect to the specified gradient
  14858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14859. * @returns the current particle system
  14860. */
  14861. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14862. /**
  14863. * Remove a specific drag gradient
  14864. * @param gradient defines the gradient to remove
  14865. * @returns the current particle system
  14866. */
  14867. removeDragGradient(gradient: number): IParticleSystem;
  14868. /**
  14869. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14870. * @param gradient defines the gradient to use (between 0 and 1)
  14871. * @param factor defines the emit rate value to affect to the specified gradient
  14872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14873. * @returns the current particle system
  14874. */
  14875. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14876. /**
  14877. * Remove a specific emit rate gradient
  14878. * @param gradient defines the gradient to remove
  14879. * @returns the current particle system
  14880. */
  14881. removeEmitRateGradient(gradient: number): IParticleSystem;
  14882. /**
  14883. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param factor defines the start size value to affect to the specified gradient
  14886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14887. * @returns the current particle system
  14888. */
  14889. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14890. /**
  14891. * Remove a specific start size gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeStartSizeGradient(gradient: number): IParticleSystem;
  14896. private _createRampGradientTexture;
  14897. /**
  14898. * Gets the current list of ramp gradients.
  14899. * You must use addRampGradient and removeRampGradient to udpate this list
  14900. * @returns the list of ramp gradients
  14901. */
  14902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14903. /**
  14904. * Adds a new ramp gradient used to remap particle colors
  14905. * @param gradient defines the gradient to use (between 0 and 1)
  14906. * @param color defines the color to affect to the specified gradient
  14907. * @returns the current particle system
  14908. */
  14909. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14910. /**
  14911. * Remove a specific ramp gradient
  14912. * @param gradient defines the gradient to remove
  14913. * @returns the current particle system
  14914. */
  14915. removeRampGradient(gradient: number): ParticleSystem;
  14916. /**
  14917. * Adds a new color gradient
  14918. * @param gradient defines the gradient to use (between 0 and 1)
  14919. * @param color1 defines the color to affect to the specified gradient
  14920. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14921. * @returns this particle system
  14922. */
  14923. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14924. /**
  14925. * Remove a specific color gradient
  14926. * @param gradient defines the gradient to remove
  14927. * @returns this particle system
  14928. */
  14929. removeColorGradient(gradient: number): IParticleSystem;
  14930. private _fetchR;
  14931. protected _reset(): void;
  14932. private _resetEffect;
  14933. private _createVertexBuffers;
  14934. private _createIndexBuffer;
  14935. /**
  14936. * Gets the maximum number of particles active at the same time.
  14937. * @returns The max number of active particles.
  14938. */
  14939. getCapacity(): number;
  14940. /**
  14941. * Gets whether there are still active particles in the system.
  14942. * @returns True if it is alive, otherwise false.
  14943. */
  14944. isAlive(): boolean;
  14945. /**
  14946. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14947. * @returns True if it has been started, otherwise false.
  14948. */
  14949. isStarted(): boolean;
  14950. private _prepareSubEmitterInternalArray;
  14951. /**
  14952. * Starts the particle system and begins to emit
  14953. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14954. */
  14955. start(delay?: number): void;
  14956. /**
  14957. * Stops the particle system.
  14958. * @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.
  14959. */
  14960. stop(stopSubEmitters?: boolean): void;
  14961. /**
  14962. * Remove all active particles
  14963. */
  14964. reset(): void;
  14965. /**
  14966. * @hidden (for internal use only)
  14967. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14968. /**
  14969. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14970. * Its lifetime will start back at 0.
  14971. */
  14972. recycleParticle: (particle: Particle) => void;
  14973. private _stopSubEmitters;
  14974. private _createParticle;
  14975. private _removeFromRoot;
  14976. private _emitFromParticle;
  14977. private _update;
  14978. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14979. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14980. /** @hidden */
  14981. private _getEffect;
  14982. /**
  14983. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14984. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14985. */
  14986. animate(preWarmOnly?: boolean): void;
  14987. private _appendParticleVertices;
  14988. /**
  14989. * Rebuilds the particle system.
  14990. */
  14991. rebuild(): void;
  14992. /**
  14993. * Is this system ready to be used/rendered
  14994. * @return true if the system is ready
  14995. */
  14996. isReady(): boolean;
  14997. private _render;
  14998. /**
  14999. * Renders the particle system in its current state.
  15000. * @returns the current number of particles
  15001. */
  15002. render(): number;
  15003. /**
  15004. * Disposes the particle system and free the associated resources
  15005. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15006. */
  15007. dispose(disposeTexture?: boolean): void;
  15008. /**
  15009. * Clones the particle system.
  15010. * @param name The name of the cloned object
  15011. * @param newEmitter The new emitter to use
  15012. * @returns the cloned particle system
  15013. */
  15014. clone(name: string, newEmitter: any): ParticleSystem;
  15015. /**
  15016. * Serializes the particle system to a JSON object.
  15017. * @returns the JSON object
  15018. */
  15019. serialize(): any;
  15020. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15021. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15022. /**
  15023. * Parses a JSON object to create a particle system.
  15024. * @param parsedParticleSystem The JSON object to parse
  15025. * @param scene The scene to create the particle system in
  15026. * @param rootUrl The root url to use to load external dependencies like texture
  15027. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15028. * @returns the Parsed particle system
  15029. */
  15030. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15031. }
  15032. }
  15033. declare module BABYLON {
  15034. /**
  15035. * A particle represents one of the element emitted by a particle system.
  15036. * This is mainly define by its coordinates, direction, velocity and age.
  15037. */
  15038. export class Particle {
  15039. /**
  15040. * The particle system the particle belongs to.
  15041. */
  15042. particleSystem: ParticleSystem;
  15043. private static _Count;
  15044. /**
  15045. * Unique ID of the particle
  15046. */
  15047. id: number;
  15048. /**
  15049. * The world position of the particle in the scene.
  15050. */
  15051. position: Vector3;
  15052. /**
  15053. * The world direction of the particle in the scene.
  15054. */
  15055. direction: Vector3;
  15056. /**
  15057. * The color of the particle.
  15058. */
  15059. color: Color4;
  15060. /**
  15061. * The color change of the particle per step.
  15062. */
  15063. colorStep: Color4;
  15064. /**
  15065. * Defines how long will the life of the particle be.
  15066. */
  15067. lifeTime: number;
  15068. /**
  15069. * The current age of the particle.
  15070. */
  15071. age: number;
  15072. /**
  15073. * The current size of the particle.
  15074. */
  15075. size: number;
  15076. /**
  15077. * The current scale of the particle.
  15078. */
  15079. scale: Vector2;
  15080. /**
  15081. * The current angle of the particle.
  15082. */
  15083. angle: number;
  15084. /**
  15085. * Defines how fast is the angle changing.
  15086. */
  15087. angularSpeed: number;
  15088. /**
  15089. * Defines the cell index used by the particle to be rendered from a sprite.
  15090. */
  15091. cellIndex: number;
  15092. /**
  15093. * The information required to support color remapping
  15094. */
  15095. remapData: Vector4;
  15096. /** @hidden */ randomCellOffset?: number;
  15097. /** @hidden */ initialDirection: Nullable<Vector3>;
  15098. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15099. /** @hidden */ initialStartSpriteCellID: number;
  15100. /** @hidden */ initialEndSpriteCellID: number;
  15101. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15102. /** @hidden */ currentColor1: Color4;
  15103. /** @hidden */ currentColor2: Color4;
  15104. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15105. /** @hidden */ currentSize1: number;
  15106. /** @hidden */ currentSize2: number;
  15107. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15108. /** @hidden */ currentAngularSpeed1: number;
  15109. /** @hidden */ currentAngularSpeed2: number;
  15110. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15111. /** @hidden */ currentVelocity1: number;
  15112. /** @hidden */ currentVelocity2: number;
  15113. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15114. /** @hidden */ currentLimitVelocity1: number;
  15115. /** @hidden */ currentLimitVelocity2: number;
  15116. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15117. /** @hidden */ currentDrag1: number;
  15118. /** @hidden */ currentDrag2: number;
  15119. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15120. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15121. /**
  15122. * Creates a new instance Particle
  15123. * @param particleSystem the particle system the particle belongs to
  15124. */
  15125. constructor(
  15126. /**
  15127. * The particle system the particle belongs to.
  15128. */
  15129. particleSystem: ParticleSystem);
  15130. private updateCellInfoFromSystem;
  15131. /**
  15132. * Defines how the sprite cell index is updated for the particle
  15133. */
  15134. updateCellIndex(): void;
  15135. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15136. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15137. /** @hidden */ reset(): void;
  15138. /**
  15139. * Copy the properties of particle to another one.
  15140. * @param other the particle to copy the information to.
  15141. */
  15142. copyTo(other: Particle): void;
  15143. }
  15144. }
  15145. declare module BABYLON {
  15146. /**
  15147. * Particle emitter represents a volume emitting particles.
  15148. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15149. */
  15150. export interface IParticleEmitterType {
  15151. /**
  15152. * Called by the particle System when the direction is computed for the created particle.
  15153. * @param worldMatrix is the world matrix of the particle system
  15154. * @param directionToUpdate is the direction vector to update with the result
  15155. * @param particle is the particle we are computed the direction for
  15156. */
  15157. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15158. /**
  15159. * Called by the particle System when the position is computed for the created particle.
  15160. * @param worldMatrix is the world matrix of the particle system
  15161. * @param positionToUpdate is the position vector to update with the result
  15162. * @param particle is the particle we are computed the position for
  15163. */
  15164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15165. /**
  15166. * Clones the current emitter and returns a copy of it
  15167. * @returns the new emitter
  15168. */
  15169. clone(): IParticleEmitterType;
  15170. /**
  15171. * Called by the GPUParticleSystem to setup the update shader
  15172. * @param effect defines the update shader
  15173. */
  15174. applyToShader(effect: Effect): void;
  15175. /**
  15176. * Returns a string to use to update the GPU particles update shader
  15177. * @returns the effect defines string
  15178. */
  15179. getEffectDefines(): string;
  15180. /**
  15181. * Returns a string representing the class name
  15182. * @returns a string containing the class name
  15183. */
  15184. getClassName(): string;
  15185. /**
  15186. * Serializes the particle system to a JSON object.
  15187. * @returns the JSON object
  15188. */
  15189. serialize(): any;
  15190. /**
  15191. * Parse properties from a JSON object
  15192. * @param serializationObject defines the JSON object
  15193. */
  15194. parse(serializationObject: any): void;
  15195. }
  15196. }
  15197. declare module BABYLON {
  15198. /**
  15199. * Particle emitter emitting particles from the inside of a box.
  15200. * It emits the particles randomly between 2 given directions.
  15201. */
  15202. export class BoxParticleEmitter implements IParticleEmitterType {
  15203. /**
  15204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15205. */
  15206. direction1: Vector3;
  15207. /**
  15208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15209. */
  15210. direction2: Vector3;
  15211. /**
  15212. * 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.
  15213. */
  15214. minEmitBox: Vector3;
  15215. /**
  15216. * 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.
  15217. */
  15218. maxEmitBox: Vector3;
  15219. /**
  15220. * Creates a new instance BoxParticleEmitter
  15221. */
  15222. constructor();
  15223. /**
  15224. * Called by the particle System when the direction is computed for the created particle.
  15225. * @param worldMatrix is the world matrix of the particle system
  15226. * @param directionToUpdate is the direction vector to update with the result
  15227. * @param particle is the particle we are computed the direction for
  15228. */
  15229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15230. /**
  15231. * Called by the particle System when the position is computed for the created particle.
  15232. * @param worldMatrix is the world matrix of the particle system
  15233. * @param positionToUpdate is the position vector to update with the result
  15234. * @param particle is the particle we are computed the position for
  15235. */
  15236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15237. /**
  15238. * Clones the current emitter and returns a copy of it
  15239. * @returns the new emitter
  15240. */
  15241. clone(): BoxParticleEmitter;
  15242. /**
  15243. * Called by the GPUParticleSystem to setup the update shader
  15244. * @param effect defines the update shader
  15245. */
  15246. applyToShader(effect: Effect): void;
  15247. /**
  15248. * Returns a string to use to update the GPU particles update shader
  15249. * @returns a string containng the defines string
  15250. */
  15251. getEffectDefines(): string;
  15252. /**
  15253. * Returns the string "BoxParticleEmitter"
  15254. * @returns a string containing the class name
  15255. */
  15256. getClassName(): string;
  15257. /**
  15258. * Serializes the particle system to a JSON object.
  15259. * @returns the JSON object
  15260. */
  15261. serialize(): any;
  15262. /**
  15263. * Parse properties from a JSON object
  15264. * @param serializationObject defines the JSON object
  15265. */
  15266. parse(serializationObject: any): void;
  15267. }
  15268. }
  15269. declare module BABYLON {
  15270. /**
  15271. * Particle emitter emitting particles from the inside of a cone.
  15272. * It emits the particles alongside the cone volume from the base to the particle.
  15273. * The emission direction might be randomized.
  15274. */
  15275. export class ConeParticleEmitter implements IParticleEmitterType {
  15276. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15277. directionRandomizer: number;
  15278. private _radius;
  15279. private _angle;
  15280. private _height;
  15281. /**
  15282. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15283. */
  15284. radiusRange: number;
  15285. /**
  15286. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15287. */
  15288. heightRange: number;
  15289. /**
  15290. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15291. */
  15292. emitFromSpawnPointOnly: boolean;
  15293. /**
  15294. * Gets or sets the radius of the emission cone
  15295. */
  15296. radius: number;
  15297. /**
  15298. * Gets or sets the angle of the emission cone
  15299. */
  15300. angle: number;
  15301. private _buildHeight;
  15302. /**
  15303. * Creates a new instance ConeParticleEmitter
  15304. * @param radius the radius of the emission cone (1 by default)
  15305. * @param angle the cone base angle (PI by default)
  15306. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15307. */
  15308. constructor(radius?: number, angle?: number,
  15309. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15310. directionRandomizer?: number);
  15311. /**
  15312. * Called by the particle System when the direction is computed for the created particle.
  15313. * @param worldMatrix is the world matrix of the particle system
  15314. * @param directionToUpdate is the direction vector to update with the result
  15315. * @param particle is the particle we are computed the direction for
  15316. */
  15317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15318. /**
  15319. * Called by the particle System when the position is computed for the created particle.
  15320. * @param worldMatrix is the world matrix of the particle system
  15321. * @param positionToUpdate is the position vector to update with the result
  15322. * @param particle is the particle we are computed the position for
  15323. */
  15324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15325. /**
  15326. * Clones the current emitter and returns a copy of it
  15327. * @returns the new emitter
  15328. */
  15329. clone(): ConeParticleEmitter;
  15330. /**
  15331. * Called by the GPUParticleSystem to setup the update shader
  15332. * @param effect defines the update shader
  15333. */
  15334. applyToShader(effect: Effect): void;
  15335. /**
  15336. * Returns a string to use to update the GPU particles update shader
  15337. * @returns a string containng the defines string
  15338. */
  15339. getEffectDefines(): string;
  15340. /**
  15341. * Returns the string "ConeParticleEmitter"
  15342. * @returns a string containing the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Serializes the particle system to a JSON object.
  15347. * @returns the JSON object
  15348. */
  15349. serialize(): any;
  15350. /**
  15351. * Parse properties from a JSON object
  15352. * @param serializationObject defines the JSON object
  15353. */
  15354. parse(serializationObject: any): void;
  15355. }
  15356. }
  15357. declare module BABYLON {
  15358. /**
  15359. * Particle emitter emitting particles from the inside of a cylinder.
  15360. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15361. */
  15362. export class CylinderParticleEmitter implements IParticleEmitterType {
  15363. /**
  15364. * The radius of the emission cylinder.
  15365. */
  15366. radius: number;
  15367. /**
  15368. * The height of the emission cylinder.
  15369. */
  15370. height: number;
  15371. /**
  15372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15373. */
  15374. radiusRange: number;
  15375. /**
  15376. * How much to randomize the particle direction [0-1].
  15377. */
  15378. directionRandomizer: number;
  15379. /**
  15380. * Creates a new instance CylinderParticleEmitter
  15381. * @param radius the radius of the emission cylinder (1 by default)
  15382. * @param height the height of the emission cylinder (1 by default)
  15383. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15384. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15385. */
  15386. constructor(
  15387. /**
  15388. * The radius of the emission cylinder.
  15389. */
  15390. radius?: number,
  15391. /**
  15392. * The height of the emission cylinder.
  15393. */
  15394. height?: number,
  15395. /**
  15396. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15397. */
  15398. radiusRange?: number,
  15399. /**
  15400. * How much to randomize the particle direction [0-1].
  15401. */
  15402. directionRandomizer?: number);
  15403. /**
  15404. * Called by the particle System when the direction is computed for the created particle.
  15405. * @param worldMatrix is the world matrix of the particle system
  15406. * @param directionToUpdate is the direction vector to update with the result
  15407. * @param particle is the particle we are computed the direction for
  15408. */
  15409. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15410. /**
  15411. * Called by the particle System when the position is computed for the created particle.
  15412. * @param worldMatrix is the world matrix of the particle system
  15413. * @param positionToUpdate is the position vector to update with the result
  15414. * @param particle is the particle we are computed the position for
  15415. */
  15416. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15417. /**
  15418. * Clones the current emitter and returns a copy of it
  15419. * @returns the new emitter
  15420. */
  15421. clone(): CylinderParticleEmitter;
  15422. /**
  15423. * Called by the GPUParticleSystem to setup the update shader
  15424. * @param effect defines the update shader
  15425. */
  15426. applyToShader(effect: Effect): void;
  15427. /**
  15428. * Returns a string to use to update the GPU particles update shader
  15429. * @returns a string containng the defines string
  15430. */
  15431. getEffectDefines(): string;
  15432. /**
  15433. * Returns the string "CylinderParticleEmitter"
  15434. * @returns a string containing the class name
  15435. */
  15436. getClassName(): string;
  15437. /**
  15438. * Serializes the particle system to a JSON object.
  15439. * @returns the JSON object
  15440. */
  15441. serialize(): any;
  15442. /**
  15443. * Parse properties from a JSON object
  15444. * @param serializationObject defines the JSON object
  15445. */
  15446. parse(serializationObject: any): void;
  15447. }
  15448. /**
  15449. * Particle emitter emitting particles from the inside of a cylinder.
  15450. * It emits the particles randomly between two vectors.
  15451. */
  15452. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15453. /**
  15454. * The min limit of the emission direction.
  15455. */
  15456. direction1: Vector3;
  15457. /**
  15458. * The max limit of the emission direction.
  15459. */
  15460. direction2: Vector3;
  15461. /**
  15462. * Creates a new instance CylinderDirectedParticleEmitter
  15463. * @param radius the radius of the emission cylinder (1 by default)
  15464. * @param height the height of the emission cylinder (1 by default)
  15465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15466. * @param direction1 the min limit of the emission direction (up vector by default)
  15467. * @param direction2 the max limit of the emission direction (up vector by default)
  15468. */
  15469. constructor(radius?: number, height?: number, radiusRange?: number,
  15470. /**
  15471. * The min limit of the emission direction.
  15472. */
  15473. direction1?: Vector3,
  15474. /**
  15475. * The max limit of the emission direction.
  15476. */
  15477. direction2?: Vector3);
  15478. /**
  15479. * Called by the particle System when the direction is computed for the created particle.
  15480. * @param worldMatrix is the world matrix of the particle system
  15481. * @param directionToUpdate is the direction vector to update with the result
  15482. * @param particle is the particle we are computed the direction for
  15483. */
  15484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15485. /**
  15486. * Clones the current emitter and returns a copy of it
  15487. * @returns the new emitter
  15488. */
  15489. clone(): CylinderDirectedParticleEmitter;
  15490. /**
  15491. * Called by the GPUParticleSystem to setup the update shader
  15492. * @param effect defines the update shader
  15493. */
  15494. applyToShader(effect: Effect): void;
  15495. /**
  15496. * Returns a string to use to update the GPU particles update shader
  15497. * @returns a string containng the defines string
  15498. */
  15499. getEffectDefines(): string;
  15500. /**
  15501. * Returns the string "CylinderDirectedParticleEmitter"
  15502. * @returns a string containing the class name
  15503. */
  15504. getClassName(): string;
  15505. /**
  15506. * Serializes the particle system to a JSON object.
  15507. * @returns the JSON object
  15508. */
  15509. serialize(): any;
  15510. /**
  15511. * Parse properties from a JSON object
  15512. * @param serializationObject defines the JSON object
  15513. */
  15514. parse(serializationObject: any): void;
  15515. }
  15516. }
  15517. declare module BABYLON {
  15518. /**
  15519. * Particle emitter emitting particles from the inside of a hemisphere.
  15520. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15521. */
  15522. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15523. /**
  15524. * The radius of the emission hemisphere.
  15525. */
  15526. radius: number;
  15527. /**
  15528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15529. */
  15530. radiusRange: number;
  15531. /**
  15532. * How much to randomize the particle direction [0-1].
  15533. */
  15534. directionRandomizer: number;
  15535. /**
  15536. * Creates a new instance HemisphericParticleEmitter
  15537. * @param radius the radius of the emission hemisphere (1 by default)
  15538. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15539. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15540. */
  15541. constructor(
  15542. /**
  15543. * The radius of the emission hemisphere.
  15544. */
  15545. radius?: number,
  15546. /**
  15547. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15548. */
  15549. radiusRange?: number,
  15550. /**
  15551. * How much to randomize the particle direction [0-1].
  15552. */
  15553. directionRandomizer?: number);
  15554. /**
  15555. * Called by the particle System when the direction is computed for the created particle.
  15556. * @param worldMatrix is the world matrix of the particle system
  15557. * @param directionToUpdate is the direction vector to update with the result
  15558. * @param particle is the particle we are computed the direction for
  15559. */
  15560. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15561. /**
  15562. * Called by the particle System when the position is computed for the created particle.
  15563. * @param worldMatrix is the world matrix of the particle system
  15564. * @param positionToUpdate is the position vector to update with the result
  15565. * @param particle is the particle we are computed the position for
  15566. */
  15567. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15568. /**
  15569. * Clones the current emitter and returns a copy of it
  15570. * @returns the new emitter
  15571. */
  15572. clone(): HemisphericParticleEmitter;
  15573. /**
  15574. * Called by the GPUParticleSystem to setup the update shader
  15575. * @param effect defines the update shader
  15576. */
  15577. applyToShader(effect: Effect): void;
  15578. /**
  15579. * Returns a string to use to update the GPU particles update shader
  15580. * @returns a string containng the defines string
  15581. */
  15582. getEffectDefines(): string;
  15583. /**
  15584. * Returns the string "HemisphericParticleEmitter"
  15585. * @returns a string containing the class name
  15586. */
  15587. getClassName(): string;
  15588. /**
  15589. * Serializes the particle system to a JSON object.
  15590. * @returns the JSON object
  15591. */
  15592. serialize(): any;
  15593. /**
  15594. * Parse properties from a JSON object
  15595. * @param serializationObject defines the JSON object
  15596. */
  15597. parse(serializationObject: any): void;
  15598. }
  15599. }
  15600. declare module BABYLON {
  15601. /**
  15602. * Particle emitter emitting particles from a point.
  15603. * It emits the particles randomly between 2 given directions.
  15604. */
  15605. export class PointParticleEmitter implements IParticleEmitterType {
  15606. /**
  15607. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15608. */
  15609. direction1: Vector3;
  15610. /**
  15611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15612. */
  15613. direction2: Vector3;
  15614. /**
  15615. * Creates a new instance PointParticleEmitter
  15616. */
  15617. constructor();
  15618. /**
  15619. * Called by the particle System when the direction is computed for the created particle.
  15620. * @param worldMatrix is the world matrix of the particle system
  15621. * @param directionToUpdate is the direction vector to update with the result
  15622. * @param particle is the particle we are computed the direction for
  15623. */
  15624. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15625. /**
  15626. * Called by the particle System when the position is computed for the created particle.
  15627. * @param worldMatrix is the world matrix of the particle system
  15628. * @param positionToUpdate is the position vector to update with the result
  15629. * @param particle is the particle we are computed the position for
  15630. */
  15631. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15632. /**
  15633. * Clones the current emitter and returns a copy of it
  15634. * @returns the new emitter
  15635. */
  15636. clone(): PointParticleEmitter;
  15637. /**
  15638. * Called by the GPUParticleSystem to setup the update shader
  15639. * @param effect defines the update shader
  15640. */
  15641. applyToShader(effect: Effect): void;
  15642. /**
  15643. * Returns a string to use to update the GPU particles update shader
  15644. * @returns a string containng the defines string
  15645. */
  15646. getEffectDefines(): string;
  15647. /**
  15648. * Returns the string "PointParticleEmitter"
  15649. * @returns a string containing the class name
  15650. */
  15651. getClassName(): string;
  15652. /**
  15653. * Serializes the particle system to a JSON object.
  15654. * @returns the JSON object
  15655. */
  15656. serialize(): any;
  15657. /**
  15658. * Parse properties from a JSON object
  15659. * @param serializationObject defines the JSON object
  15660. */
  15661. parse(serializationObject: any): void;
  15662. }
  15663. }
  15664. declare module BABYLON {
  15665. /**
  15666. * Particle emitter emitting particles from the inside of a sphere.
  15667. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15668. */
  15669. export class SphereParticleEmitter implements IParticleEmitterType {
  15670. /**
  15671. * The radius of the emission sphere.
  15672. */
  15673. radius: number;
  15674. /**
  15675. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15676. */
  15677. radiusRange: number;
  15678. /**
  15679. * How much to randomize the particle direction [0-1].
  15680. */
  15681. directionRandomizer: number;
  15682. /**
  15683. * Creates a new instance SphereParticleEmitter
  15684. * @param radius the radius of the emission sphere (1 by default)
  15685. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15686. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15687. */
  15688. constructor(
  15689. /**
  15690. * The radius of the emission sphere.
  15691. */
  15692. radius?: number,
  15693. /**
  15694. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15695. */
  15696. radiusRange?: number,
  15697. /**
  15698. * How much to randomize the particle direction [0-1].
  15699. */
  15700. directionRandomizer?: number);
  15701. /**
  15702. * Called by the particle System when the direction is computed for the created particle.
  15703. * @param worldMatrix is the world matrix of the particle system
  15704. * @param directionToUpdate is the direction vector to update with the result
  15705. * @param particle is the particle we are computed the direction for
  15706. */
  15707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15708. /**
  15709. * Called by the particle System when the position is computed for the created particle.
  15710. * @param worldMatrix is the world matrix of the particle system
  15711. * @param positionToUpdate is the position vector to update with the result
  15712. * @param particle is the particle we are computed the position for
  15713. */
  15714. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15715. /**
  15716. * Clones the current emitter and returns a copy of it
  15717. * @returns the new emitter
  15718. */
  15719. clone(): SphereParticleEmitter;
  15720. /**
  15721. * Called by the GPUParticleSystem to setup the update shader
  15722. * @param effect defines the update shader
  15723. */
  15724. applyToShader(effect: Effect): void;
  15725. /**
  15726. * Returns a string to use to update the GPU particles update shader
  15727. * @returns a string containng the defines string
  15728. */
  15729. getEffectDefines(): string;
  15730. /**
  15731. * Returns the string "SphereParticleEmitter"
  15732. * @returns a string containing the class name
  15733. */
  15734. getClassName(): string;
  15735. /**
  15736. * Serializes the particle system to a JSON object.
  15737. * @returns the JSON object
  15738. */
  15739. serialize(): any;
  15740. /**
  15741. * Parse properties from a JSON object
  15742. * @param serializationObject defines the JSON object
  15743. */
  15744. parse(serializationObject: any): void;
  15745. }
  15746. /**
  15747. * Particle emitter emitting particles from the inside of a sphere.
  15748. * It emits the particles randomly between two vectors.
  15749. */
  15750. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15751. /**
  15752. * The min limit of the emission direction.
  15753. */
  15754. direction1: Vector3;
  15755. /**
  15756. * The max limit of the emission direction.
  15757. */
  15758. direction2: Vector3;
  15759. /**
  15760. * Creates a new instance SphereDirectedParticleEmitter
  15761. * @param radius the radius of the emission sphere (1 by default)
  15762. * @param direction1 the min limit of the emission direction (up vector by default)
  15763. * @param direction2 the max limit of the emission direction (up vector by default)
  15764. */
  15765. constructor(radius?: number,
  15766. /**
  15767. * The min limit of the emission direction.
  15768. */
  15769. direction1?: Vector3,
  15770. /**
  15771. * The max limit of the emission direction.
  15772. */
  15773. direction2?: Vector3);
  15774. /**
  15775. * Called by the particle System when the direction is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param directionToUpdate is the direction vector to update with the result
  15778. * @param particle is the particle we are computed the direction for
  15779. */
  15780. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Clones the current emitter and returns a copy of it
  15783. * @returns the new emitter
  15784. */
  15785. clone(): SphereDirectedParticleEmitter;
  15786. /**
  15787. * Called by the GPUParticleSystem to setup the update shader
  15788. * @param effect defines the update shader
  15789. */
  15790. applyToShader(effect: Effect): void;
  15791. /**
  15792. * Returns a string to use to update the GPU particles update shader
  15793. * @returns a string containng the defines string
  15794. */
  15795. getEffectDefines(): string;
  15796. /**
  15797. * Returns the string "SphereDirectedParticleEmitter"
  15798. * @returns a string containing the class name
  15799. */
  15800. getClassName(): string;
  15801. /**
  15802. * Serializes the particle system to a JSON object.
  15803. * @returns the JSON object
  15804. */
  15805. serialize(): any;
  15806. /**
  15807. * Parse properties from a JSON object
  15808. * @param serializationObject defines the JSON object
  15809. */
  15810. parse(serializationObject: any): void;
  15811. }
  15812. }
  15813. declare module BABYLON {
  15814. /**
  15815. * Interface representing a particle system in Babylon.js.
  15816. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15817. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15818. */
  15819. export interface IParticleSystem {
  15820. /**
  15821. * List of animations used by the particle system.
  15822. */
  15823. animations: Animation[];
  15824. /**
  15825. * The id of the Particle system.
  15826. */
  15827. id: string;
  15828. /**
  15829. * The name of the Particle system.
  15830. */
  15831. name: string;
  15832. /**
  15833. * The emitter represents the Mesh or position we are attaching the particle system to.
  15834. */
  15835. emitter: Nullable<AbstractMesh | Vector3>;
  15836. /**
  15837. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15838. */
  15839. isBillboardBased: boolean;
  15840. /**
  15841. * The rendering group used by the Particle system to chose when to render.
  15842. */
  15843. renderingGroupId: number;
  15844. /**
  15845. * The layer mask we are rendering the particles through.
  15846. */
  15847. layerMask: number;
  15848. /**
  15849. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15850. */
  15851. updateSpeed: number;
  15852. /**
  15853. * The amount of time the particle system is running (depends of the overall update speed).
  15854. */
  15855. targetStopDuration: number;
  15856. /**
  15857. * The texture used to render each particle. (this can be a spritesheet)
  15858. */
  15859. particleTexture: Nullable<Texture>;
  15860. /**
  15861. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15862. */
  15863. blendMode: number;
  15864. /**
  15865. * Minimum life time of emitting particles.
  15866. */
  15867. minLifeTime: number;
  15868. /**
  15869. * Maximum life time of emitting particles.
  15870. */
  15871. maxLifeTime: number;
  15872. /**
  15873. * Minimum Size of emitting particles.
  15874. */
  15875. minSize: number;
  15876. /**
  15877. * Maximum Size of emitting particles.
  15878. */
  15879. maxSize: number;
  15880. /**
  15881. * Minimum scale of emitting particles on X axis.
  15882. */
  15883. minScaleX: number;
  15884. /**
  15885. * Maximum scale of emitting particles on X axis.
  15886. */
  15887. maxScaleX: number;
  15888. /**
  15889. * Minimum scale of emitting particles on Y axis.
  15890. */
  15891. minScaleY: number;
  15892. /**
  15893. * Maximum scale of emitting particles on Y axis.
  15894. */
  15895. maxScaleY: number;
  15896. /**
  15897. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15898. */
  15899. color1: Color4;
  15900. /**
  15901. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15902. */
  15903. color2: Color4;
  15904. /**
  15905. * Color the particle will have at the end of its lifetime.
  15906. */
  15907. colorDead: Color4;
  15908. /**
  15909. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15910. */
  15911. emitRate: number;
  15912. /**
  15913. * You can use gravity if you want to give an orientation to your particles.
  15914. */
  15915. gravity: Vector3;
  15916. /**
  15917. * Minimum power of emitting particles.
  15918. */
  15919. minEmitPower: number;
  15920. /**
  15921. * Maximum power of emitting particles.
  15922. */
  15923. maxEmitPower: number;
  15924. /**
  15925. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15926. */
  15927. minAngularSpeed: number;
  15928. /**
  15929. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15930. */
  15931. maxAngularSpeed: number;
  15932. /**
  15933. * Gets or sets the minimal initial rotation in radians.
  15934. */
  15935. minInitialRotation: number;
  15936. /**
  15937. * Gets or sets the maximal initial rotation in radians.
  15938. */
  15939. maxInitialRotation: number;
  15940. /**
  15941. * The particle emitter type defines the emitter used by the particle system.
  15942. * It can be for example box, sphere, or cone...
  15943. */
  15944. particleEmitterType: Nullable<IParticleEmitterType>;
  15945. /**
  15946. * Defines the delay in milliseconds before starting the system (0 by default)
  15947. */
  15948. startDelay: number;
  15949. /**
  15950. * 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
  15951. */
  15952. preWarmCycles: number;
  15953. /**
  15954. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15955. */
  15956. preWarmStepOffset: number;
  15957. /**
  15958. * 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)
  15959. */
  15960. spriteCellChangeSpeed: number;
  15961. /**
  15962. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15963. */
  15964. startSpriteCellID: number;
  15965. /**
  15966. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15967. */
  15968. endSpriteCellID: number;
  15969. /**
  15970. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15971. */
  15972. spriteCellWidth: number;
  15973. /**
  15974. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15975. */
  15976. spriteCellHeight: number;
  15977. /**
  15978. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15979. */
  15980. spriteRandomStartCell: boolean;
  15981. /**
  15982. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15983. */
  15984. isAnimationSheetEnabled: boolean;
  15985. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15986. translationPivot: Vector2;
  15987. /**
  15988. * Gets or sets a texture used to add random noise to particle positions
  15989. */
  15990. noiseTexture: Nullable<BaseTexture>;
  15991. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15992. noiseStrength: Vector3;
  15993. /**
  15994. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15995. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15996. */
  15997. billboardMode: number;
  15998. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15999. limitVelocityDamping: number;
  16000. /**
  16001. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16002. */
  16003. beginAnimationOnStart: boolean;
  16004. /**
  16005. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16006. */
  16007. beginAnimationFrom: number;
  16008. /**
  16009. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16010. */
  16011. beginAnimationTo: number;
  16012. /**
  16013. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16014. */
  16015. beginAnimationLoop: boolean;
  16016. /**
  16017. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16018. */
  16019. disposeOnStop: boolean;
  16020. /**
  16021. * Gets the maximum number of particles active at the same time.
  16022. * @returns The max number of active particles.
  16023. */
  16024. getCapacity(): number;
  16025. /**
  16026. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16027. * @returns True if it has been started, otherwise false.
  16028. */
  16029. isStarted(): boolean;
  16030. /**
  16031. * Animates the particle system for this frame.
  16032. */
  16033. animate(): void;
  16034. /**
  16035. * Renders the particle system in its current state.
  16036. * @returns the current number of particles
  16037. */
  16038. render(): number;
  16039. /**
  16040. * Dispose the particle system and frees its associated resources.
  16041. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16042. */
  16043. dispose(disposeTexture?: boolean): void;
  16044. /**
  16045. * Clones the particle system.
  16046. * @param name The name of the cloned object
  16047. * @param newEmitter The new emitter to use
  16048. * @returns the cloned particle system
  16049. */
  16050. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16051. /**
  16052. * Serializes the particle system to a JSON object.
  16053. * @returns the JSON object
  16054. */
  16055. serialize(): any;
  16056. /**
  16057. * Rebuild the particle system
  16058. */
  16059. rebuild(): void;
  16060. /**
  16061. * Starts the particle system and begins to emit
  16062. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16063. */
  16064. start(delay?: number): void;
  16065. /**
  16066. * Stops the particle system.
  16067. */
  16068. stop(): void;
  16069. /**
  16070. * Remove all active particles
  16071. */
  16072. reset(): void;
  16073. /**
  16074. * Is this system ready to be used/rendered
  16075. * @return true if the system is ready
  16076. */
  16077. isReady(): boolean;
  16078. /**
  16079. * Adds a new color gradient
  16080. * @param gradient defines the gradient to use (between 0 and 1)
  16081. * @param color1 defines the color to affect to the specified gradient
  16082. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16083. * @returns the current particle system
  16084. */
  16085. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16086. /**
  16087. * Remove a specific color gradient
  16088. * @param gradient defines the gradient to remove
  16089. * @returns the current particle system
  16090. */
  16091. removeColorGradient(gradient: number): IParticleSystem;
  16092. /**
  16093. * Adds a new size gradient
  16094. * @param gradient defines the gradient to use (between 0 and 1)
  16095. * @param factor defines the size factor to affect to the specified gradient
  16096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16097. * @returns the current particle system
  16098. */
  16099. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16100. /**
  16101. * Remove a specific size gradient
  16102. * @param gradient defines the gradient to remove
  16103. * @returns the current particle system
  16104. */
  16105. removeSizeGradient(gradient: number): IParticleSystem;
  16106. /**
  16107. * Gets the current list of color gradients.
  16108. * You must use addColorGradient and removeColorGradient to udpate this list
  16109. * @returns the list of color gradients
  16110. */
  16111. getColorGradients(): Nullable<Array<ColorGradient>>;
  16112. /**
  16113. * Gets the current list of size gradients.
  16114. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16115. * @returns the list of size gradients
  16116. */
  16117. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16118. /**
  16119. * Gets the current list of angular speed gradients.
  16120. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16121. * @returns the list of angular speed gradients
  16122. */
  16123. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16124. /**
  16125. * Adds a new angular speed gradient
  16126. * @param gradient defines the gradient to use (between 0 and 1)
  16127. * @param factor defines the angular speed to affect to the specified gradient
  16128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16129. * @returns the current particle system
  16130. */
  16131. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16132. /**
  16133. * Remove a specific angular speed gradient
  16134. * @param gradient defines the gradient to remove
  16135. * @returns the current particle system
  16136. */
  16137. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16138. /**
  16139. * Gets the current list of velocity gradients.
  16140. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16141. * @returns the list of velocity gradients
  16142. */
  16143. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16144. /**
  16145. * Adds a new velocity gradient
  16146. * @param gradient defines the gradient to use (between 0 and 1)
  16147. * @param factor defines the velocity to affect to the specified gradient
  16148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16149. * @returns the current particle system
  16150. */
  16151. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16152. /**
  16153. * Remove a specific velocity gradient
  16154. * @param gradient defines the gradient to remove
  16155. * @returns the current particle system
  16156. */
  16157. removeVelocityGradient(gradient: number): IParticleSystem;
  16158. /**
  16159. * Gets the current list of limit velocity gradients.
  16160. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16161. * @returns the list of limit velocity gradients
  16162. */
  16163. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16164. /**
  16165. * Adds a new limit velocity gradient
  16166. * @param gradient defines the gradient to use (between 0 and 1)
  16167. * @param factor defines the limit velocity to affect to the specified gradient
  16168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16169. * @returns the current particle system
  16170. */
  16171. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16172. /**
  16173. * Remove a specific limit velocity gradient
  16174. * @param gradient defines the gradient to remove
  16175. * @returns the current particle system
  16176. */
  16177. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16178. /**
  16179. * Adds a new drag gradient
  16180. * @param gradient defines the gradient to use (between 0 and 1)
  16181. * @param factor defines the drag to affect to the specified gradient
  16182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16183. * @returns the current particle system
  16184. */
  16185. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16186. /**
  16187. * Remove a specific drag gradient
  16188. * @param gradient defines the gradient to remove
  16189. * @returns the current particle system
  16190. */
  16191. removeDragGradient(gradient: number): IParticleSystem;
  16192. /**
  16193. * Gets the current list of drag gradients.
  16194. * You must use addDragGradient and removeDragGradient to udpate this list
  16195. * @returns the list of drag gradients
  16196. */
  16197. getDragGradients(): Nullable<Array<FactorGradient>>;
  16198. /**
  16199. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16200. * @param gradient defines the gradient to use (between 0 and 1)
  16201. * @param factor defines the emit rate to affect to the specified gradient
  16202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16203. * @returns the current particle system
  16204. */
  16205. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16206. /**
  16207. * Remove a specific emit rate gradient
  16208. * @param gradient defines the gradient to remove
  16209. * @returns the current particle system
  16210. */
  16211. removeEmitRateGradient(gradient: number): IParticleSystem;
  16212. /**
  16213. * Gets the current list of emit rate gradients.
  16214. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16215. * @returns the list of emit rate gradients
  16216. */
  16217. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16218. /**
  16219. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16220. * @param gradient defines the gradient to use (between 0 and 1)
  16221. * @param factor defines the start size to affect to the specified gradient
  16222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16223. * @returns the current particle system
  16224. */
  16225. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16226. /**
  16227. * Remove a specific start size gradient
  16228. * @param gradient defines the gradient to remove
  16229. * @returns the current particle system
  16230. */
  16231. removeStartSizeGradient(gradient: number): IParticleSystem;
  16232. /**
  16233. * Gets the current list of start size gradients.
  16234. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16235. * @returns the list of start size gradients
  16236. */
  16237. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16238. /**
  16239. * Adds a new life time gradient
  16240. * @param gradient defines the gradient to use (between 0 and 1)
  16241. * @param factor defines the life time factor to affect to the specified gradient
  16242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16243. * @returns the current particle system
  16244. */
  16245. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16246. /**
  16247. * Remove a specific life time gradient
  16248. * @param gradient defines the gradient to remove
  16249. * @returns the current particle system
  16250. */
  16251. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16252. /**
  16253. * Gets the current list of life time gradients.
  16254. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16255. * @returns the list of life time gradients
  16256. */
  16257. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16258. /**
  16259. * Gets the current list of color gradients.
  16260. * You must use addColorGradient and removeColorGradient to udpate this list
  16261. * @returns the list of color gradients
  16262. */
  16263. getColorGradients(): Nullable<Array<ColorGradient>>;
  16264. /**
  16265. * Adds a new ramp gradient used to remap particle colors
  16266. * @param gradient defines the gradient to use (between 0 and 1)
  16267. * @param color defines the color to affect to the specified gradient
  16268. * @returns the current particle system
  16269. */
  16270. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16271. /**
  16272. * Gets the current list of ramp gradients.
  16273. * You must use addRampGradient and removeRampGradient to udpate this list
  16274. * @returns the list of ramp gradients
  16275. */
  16276. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16277. /** Gets or sets a boolean indicating that ramp gradients must be used
  16278. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16279. */
  16280. useRampGradients: boolean;
  16281. /**
  16282. * Adds a new color remap gradient
  16283. * @param gradient defines the gradient to use (between 0 and 1)
  16284. * @param min defines the color remap minimal range
  16285. * @param max defines the color remap maximal range
  16286. * @returns the current particle system
  16287. */
  16288. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16289. /**
  16290. * Gets the current list of color remap gradients.
  16291. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16292. * @returns the list of color remap gradients
  16293. */
  16294. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16295. /**
  16296. * Adds a new alpha remap gradient
  16297. * @param gradient defines the gradient to use (between 0 and 1)
  16298. * @param min defines the alpha remap minimal range
  16299. * @param max defines the alpha remap maximal range
  16300. * @returns the current particle system
  16301. */
  16302. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16303. /**
  16304. * Gets the current list of alpha remap gradients.
  16305. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16306. * @returns the list of alpha remap gradients
  16307. */
  16308. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16309. /**
  16310. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16311. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16312. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16313. * @returns the emitter
  16314. */
  16315. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16316. /**
  16317. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16318. * @param radius The radius of the hemisphere to emit from
  16319. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16320. * @returns the emitter
  16321. */
  16322. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16323. /**
  16324. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16325. * @param radius The radius of the sphere to emit from
  16326. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16327. * @returns the emitter
  16328. */
  16329. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16330. /**
  16331. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16332. * @param radius The radius of the sphere to emit from
  16333. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16334. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16335. * @returns the emitter
  16336. */
  16337. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16338. /**
  16339. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16340. * @param radius The radius of the emission cylinder
  16341. * @param height The height of the emission cylinder
  16342. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16343. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16344. * @returns the emitter
  16345. */
  16346. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16347. /**
  16348. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16349. * @param radius The radius of the cylinder to emit from
  16350. * @param height The height of the emission cylinder
  16351. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16354. * @returns the emitter
  16355. */
  16356. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16357. /**
  16358. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16359. * @param radius The radius of the cone to emit from
  16360. * @param angle The base angle of the cone
  16361. * @returns the emitter
  16362. */
  16363. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16364. /**
  16365. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16366. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16367. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16368. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16369. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16370. * @returns the emitter
  16371. */
  16372. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16373. /**
  16374. * Get hosting scene
  16375. * @returns the scene
  16376. */
  16377. getScene(): Scene;
  16378. }
  16379. }
  16380. declare module BABYLON {
  16381. /**
  16382. * Creates an instance based on a source mesh.
  16383. */
  16384. export class InstancedMesh extends AbstractMesh {
  16385. private _sourceMesh;
  16386. private _currentLOD;
  16387. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16388. constructor(name: string, source: Mesh);
  16389. /**
  16390. * Returns the string "InstancedMesh".
  16391. */
  16392. getClassName(): string;
  16393. /**
  16394. * If the source mesh receives shadows
  16395. */
  16396. readonly receiveShadows: boolean;
  16397. /**
  16398. * The material of the source mesh
  16399. */
  16400. readonly material: Nullable<Material>;
  16401. /**
  16402. * Visibility of the source mesh
  16403. */
  16404. readonly visibility: number;
  16405. /**
  16406. * Skeleton of the source mesh
  16407. */
  16408. readonly skeleton: Nullable<Skeleton>;
  16409. /**
  16410. * Rendering ground id of the source mesh
  16411. */
  16412. renderingGroupId: number;
  16413. /**
  16414. * Returns the total number of vertices (integer).
  16415. */
  16416. getTotalVertices(): number;
  16417. /**
  16418. * Returns a positive integer : the total number of indices in this mesh geometry.
  16419. * @returns the numner of indices or zero if the mesh has no geometry.
  16420. */
  16421. getTotalIndices(): number;
  16422. /**
  16423. * The source mesh of the instance
  16424. */
  16425. readonly sourceMesh: Mesh;
  16426. /**
  16427. * Is this node ready to be used/rendered
  16428. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16429. * @return {boolean} is it ready
  16430. */
  16431. isReady(completeCheck?: boolean): boolean;
  16432. /**
  16433. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16434. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16435. * @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.
  16436. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16437. */
  16438. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16439. /**
  16440. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16441. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16442. * The `data` are either a numeric array either a Float32Array.
  16443. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16444. * 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).
  16445. * Note that a new underlying VertexBuffer object is created each call.
  16446. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16447. *
  16448. * Possible `kind` values :
  16449. * - VertexBuffer.PositionKind
  16450. * - VertexBuffer.UVKind
  16451. * - VertexBuffer.UV2Kind
  16452. * - VertexBuffer.UV3Kind
  16453. * - VertexBuffer.UV4Kind
  16454. * - VertexBuffer.UV5Kind
  16455. * - VertexBuffer.UV6Kind
  16456. * - VertexBuffer.ColorKind
  16457. * - VertexBuffer.MatricesIndicesKind
  16458. * - VertexBuffer.MatricesIndicesExtraKind
  16459. * - VertexBuffer.MatricesWeightsKind
  16460. * - VertexBuffer.MatricesWeightsExtraKind
  16461. *
  16462. * Returns the Mesh.
  16463. */
  16464. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16465. /**
  16466. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16467. * If the mesh has no geometry, it is simply returned as it is.
  16468. * The `data` are either a numeric array either a Float32Array.
  16469. * No new underlying VertexBuffer object is created.
  16470. * 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.
  16471. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16472. *
  16473. * Possible `kind` values :
  16474. * - VertexBuffer.PositionKind
  16475. * - VertexBuffer.UVKind
  16476. * - VertexBuffer.UV2Kind
  16477. * - VertexBuffer.UV3Kind
  16478. * - VertexBuffer.UV4Kind
  16479. * - VertexBuffer.UV5Kind
  16480. * - VertexBuffer.UV6Kind
  16481. * - VertexBuffer.ColorKind
  16482. * - VertexBuffer.MatricesIndicesKind
  16483. * - VertexBuffer.MatricesIndicesExtraKind
  16484. * - VertexBuffer.MatricesWeightsKind
  16485. * - VertexBuffer.MatricesWeightsExtraKind
  16486. *
  16487. * Returns the Mesh.
  16488. */
  16489. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16490. /**
  16491. * Sets the mesh indices.
  16492. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16493. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16494. * This method creates a new index buffer each call.
  16495. * Returns the Mesh.
  16496. */
  16497. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16498. /**
  16499. * Boolean : True if the mesh owns the requested kind of data.
  16500. */
  16501. isVerticesDataPresent(kind: string): boolean;
  16502. /**
  16503. * Returns an array of indices (IndicesArray).
  16504. */
  16505. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16506. /**
  16507. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16508. * This means the mesh underlying bounding box and sphere are recomputed.
  16509. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16510. * @returns the current mesh
  16511. */
  16512. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16513. /** @hidden */ preActivate(): InstancedMesh;
  16514. /** @hidden */ activate(renderId: number): boolean;
  16515. getWorldMatrix(): Matrix;
  16516. /**
  16517. * Returns the current associated LOD AbstractMesh.
  16518. */
  16519. getLOD(camera: Camera): AbstractMesh;
  16520. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16521. /** @hidden */ generatePointsArray(): boolean;
  16522. /**
  16523. * Creates a new InstancedMesh from the current mesh.
  16524. * - name (string) : the cloned mesh name
  16525. * - newParent (optional Node) : the optional Node to parent the clone to.
  16526. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16527. *
  16528. * Returns the clone.
  16529. */
  16530. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16531. /**
  16532. * Disposes the InstancedMesh.
  16533. * Returns nothing.
  16534. */
  16535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16536. }
  16537. }
  16538. declare module BABYLON {
  16539. /**
  16540. * Defines the options associated with the creation of a shader material.
  16541. */
  16542. export interface IShaderMaterialOptions {
  16543. /**
  16544. * Does the material work in alpha blend mode
  16545. */
  16546. needAlphaBlending: boolean;
  16547. /**
  16548. * Does the material work in alpha test mode
  16549. */
  16550. needAlphaTesting: boolean;
  16551. /**
  16552. * The list of attribute names used in the shader
  16553. */
  16554. attributes: string[];
  16555. /**
  16556. * The list of unifrom names used in the shader
  16557. */
  16558. uniforms: string[];
  16559. /**
  16560. * The list of UBO names used in the shader
  16561. */
  16562. uniformBuffers: string[];
  16563. /**
  16564. * The list of sampler names used in the shader
  16565. */
  16566. samplers: string[];
  16567. /**
  16568. * The list of defines used in the shader
  16569. */
  16570. defines: string[];
  16571. }
  16572. /**
  16573. * 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.
  16574. *
  16575. * This returned material effects how the mesh will look based on the code in the shaders.
  16576. *
  16577. * @see http://doc.babylonjs.com/how_to/shader_material
  16578. */
  16579. export class ShaderMaterial extends Material {
  16580. private _shaderPath;
  16581. private _options;
  16582. private _textures;
  16583. private _textureArrays;
  16584. private _floats;
  16585. private _ints;
  16586. private _floatsArrays;
  16587. private _colors3;
  16588. private _colors3Arrays;
  16589. private _colors4;
  16590. private _vectors2;
  16591. private _vectors3;
  16592. private _vectors4;
  16593. private _matrices;
  16594. private _matrices3x3;
  16595. private _matrices2x2;
  16596. private _vectors2Arrays;
  16597. private _vectors3Arrays;
  16598. private _cachedWorldViewMatrix;
  16599. private _renderId;
  16600. /**
  16601. * Instantiate a new shader material.
  16602. * 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.
  16603. * This returned material effects how the mesh will look based on the code in the shaders.
  16604. * @see http://doc.babylonjs.com/how_to/shader_material
  16605. * @param name Define the name of the material in the scene
  16606. * @param scene Define the scene the material belongs to
  16607. * @param shaderPath Defines the route to the shader code in one of three ways:
  16608. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16609. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16610. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16611. * @param options Define the options used to create the shader
  16612. */
  16613. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16614. /**
  16615. * Gets the options used to compile the shader.
  16616. * They can be modified to trigger a new compilation
  16617. */
  16618. readonly options: IShaderMaterialOptions;
  16619. /**
  16620. * Gets the current class name of the material e.g. "ShaderMaterial"
  16621. * Mainly use in serialization.
  16622. * @returns the class name
  16623. */
  16624. getClassName(): string;
  16625. /**
  16626. * Specifies if the material will require alpha blending
  16627. * @returns a boolean specifying if alpha blending is needed
  16628. */
  16629. needAlphaBlending(): boolean;
  16630. /**
  16631. * Specifies if this material should be rendered in alpha test mode
  16632. * @returns a boolean specifying if an alpha test is needed.
  16633. */
  16634. needAlphaTesting(): boolean;
  16635. private _checkUniform;
  16636. /**
  16637. * Set a texture in the shader.
  16638. * @param name Define the name of the uniform samplers as defined in the shader
  16639. * @param texture Define the texture to bind to this sampler
  16640. * @return the material itself allowing "fluent" like uniform updates
  16641. */
  16642. setTexture(name: string, texture: Texture): ShaderMaterial;
  16643. /**
  16644. * Set a texture array in the shader.
  16645. * @param name Define the name of the uniform sampler array as defined in the shader
  16646. * @param textures Define the list of textures to bind to this sampler
  16647. * @return the material itself allowing "fluent" like uniform updates
  16648. */
  16649. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16650. /**
  16651. * Set a float in the shader.
  16652. * @param name Define the name of the uniform as defined in the shader
  16653. * @param value Define the value to give to the uniform
  16654. * @return the material itself allowing "fluent" like uniform updates
  16655. */
  16656. setFloat(name: string, value: number): ShaderMaterial;
  16657. /**
  16658. * Set a int in the shader.
  16659. * @param name Define the name of the uniform as defined in the shader
  16660. * @param value Define the value to give to the uniform
  16661. * @return the material itself allowing "fluent" like uniform updates
  16662. */
  16663. setInt(name: string, value: number): ShaderMaterial;
  16664. /**
  16665. * Set an array of floats in the shader.
  16666. * @param name Define the name of the uniform as defined in the shader
  16667. * @param value Define the value to give to the uniform
  16668. * @return the material itself allowing "fluent" like uniform updates
  16669. */
  16670. setFloats(name: string, value: number[]): ShaderMaterial;
  16671. /**
  16672. * Set a vec3 in the shader from a Color3.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the material itself allowing "fluent" like uniform updates
  16676. */
  16677. setColor3(name: string, value: Color3): ShaderMaterial;
  16678. /**
  16679. * Set a vec3 array in the shader from a Color3 array.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the material itself allowing "fluent" like uniform updates
  16683. */
  16684. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16685. /**
  16686. * Set a vec4 in the shader from a Color4.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the material itself allowing "fluent" like uniform updates
  16690. */
  16691. setColor4(name: string, value: Color4): ShaderMaterial;
  16692. /**
  16693. * Set a vec2 in the shader from a Vector2.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the material itself allowing "fluent" like uniform updates
  16697. */
  16698. setVector2(name: string, value: Vector2): ShaderMaterial;
  16699. /**
  16700. * Set a vec3 in the shader from a Vector3.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the material itself allowing "fluent" like uniform updates
  16704. */
  16705. setVector3(name: string, value: Vector3): ShaderMaterial;
  16706. /**
  16707. * Set a vec4 in the shader from a Vector4.
  16708. * @param name Define the name of the uniform as defined in the shader
  16709. * @param value Define the value to give to the uniform
  16710. * @return the material itself allowing "fluent" like uniform updates
  16711. */
  16712. setVector4(name: string, value: Vector4): ShaderMaterial;
  16713. /**
  16714. * Set a mat4 in the shader from a Matrix.
  16715. * @param name Define the name of the uniform as defined in the shader
  16716. * @param value Define the value to give to the uniform
  16717. * @return the material itself allowing "fluent" like uniform updates
  16718. */
  16719. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16720. /**
  16721. * Set a mat3 in the shader from a Float32Array.
  16722. * @param name Define the name of the uniform as defined in the shader
  16723. * @param value Define the value to give to the uniform
  16724. * @return the material itself allowing "fluent" like uniform updates
  16725. */
  16726. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16727. /**
  16728. * Set a mat2 in the shader from a Float32Array.
  16729. * @param name Define the name of the uniform as defined in the shader
  16730. * @param value Define the value to give to the uniform
  16731. * @return the material itself allowing "fluent" like uniform updates
  16732. */
  16733. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16734. /**
  16735. * Set a vec2 array in the shader from a number array.
  16736. * @param name Define the name of the uniform as defined in the shader
  16737. * @param value Define the value to give to the uniform
  16738. * @return the material itself allowing "fluent" like uniform updates
  16739. */
  16740. setArray2(name: string, value: number[]): ShaderMaterial;
  16741. /**
  16742. * Set a vec3 array in the shader from a number array.
  16743. * @param name Define the name of the uniform as defined in the shader
  16744. * @param value Define the value to give to the uniform
  16745. * @return the material itself allowing "fluent" like uniform updates
  16746. */
  16747. setArray3(name: string, value: number[]): ShaderMaterial;
  16748. private _checkCache;
  16749. /**
  16750. * Specifies that the submesh is ready to be used
  16751. * @param mesh defines the mesh to check
  16752. * @param subMesh defines which submesh to check
  16753. * @param useInstances specifies that instances should be used
  16754. * @returns a boolean indicating that the submesh is ready or not
  16755. */
  16756. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16757. /**
  16758. * Checks if the material is ready to render the requested mesh
  16759. * @param mesh Define the mesh to render
  16760. * @param useInstances Define whether or not the material is used with instances
  16761. * @returns true if ready, otherwise false
  16762. */
  16763. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16764. /**
  16765. * Binds the world matrix to the material
  16766. * @param world defines the world transformation matrix
  16767. */
  16768. bindOnlyWorldMatrix(world: Matrix): void;
  16769. /**
  16770. * Binds the material to the mesh
  16771. * @param world defines the world transformation matrix
  16772. * @param mesh defines the mesh to bind the material to
  16773. */
  16774. bind(world: Matrix, mesh?: Mesh): void;
  16775. /**
  16776. * Gets the active textures from the material
  16777. * @returns an array of textures
  16778. */
  16779. getActiveTextures(): BaseTexture[];
  16780. /**
  16781. * Specifies if the material uses a texture
  16782. * @param texture defines the texture to check against the material
  16783. * @returns a boolean specifying if the material uses the texture
  16784. */
  16785. hasTexture(texture: BaseTexture): boolean;
  16786. /**
  16787. * Makes a duplicate of the material, and gives it a new name
  16788. * @param name defines the new name for the duplicated material
  16789. * @returns the cloned material
  16790. */
  16791. clone(name: string): ShaderMaterial;
  16792. /**
  16793. * Disposes the material
  16794. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16795. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16796. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16797. */
  16798. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16799. /**
  16800. * Serializes this material in a JSON representation
  16801. * @returns the serialized material object
  16802. */
  16803. serialize(): any;
  16804. /**
  16805. * Creates a shader material from parsed shader material data
  16806. * @param source defines the JSON represnetation of the material
  16807. * @param scene defines the hosting scene
  16808. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16809. * @returns a new material
  16810. */
  16811. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16812. }
  16813. }
  16814. declare module BABYLON {
  16815. /** @hidden */
  16816. export var colorPixelShader: {
  16817. name: string;
  16818. shader: string;
  16819. };
  16820. }
  16821. declare module BABYLON {
  16822. /** @hidden */
  16823. export var colorVertexShader: {
  16824. name: string;
  16825. shader: string;
  16826. };
  16827. }
  16828. declare module BABYLON {
  16829. /**
  16830. * Line mesh
  16831. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16832. */
  16833. export class LinesMesh extends Mesh {
  16834. /**
  16835. * If vertex color should be applied to the mesh
  16836. */
  16837. useVertexColor?: boolean | undefined;
  16838. /**
  16839. * If vertex alpha should be applied to the mesh
  16840. */
  16841. useVertexAlpha?: boolean | undefined;
  16842. /**
  16843. * Color of the line (Default: White)
  16844. */
  16845. color: Color3;
  16846. /**
  16847. * Alpha of the line (Default: 1)
  16848. */
  16849. alpha: number;
  16850. /**
  16851. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16852. * This margin is expressed in world space coordinates, so its value may vary.
  16853. * Default value is 0.1
  16854. */
  16855. intersectionThreshold: number;
  16856. private _colorShader;
  16857. /**
  16858. * Creates a new LinesMesh
  16859. * @param name defines the name
  16860. * @param scene defines the hosting scene
  16861. * @param parent defines the parent mesh if any
  16862. * @param source defines the optional source LinesMesh used to clone data from
  16863. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16864. * When false, achieved by calling a clone(), also passing False.
  16865. * This will make creation of children, recursive.
  16866. * @param useVertexColor defines if this LinesMesh supports vertex color
  16867. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16868. */
  16869. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16870. /**
  16871. * If vertex color should be applied to the mesh
  16872. */
  16873. useVertexColor?: boolean | undefined,
  16874. /**
  16875. * If vertex alpha should be applied to the mesh
  16876. */
  16877. useVertexAlpha?: boolean | undefined);
  16878. private _addClipPlaneDefine;
  16879. private _removeClipPlaneDefine;
  16880. isReady(): boolean;
  16881. /**
  16882. * Returns the string "LineMesh"
  16883. */
  16884. getClassName(): string;
  16885. /**
  16886. * @hidden
  16887. */
  16888. /**
  16889. * @hidden
  16890. */
  16891. material: Material;
  16892. /**
  16893. * @hidden
  16894. */
  16895. readonly checkCollisions: boolean;
  16896. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16897. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16898. /**
  16899. * Disposes of the line mesh
  16900. * @param doNotRecurse If children should be disposed
  16901. */
  16902. dispose(doNotRecurse?: boolean): void;
  16903. /**
  16904. * Returns a new LineMesh object cloned from the current one.
  16905. */
  16906. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16907. /**
  16908. * Creates a new InstancedLinesMesh object from the mesh model.
  16909. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16910. * @param name defines the name of the new instance
  16911. * @returns a new InstancedLinesMesh
  16912. */
  16913. createInstance(name: string): InstancedLinesMesh;
  16914. }
  16915. /**
  16916. * Creates an instance based on a source LinesMesh
  16917. */
  16918. export class InstancedLinesMesh extends InstancedMesh {
  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. * Initilized with the intersectionThreshold value of the source LinesMesh
  16923. */
  16924. intersectionThreshold: number;
  16925. constructor(name: string, source: LinesMesh);
  16926. /**
  16927. * Returns the string "InstancedLinesMesh".
  16928. */
  16929. getClassName(): string;
  16930. }
  16931. }
  16932. declare module BABYLON {
  16933. /** @hidden */
  16934. export var linePixelShader: {
  16935. name: string;
  16936. shader: string;
  16937. };
  16938. }
  16939. declare module BABYLON {
  16940. /** @hidden */
  16941. export var lineVertexShader: {
  16942. name: string;
  16943. shader: string;
  16944. };
  16945. }
  16946. declare module BABYLON {
  16947. interface AbstractMesh {
  16948. /**
  16949. * Disables the mesh edge rendering mode
  16950. * @returns the currentAbstractMesh
  16951. */
  16952. disableEdgesRendering(): AbstractMesh;
  16953. /**
  16954. * Enables the edge rendering mode on the mesh.
  16955. * This mode makes the mesh edges visible
  16956. * @param epsilon defines the maximal distance between two angles to detect a face
  16957. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16958. * @returns the currentAbstractMesh
  16959. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16960. */
  16961. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16962. /**
  16963. * Gets the edgesRenderer associated with the mesh
  16964. */
  16965. edgesRenderer: Nullable<EdgesRenderer>;
  16966. }
  16967. interface LinesMesh {
  16968. /**
  16969. * Enables the edge rendering mode on the mesh.
  16970. * This mode makes the mesh edges visible
  16971. * @param epsilon defines the maximal distance between two angles to detect a face
  16972. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16973. * @returns the currentAbstractMesh
  16974. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16975. */
  16976. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16977. }
  16978. interface InstancedLinesMesh {
  16979. /**
  16980. * Enables the edge rendering mode on the mesh.
  16981. * This mode makes the mesh edges visible
  16982. * @param epsilon defines the maximal distance between two angles to detect a face
  16983. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16984. * @returns the current InstancedLinesMesh
  16985. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16986. */
  16987. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16988. }
  16989. /**
  16990. * Defines the minimum contract an Edges renderer should follow.
  16991. */
  16992. export interface IEdgesRenderer extends IDisposable {
  16993. /**
  16994. * Gets or sets a boolean indicating if the edgesRenderer is active
  16995. */
  16996. isEnabled: boolean;
  16997. /**
  16998. * Renders the edges of the attached mesh,
  16999. */
  17000. render(): void;
  17001. /**
  17002. * Checks wether or not the edges renderer is ready to render.
  17003. * @return true if ready, otherwise false.
  17004. */
  17005. isReady(): boolean;
  17006. }
  17007. /**
  17008. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17009. */
  17010. export class EdgesRenderer implements IEdgesRenderer {
  17011. /**
  17012. * Define the size of the edges with an orthographic camera
  17013. */
  17014. edgesWidthScalerForOrthographic: number;
  17015. /**
  17016. * Define the size of the edges with a perspective camera
  17017. */
  17018. edgesWidthScalerForPerspective: number;
  17019. protected _source: AbstractMesh;
  17020. protected _linesPositions: number[];
  17021. protected _linesNormals: number[];
  17022. protected _linesIndices: number[];
  17023. protected _epsilon: number;
  17024. protected _indicesCount: number;
  17025. protected _lineShader: ShaderMaterial;
  17026. protected _ib: DataBuffer;
  17027. protected _buffers: {
  17028. [key: string]: Nullable<VertexBuffer>;
  17029. };
  17030. protected _checkVerticesInsteadOfIndices: boolean;
  17031. private _meshRebuildObserver;
  17032. private _meshDisposeObserver;
  17033. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17034. isEnabled: boolean;
  17035. /**
  17036. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17037. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17038. * @param source Mesh used to create edges
  17039. * @param epsilon sum of angles in adjacency to check for edge
  17040. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17041. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17042. */
  17043. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17044. protected _prepareRessources(): void;
  17045. /** @hidden */ rebuild(): void;
  17046. /**
  17047. * Releases the required resources for the edges renderer
  17048. */
  17049. dispose(): void;
  17050. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17051. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17052. /**
  17053. * Checks if the pair of p0 and p1 is en edge
  17054. * @param faceIndex
  17055. * @param edge
  17056. * @param faceNormals
  17057. * @param p0
  17058. * @param p1
  17059. * @private
  17060. */
  17061. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17062. /**
  17063. * push line into the position, normal and index buffer
  17064. * @protected
  17065. */
  17066. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17067. /**
  17068. * Generates lines edges from adjacencjes
  17069. * @private
  17070. */ generateEdgesLines(): void;
  17071. /**
  17072. * Checks wether or not the edges renderer is ready to render.
  17073. * @return true if ready, otherwise false.
  17074. */
  17075. isReady(): boolean;
  17076. /**
  17077. * Renders the edges of the attached mesh,
  17078. */
  17079. render(): void;
  17080. }
  17081. /**
  17082. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17083. */
  17084. export class LineEdgesRenderer extends EdgesRenderer {
  17085. /**
  17086. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17087. * @param source LineMesh used to generate edges
  17088. * @param epsilon not important (specified angle for edge detection)
  17089. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17090. */
  17091. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17092. /**
  17093. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17094. */ generateEdgesLines(): void;
  17095. }
  17096. }
  17097. declare module BABYLON {
  17098. /**
  17099. * This represents the object necessary to create a rendering group.
  17100. * This is exclusively used and created by the rendering manager.
  17101. * To modify the behavior, you use the available helpers in your scene or meshes.
  17102. * @hidden
  17103. */
  17104. export class RenderingGroup {
  17105. index: number;
  17106. private _scene;
  17107. private _opaqueSubMeshes;
  17108. private _transparentSubMeshes;
  17109. private _alphaTestSubMeshes;
  17110. private _depthOnlySubMeshes;
  17111. private _particleSystems;
  17112. private _spriteManagers;
  17113. private _opaqueSortCompareFn;
  17114. private _alphaTestSortCompareFn;
  17115. private _transparentSortCompareFn;
  17116. private _renderOpaque;
  17117. private _renderAlphaTest;
  17118. private _renderTransparent;
  17119. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17120. onBeforeTransparentRendering: () => void;
  17121. /**
  17122. * Set the opaque sort comparison function.
  17123. * If null the sub meshes will be render in the order they were created
  17124. */
  17125. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17126. /**
  17127. * Set the alpha test sort comparison function.
  17128. * If null the sub meshes will be render in the order they were created
  17129. */
  17130. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17131. /**
  17132. * Set the transparent sort comparison function.
  17133. * If null the sub meshes will be render in the order they were created
  17134. */
  17135. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17136. /**
  17137. * Creates a new rendering group.
  17138. * @param index The rendering group index
  17139. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17140. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17141. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17142. */
  17143. 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>);
  17144. /**
  17145. * Render all the sub meshes contained in the group.
  17146. * @param customRenderFunction Used to override the default render behaviour of the group.
  17147. * @returns true if rendered some submeshes.
  17148. */
  17149. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17150. /**
  17151. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17152. * @param subMeshes The submeshes to render
  17153. */
  17154. private renderOpaqueSorted;
  17155. /**
  17156. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17157. * @param subMeshes The submeshes to render
  17158. */
  17159. private renderAlphaTestSorted;
  17160. /**
  17161. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17162. * @param subMeshes The submeshes to render
  17163. */
  17164. private renderTransparentSorted;
  17165. /**
  17166. * Renders the submeshes in a specified order.
  17167. * @param subMeshes The submeshes to sort before render
  17168. * @param sortCompareFn The comparison function use to sort
  17169. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17170. * @param transparent Specifies to activate blending if true
  17171. */
  17172. private static renderSorted;
  17173. /**
  17174. * Renders the submeshes in the order they were dispatched (no sort applied).
  17175. * @param subMeshes The submeshes to render
  17176. */
  17177. private static renderUnsorted;
  17178. /**
  17179. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17180. * are rendered back to front if in the same alpha index.
  17181. *
  17182. * @param a The first submesh
  17183. * @param b The second submesh
  17184. * @returns The result of the comparison
  17185. */
  17186. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17187. /**
  17188. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17189. * are rendered back to front.
  17190. *
  17191. * @param a The first submesh
  17192. * @param b The second submesh
  17193. * @returns The result of the comparison
  17194. */
  17195. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17196. /**
  17197. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17198. * are rendered front to back (prevent overdraw).
  17199. *
  17200. * @param a The first submesh
  17201. * @param b The second submesh
  17202. * @returns The result of the comparison
  17203. */
  17204. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17205. /**
  17206. * Resets the different lists of submeshes to prepare a new frame.
  17207. */
  17208. prepare(): void;
  17209. dispose(): void;
  17210. /**
  17211. * Inserts the submesh in its correct queue depending on its material.
  17212. * @param subMesh The submesh to dispatch
  17213. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17214. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17215. */
  17216. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17217. dispatchSprites(spriteManager: ISpriteManager): void;
  17218. dispatchParticles(particleSystem: IParticleSystem): void;
  17219. private _renderParticles;
  17220. private _renderSprites;
  17221. }
  17222. }
  17223. declare module BABYLON {
  17224. /**
  17225. * Interface describing the different options available in the rendering manager
  17226. * regarding Auto Clear between groups.
  17227. */
  17228. export interface IRenderingManagerAutoClearSetup {
  17229. /**
  17230. * Defines whether or not autoclear is enable.
  17231. */
  17232. autoClear: boolean;
  17233. /**
  17234. * Defines whether or not to autoclear the depth buffer.
  17235. */
  17236. depth: boolean;
  17237. /**
  17238. * Defines whether or not to autoclear the stencil buffer.
  17239. */
  17240. stencil: boolean;
  17241. }
  17242. /**
  17243. * This class is used by the onRenderingGroupObservable
  17244. */
  17245. export class RenderingGroupInfo {
  17246. /**
  17247. * The Scene that being rendered
  17248. */
  17249. scene: Scene;
  17250. /**
  17251. * The camera currently used for the rendering pass
  17252. */
  17253. camera: Nullable<Camera>;
  17254. /**
  17255. * The ID of the renderingGroup being processed
  17256. */
  17257. renderingGroupId: number;
  17258. }
  17259. /**
  17260. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17261. * It is enable to manage the different groups as well as the different necessary sort functions.
  17262. * This should not be used directly aside of the few static configurations
  17263. */
  17264. export class RenderingManager {
  17265. /**
  17266. * The max id used for rendering groups (not included)
  17267. */
  17268. static MAX_RENDERINGGROUPS: number;
  17269. /**
  17270. * The min id used for rendering groups (included)
  17271. */
  17272. static MIN_RENDERINGGROUPS: number;
  17273. /**
  17274. * Used to globally prevent autoclearing scenes.
  17275. */
  17276. static AUTOCLEAR: boolean;
  17277. /**
  17278. * @hidden
  17279. */ useSceneAutoClearSetup: boolean;
  17280. private _scene;
  17281. private _renderingGroups;
  17282. private _depthStencilBufferAlreadyCleaned;
  17283. private _autoClearDepthStencil;
  17284. private _customOpaqueSortCompareFn;
  17285. private _customAlphaTestSortCompareFn;
  17286. private _customTransparentSortCompareFn;
  17287. private _renderingGroupInfo;
  17288. /**
  17289. * Instantiates a new rendering group for a particular scene
  17290. * @param scene Defines the scene the groups belongs to
  17291. */
  17292. constructor(scene: Scene);
  17293. private _clearDepthStencilBuffer;
  17294. /**
  17295. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17296. * @hidden
  17297. */
  17298. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17299. /**
  17300. * Resets the different information of the group to prepare a new frame
  17301. * @hidden
  17302. */
  17303. reset(): void;
  17304. /**
  17305. * Dispose and release the group and its associated resources.
  17306. * @hidden
  17307. */
  17308. dispose(): void;
  17309. /**
  17310. * Clear the info related to rendering groups preventing retention points during dispose.
  17311. */
  17312. freeRenderingGroups(): void;
  17313. private _prepareRenderingGroup;
  17314. /**
  17315. * Add a sprite manager to the rendering manager in order to render it this frame.
  17316. * @param spriteManager Define the sprite manager to render
  17317. */
  17318. dispatchSprites(spriteManager: ISpriteManager): void;
  17319. /**
  17320. * Add a particle system to the rendering manager in order to render it this frame.
  17321. * @param particleSystem Define the particle system to render
  17322. */
  17323. dispatchParticles(particleSystem: IParticleSystem): void;
  17324. /**
  17325. * Add a submesh to the manager in order to render it this frame
  17326. * @param subMesh The submesh to dispatch
  17327. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17328. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17329. */
  17330. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17331. /**
  17332. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17333. * This allowed control for front to back rendering or reversly depending of the special needs.
  17334. *
  17335. * @param renderingGroupId The rendering group id corresponding to its index
  17336. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17337. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17338. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17339. */
  17340. 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;
  17341. /**
  17342. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17343. *
  17344. * @param renderingGroupId The rendering group id corresponding to its index
  17345. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17346. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17347. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17348. */
  17349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17350. /**
  17351. * Gets the current auto clear configuration for one rendering group of the rendering
  17352. * manager.
  17353. * @param index the rendering group index to get the information for
  17354. * @returns The auto clear setup for the requested rendering group
  17355. */
  17356. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17357. }
  17358. }
  17359. declare module BABYLON {
  17360. /**
  17361. * This Helps creating a texture that will be created from a camera in your scene.
  17362. * It is basically a dynamic texture that could be used to create special effects for instance.
  17363. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17364. */
  17365. export class RenderTargetTexture extends Texture {
  17366. isCube: boolean;
  17367. /**
  17368. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17369. */
  17370. static readonly REFRESHRATE_RENDER_ONCE: number;
  17371. /**
  17372. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17373. */
  17374. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17375. /**
  17376. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17377. * the central point of your effect and can save a lot of performances.
  17378. */
  17379. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17380. /**
  17381. * Use this predicate to dynamically define the list of mesh you want to render.
  17382. * If set, the renderList property will be overwritten.
  17383. */
  17384. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17385. private _renderList;
  17386. /**
  17387. * Use this list to define the list of mesh you want to render.
  17388. */
  17389. renderList: Nullable<Array<AbstractMesh>>;
  17390. private _hookArray;
  17391. /**
  17392. * Define if particles should be rendered in your texture.
  17393. */
  17394. renderParticles: boolean;
  17395. /**
  17396. * Define if sprites should be rendered in your texture.
  17397. */
  17398. renderSprites: boolean;
  17399. /**
  17400. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17401. */
  17402. coordinatesMode: number;
  17403. /**
  17404. * Define the camera used to render the texture.
  17405. */
  17406. activeCamera: Nullable<Camera>;
  17407. /**
  17408. * Override the render function of the texture with your own one.
  17409. */
  17410. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17411. /**
  17412. * Define if camera post processes should be use while rendering the texture.
  17413. */
  17414. useCameraPostProcesses: boolean;
  17415. /**
  17416. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17417. */
  17418. ignoreCameraViewport: boolean;
  17419. private _postProcessManager;
  17420. private _postProcesses;
  17421. private _resizeObserver;
  17422. /**
  17423. * An event triggered when the texture is unbind.
  17424. */
  17425. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17426. /**
  17427. * An event triggered when the texture is unbind.
  17428. */
  17429. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17430. private _onAfterUnbindObserver;
  17431. /**
  17432. * Set a after unbind callback in the texture.
  17433. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17434. */
  17435. onAfterUnbind: () => void;
  17436. /**
  17437. * An event triggered before rendering the texture
  17438. */
  17439. onBeforeRenderObservable: Observable<number>;
  17440. private _onBeforeRenderObserver;
  17441. /**
  17442. * Set a before render callback in the texture.
  17443. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17444. */
  17445. onBeforeRender: (faceIndex: number) => void;
  17446. /**
  17447. * An event triggered after rendering the texture
  17448. */
  17449. onAfterRenderObservable: Observable<number>;
  17450. private _onAfterRenderObserver;
  17451. /**
  17452. * Set a after render callback in the texture.
  17453. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17454. */
  17455. onAfterRender: (faceIndex: number) => void;
  17456. /**
  17457. * An event triggered after the texture clear
  17458. */
  17459. onClearObservable: Observable<Engine>;
  17460. private _onClearObserver;
  17461. /**
  17462. * Set a clear callback in the texture.
  17463. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17464. */
  17465. onClear: (Engine: Engine) => void;
  17466. /**
  17467. * Define the clear color of the Render Target if it should be different from the scene.
  17468. */
  17469. clearColor: Color4;
  17470. protected _size: number | {
  17471. width: number;
  17472. height: number;
  17473. };
  17474. protected _initialSizeParameter: number | {
  17475. width: number;
  17476. height: number;
  17477. } | {
  17478. ratio: number;
  17479. };
  17480. protected _sizeRatio: Nullable<number>;
  17481. /** @hidden */ generateMipMaps: boolean;
  17482. protected _renderingManager: RenderingManager;
  17483. /** @hidden */ waitingRenderList: string[];
  17484. protected _doNotChangeAspectRatio: boolean;
  17485. protected _currentRefreshId: number;
  17486. protected _refreshRate: number;
  17487. protected _textureMatrix: Matrix;
  17488. protected _samples: number;
  17489. protected _renderTargetOptions: RenderTargetCreationOptions;
  17490. /**
  17491. * Gets render target creation options that were used.
  17492. */
  17493. readonly renderTargetOptions: RenderTargetCreationOptions;
  17494. protected _engine: Engine;
  17495. protected _onRatioRescale(): void;
  17496. /**
  17497. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17498. * It must define where the camera used to render the texture is set
  17499. */
  17500. boundingBoxPosition: Vector3;
  17501. private _boundingBoxSize;
  17502. /**
  17503. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17504. * When defined, the cubemap will switch to local mode
  17505. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17506. * @example https://www.babylonjs-playground.com/#RNASML
  17507. */
  17508. boundingBoxSize: Vector3;
  17509. /**
  17510. * In case the RTT has been created with a depth texture, get the associated
  17511. * depth texture.
  17512. * Otherwise, return null.
  17513. */
  17514. depthStencilTexture: Nullable<InternalTexture>;
  17515. /**
  17516. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17517. * or used a shadow, depth texture...
  17518. * @param name The friendly name of the texture
  17519. * @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)
  17520. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17521. * @param generateMipMaps True if mip maps need to be generated after render.
  17522. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17523. * @param type The type of the buffer in the RTT (int, half float, float...)
  17524. * @param isCube True if a cube texture needs to be created
  17525. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17526. * @param generateDepthBuffer True to generate a depth buffer
  17527. * @param generateStencilBuffer True to generate a stencil buffer
  17528. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17529. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17530. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17531. */
  17532. constructor(name: string, size: number | {
  17533. width: number;
  17534. height: number;
  17535. } | {
  17536. ratio: number;
  17537. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17538. /**
  17539. * Creates a depth stencil texture.
  17540. * This is only available in WebGL 2 or with the depth texture extension available.
  17541. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17542. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17543. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17544. */
  17545. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17546. private _processSizeParameter;
  17547. /**
  17548. * Define the number of samples to use in case of MSAA.
  17549. * It defaults to one meaning no MSAA has been enabled.
  17550. */
  17551. samples: number;
  17552. /**
  17553. * Resets the refresh counter of the texture and start bak from scratch.
  17554. * Could be useful to regenerate the texture if it is setup to render only once.
  17555. */
  17556. resetRefreshCounter(): void;
  17557. /**
  17558. * Define the refresh rate of the texture or the rendering frequency.
  17559. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17560. */
  17561. refreshRate: number;
  17562. /**
  17563. * Adds a post process to the render target rendering passes.
  17564. * @param postProcess define the post process to add
  17565. */
  17566. addPostProcess(postProcess: PostProcess): void;
  17567. /**
  17568. * Clear all the post processes attached to the render target
  17569. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17570. */
  17571. clearPostProcesses(dispose?: boolean): void;
  17572. /**
  17573. * Remove one of the post process from the list of attached post processes to the texture
  17574. * @param postProcess define the post process to remove from the list
  17575. */
  17576. removePostProcess(postProcess: PostProcess): void;
  17577. /** @hidden */ shouldRender(): boolean;
  17578. /**
  17579. * Gets the actual render size of the texture.
  17580. * @returns the width of the render size
  17581. */
  17582. getRenderSize(): number;
  17583. /**
  17584. * Gets the actual render width of the texture.
  17585. * @returns the width of the render size
  17586. */
  17587. getRenderWidth(): number;
  17588. /**
  17589. * Gets the actual render height of the texture.
  17590. * @returns the height of the render size
  17591. */
  17592. getRenderHeight(): number;
  17593. /**
  17594. * Get if the texture can be rescaled or not.
  17595. */
  17596. readonly canRescale: boolean;
  17597. /**
  17598. * Resize the texture using a ratio.
  17599. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17600. */
  17601. scale(ratio: number): void;
  17602. /**
  17603. * Get the texture reflection matrix used to rotate/transform the reflection.
  17604. * @returns the reflection matrix
  17605. */
  17606. getReflectionTextureMatrix(): Matrix;
  17607. /**
  17608. * Resize the texture to a new desired size.
  17609. * Be carrefull as it will recreate all the data in the new texture.
  17610. * @param size Define the new size. It can be:
  17611. * - a number for squared texture,
  17612. * - an object containing { width: number, height: number }
  17613. * - or an object containing a ratio { ratio: number }
  17614. */
  17615. resize(size: number | {
  17616. width: number;
  17617. height: number;
  17618. } | {
  17619. ratio: number;
  17620. }): void;
  17621. /**
  17622. * Renders all the objects from the render list into the texture.
  17623. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17624. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17625. */
  17626. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17627. private _bestReflectionRenderTargetDimension;
  17628. /**
  17629. * @hidden
  17630. * @param faceIndex face index to bind to if this is a cubetexture
  17631. */ bindFrameBuffer(faceIndex?: number): void;
  17632. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17633. private renderToTarget;
  17634. /**
  17635. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17636. * This allowed control for front to back rendering or reversly depending of the special needs.
  17637. *
  17638. * @param renderingGroupId The rendering group id corresponding to its index
  17639. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17640. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17641. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17642. */
  17643. 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;
  17644. /**
  17645. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17646. *
  17647. * @param renderingGroupId The rendering group id corresponding to its index
  17648. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17649. */
  17650. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17651. /**
  17652. * Clones the texture.
  17653. * @returns the cloned texture
  17654. */
  17655. clone(): RenderTargetTexture;
  17656. /**
  17657. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17658. * @returns The JSON representation of the texture
  17659. */
  17660. serialize(): any;
  17661. /**
  17662. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17663. */
  17664. disposeFramebufferObjects(): void;
  17665. /**
  17666. * Dispose the texture and release its associated resources.
  17667. */
  17668. dispose(): void;
  17669. /** @hidden */ rebuild(): void;
  17670. /**
  17671. * Clear the info related to rendering groups preventing retention point in material dispose.
  17672. */
  17673. freeRenderingGroups(): void;
  17674. /**
  17675. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17676. * @returns the view count
  17677. */
  17678. getViewCount(): number;
  17679. }
  17680. }
  17681. declare module BABYLON {
  17682. /**
  17683. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17684. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17685. * You can then easily use it as a reflectionTexture on a flat surface.
  17686. * In case the surface is not a plane, please consider relying on reflection probes.
  17687. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17688. */
  17689. export class MirrorTexture extends RenderTargetTexture {
  17690. private scene;
  17691. /**
  17692. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17693. * 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.
  17694. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17695. */
  17696. mirrorPlane: Plane;
  17697. /**
  17698. * Define the blur ratio used to blur the reflection if needed.
  17699. */
  17700. blurRatio: number;
  17701. /**
  17702. * Define the adaptive blur kernel used to blur the reflection if needed.
  17703. * This will autocompute the closest best match for the `blurKernel`
  17704. */
  17705. adaptiveBlurKernel: number;
  17706. /**
  17707. * Define the blur kernel used to blur the reflection if needed.
  17708. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17709. */
  17710. blurKernel: number;
  17711. /**
  17712. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17713. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17714. */
  17715. blurKernelX: number;
  17716. /**
  17717. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17718. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17719. */
  17720. blurKernelY: number;
  17721. private _autoComputeBlurKernel;
  17722. protected _onRatioRescale(): void;
  17723. private _updateGammaSpace;
  17724. private _imageProcessingConfigChangeObserver;
  17725. private _transformMatrix;
  17726. private _mirrorMatrix;
  17727. private _savedViewMatrix;
  17728. private _blurX;
  17729. private _blurY;
  17730. private _adaptiveBlurKernel;
  17731. private _blurKernelX;
  17732. private _blurKernelY;
  17733. private _blurRatio;
  17734. /**
  17735. * Instantiates a Mirror Texture.
  17736. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17737. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17738. * You can then easily use it as a reflectionTexture on a flat surface.
  17739. * In case the surface is not a plane, please consider relying on reflection probes.
  17740. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17741. * @param name
  17742. * @param size
  17743. * @param scene
  17744. * @param generateMipMaps
  17745. * @param type
  17746. * @param samplingMode
  17747. * @param generateDepthBuffer
  17748. */
  17749. constructor(name: string, size: number | {
  17750. width: number;
  17751. height: number;
  17752. } | {
  17753. ratio: number;
  17754. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17755. private _preparePostProcesses;
  17756. /**
  17757. * Clone the mirror texture.
  17758. * @returns the cloned texture
  17759. */
  17760. clone(): MirrorTexture;
  17761. /**
  17762. * Serialize the texture to a JSON representation you could use in Parse later on
  17763. * @returns the serialized JSON representation
  17764. */
  17765. serialize(): any;
  17766. /**
  17767. * Dispose the texture and release its associated resources.
  17768. */
  17769. dispose(): void;
  17770. }
  17771. }
  17772. declare module BABYLON {
  17773. /**
  17774. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17775. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17776. */
  17777. export class Texture extends BaseTexture {
  17778. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17779. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17780. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17781. /** nearest is mag = nearest and min = nearest and mip = linear */
  17782. static readonly NEAREST_SAMPLINGMODE: number;
  17783. /** nearest is mag = nearest and min = nearest and mip = linear */
  17784. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17785. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17786. static readonly BILINEAR_SAMPLINGMODE: number;
  17787. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17788. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17789. /** Trilinear is mag = linear and min = linear and mip = linear */
  17790. static readonly TRILINEAR_SAMPLINGMODE: number;
  17791. /** Trilinear is mag = linear and min = linear and mip = linear */
  17792. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17793. /** mag = nearest and min = nearest and mip = nearest */
  17794. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17795. /** mag = nearest and min = linear and mip = nearest */
  17796. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17797. /** mag = nearest and min = linear and mip = linear */
  17798. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17799. /** mag = nearest and min = linear and mip = none */
  17800. static readonly NEAREST_LINEAR: number;
  17801. /** mag = nearest and min = nearest and mip = none */
  17802. static readonly NEAREST_NEAREST: number;
  17803. /** mag = linear and min = nearest and mip = nearest */
  17804. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17805. /** mag = linear and min = nearest and mip = linear */
  17806. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17807. /** mag = linear and min = linear and mip = none */
  17808. static readonly LINEAR_LINEAR: number;
  17809. /** mag = linear and min = nearest and mip = none */
  17810. static readonly LINEAR_NEAREST: number;
  17811. /** Explicit coordinates mode */
  17812. static readonly EXPLICIT_MODE: number;
  17813. /** Spherical coordinates mode */
  17814. static readonly SPHERICAL_MODE: number;
  17815. /** Planar coordinates mode */
  17816. static readonly PLANAR_MODE: number;
  17817. /** Cubic coordinates mode */
  17818. static readonly CUBIC_MODE: number;
  17819. /** Projection coordinates mode */
  17820. static readonly PROJECTION_MODE: number;
  17821. /** Inverse Cubic coordinates mode */
  17822. static readonly SKYBOX_MODE: number;
  17823. /** Inverse Cubic coordinates mode */
  17824. static readonly INVCUBIC_MODE: number;
  17825. /** Equirectangular coordinates mode */
  17826. static readonly EQUIRECTANGULAR_MODE: number;
  17827. /** Equirectangular Fixed coordinates mode */
  17828. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17829. /** Equirectangular Fixed Mirrored coordinates mode */
  17830. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17831. /** Texture is not repeating outside of 0..1 UVs */
  17832. static readonly CLAMP_ADDRESSMODE: number;
  17833. /** Texture is repeating outside of 0..1 UVs */
  17834. static readonly WRAP_ADDRESSMODE: number;
  17835. /** Texture is repeating and mirrored */
  17836. static readonly MIRROR_ADDRESSMODE: number;
  17837. /**
  17838. * 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
  17839. */
  17840. static UseSerializedUrlIfAny: boolean;
  17841. /**
  17842. * Define the url of the texture.
  17843. */
  17844. url: Nullable<string>;
  17845. /**
  17846. * Define an offset on the texture to offset the u coordinates of the UVs
  17847. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17848. */
  17849. uOffset: number;
  17850. /**
  17851. * Define an offset on the texture to offset the v coordinates of the UVs
  17852. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17853. */
  17854. vOffset: number;
  17855. /**
  17856. * Define an offset on the texture to scale the u coordinates of the UVs
  17857. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17858. */
  17859. uScale: number;
  17860. /**
  17861. * Define an offset on the texture to scale the v coordinates of the UVs
  17862. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17863. */
  17864. vScale: number;
  17865. /**
  17866. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17867. * @see http://doc.babylonjs.com/how_to/more_materials
  17868. */
  17869. uAng: number;
  17870. /**
  17871. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17872. * @see http://doc.babylonjs.com/how_to/more_materials
  17873. */
  17874. vAng: number;
  17875. /**
  17876. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17877. * @see http://doc.babylonjs.com/how_to/more_materials
  17878. */
  17879. wAng: number;
  17880. /**
  17881. * Defines the center of rotation (U)
  17882. */
  17883. uRotationCenter: number;
  17884. /**
  17885. * Defines the center of rotation (V)
  17886. */
  17887. vRotationCenter: number;
  17888. /**
  17889. * Defines the center of rotation (W)
  17890. */
  17891. wRotationCenter: number;
  17892. /**
  17893. * Are mip maps generated for this texture or not.
  17894. */
  17895. readonly noMipmap: boolean;
  17896. /**
  17897. * List of inspectable custom properties (used by the Inspector)
  17898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17899. */
  17900. inspectableCustomProperties: Nullable<IInspectable[]>;
  17901. private _noMipmap;
  17902. /** @hidden */ invertY: boolean;
  17903. private _rowGenerationMatrix;
  17904. private _cachedTextureMatrix;
  17905. private _projectionModeMatrix;
  17906. private _t0;
  17907. private _t1;
  17908. private _t2;
  17909. private _cachedUOffset;
  17910. private _cachedVOffset;
  17911. private _cachedUScale;
  17912. private _cachedVScale;
  17913. private _cachedUAng;
  17914. private _cachedVAng;
  17915. private _cachedWAng;
  17916. private _cachedProjectionMatrixId;
  17917. private _cachedCoordinatesMode;
  17918. /** @hidden */
  17919. protected _initialSamplingMode: number;
  17920. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17921. private _deleteBuffer;
  17922. protected _format: Nullable<number>;
  17923. private _delayedOnLoad;
  17924. private _delayedOnError;
  17925. /**
  17926. * Observable triggered once the texture has been loaded.
  17927. */
  17928. onLoadObservable: Observable<Texture>;
  17929. protected _isBlocking: boolean;
  17930. /**
  17931. * Is the texture preventing material to render while loading.
  17932. * If false, a default texture will be used instead of the loading one during the preparation step.
  17933. */
  17934. isBlocking: boolean;
  17935. /**
  17936. * Get the current sampling mode associated with the texture.
  17937. */
  17938. readonly samplingMode: number;
  17939. /**
  17940. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17941. */
  17942. readonly invertY: boolean;
  17943. /**
  17944. * Instantiates a new texture.
  17945. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17946. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17947. * @param url define the url of the picture to load as a texture
  17948. * @param scene define the scene the texture will belong to
  17949. * @param noMipmap define if the texture will require mip maps or not
  17950. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17951. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17952. * @param onLoad define a callback triggered when the texture has been loaded
  17953. * @param onError define a callback triggered when an error occurred during the loading session
  17954. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17955. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17956. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17957. */
  17958. 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);
  17959. /**
  17960. * Update the url (and optional buffer) of this texture if url was null during construction.
  17961. * @param url the url of the texture
  17962. * @param buffer the buffer of the texture (defaults to null)
  17963. * @param onLoad callback called when the texture is loaded (defaults to null)
  17964. */
  17965. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17966. /**
  17967. * Finish the loading sequence of a texture flagged as delayed load.
  17968. * @hidden
  17969. */
  17970. delayLoad(): void;
  17971. private _prepareRowForTextureGeneration;
  17972. /**
  17973. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17974. * @returns the transform matrix of the texture.
  17975. */
  17976. getTextureMatrix(): Matrix;
  17977. /**
  17978. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17979. * @returns The reflection texture transform
  17980. */
  17981. getReflectionTextureMatrix(): Matrix;
  17982. /**
  17983. * Clones the texture.
  17984. * @returns the cloned texture
  17985. */
  17986. clone(): Texture;
  17987. /**
  17988. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17989. * @returns The JSON representation of the texture
  17990. */
  17991. serialize(): any;
  17992. /**
  17993. * Get the current class name of the texture useful for serialization or dynamic coding.
  17994. * @returns "Texture"
  17995. */
  17996. getClassName(): string;
  17997. /**
  17998. * Dispose the texture and release its associated resources.
  17999. */
  18000. dispose(): void;
  18001. /**
  18002. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18003. * @param parsedTexture Define the JSON representation of the texture
  18004. * @param scene Define the scene the parsed texture should be instantiated in
  18005. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18006. * @returns The parsed texture if successful
  18007. */
  18008. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18009. /**
  18010. * Creates a texture from its base 64 representation.
  18011. * @param data Define the base64 payload without the data: prefix
  18012. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18013. * @param scene Define the scene the texture should belong to
  18014. * @param noMipmap Forces the texture to not create mip map information if true
  18015. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18016. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18017. * @param onLoad define a callback triggered when the texture has been loaded
  18018. * @param onError define a callback triggered when an error occurred during the loading session
  18019. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18020. * @returns the created texture
  18021. */
  18022. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18023. /**
  18024. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18025. * @param data Define the base64 payload without the data: prefix
  18026. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18027. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18028. * @param scene Define the scene the texture should belong to
  18029. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18030. * @param noMipmap Forces the texture to not create mip map information if true
  18031. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18032. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18033. * @param onLoad define a callback triggered when the texture has been loaded
  18034. * @param onError define a callback triggered when an error occurred during the loading session
  18035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18036. * @returns the created texture
  18037. */
  18038. 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;
  18039. }
  18040. }
  18041. declare module BABYLON {
  18042. interface Engine {
  18043. /**
  18044. * Creates a raw texture
  18045. * @param data defines the data to store in the texture
  18046. * @param width defines the width of the texture
  18047. * @param height defines the height of the texture
  18048. * @param format defines the format of the data
  18049. * @param generateMipMaps defines if the engine should generate the mip levels
  18050. * @param invertY defines if data must be stored with Y axis inverted
  18051. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18052. * @param compression defines the compression used (null by default)
  18053. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18054. * @returns the raw texture inside an InternalTexture
  18055. */
  18056. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18057. /**
  18058. * Update a raw texture
  18059. * @param texture defines the texture to update
  18060. * @param data defines the data to store in the texture
  18061. * @param format defines the format of the data
  18062. * @param invertY defines if data must be stored with Y axis inverted
  18063. */
  18064. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18065. /**
  18066. * Update a raw texture
  18067. * @param texture defines the texture to update
  18068. * @param data defines the data to store in the texture
  18069. * @param format defines the format of the data
  18070. * @param invertY defines if data must be stored with Y axis inverted
  18071. * @param compression defines the compression used (null by default)
  18072. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18073. */
  18074. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18075. /**
  18076. * Creates a new raw cube texture
  18077. * @param data defines the array of data to use to create each face
  18078. * @param size defines the size of the textures
  18079. * @param format defines the format of the data
  18080. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18081. * @param generateMipMaps defines if the engine should generate the mip levels
  18082. * @param invertY defines if data must be stored with Y axis inverted
  18083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18084. * @param compression defines the compression used (null by default)
  18085. * @returns the cube texture as an InternalTexture
  18086. */
  18087. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18088. /**
  18089. * Update a raw cube texture
  18090. * @param texture defines the texture to udpdate
  18091. * @param data defines the data to store
  18092. * @param format defines the data format
  18093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18094. * @param invertY defines if data must be stored with Y axis inverted
  18095. */
  18096. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18097. /**
  18098. * Update a raw cube texture
  18099. * @param texture defines the texture to udpdate
  18100. * @param data defines the data to store
  18101. * @param format defines the data format
  18102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18103. * @param invertY defines if data must be stored with Y axis inverted
  18104. * @param compression defines the compression used (null by default)
  18105. */
  18106. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18107. /**
  18108. * Update a raw cube texture
  18109. * @param texture defines the texture to udpdate
  18110. * @param data defines the data to store
  18111. * @param format defines the data format
  18112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18113. * @param invertY defines if data must be stored with Y axis inverted
  18114. * @param compression defines the compression used (null by default)
  18115. * @param level defines which level of the texture to update
  18116. */
  18117. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18118. /**
  18119. * Creates a new raw cube texture from a specified url
  18120. * @param url defines the url where the data is located
  18121. * @param scene defines the current scene
  18122. * @param size defines the size of the textures
  18123. * @param format defines the format of the data
  18124. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18125. * @param noMipmap defines if the engine should avoid generating the mip levels
  18126. * @param callback defines a callback used to extract texture data from loaded data
  18127. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18128. * @param onLoad defines a callback called when texture is loaded
  18129. * @param onError defines a callback called if there is an error
  18130. * @returns the cube texture as an InternalTexture
  18131. */
  18132. 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;
  18133. /**
  18134. * Creates a new raw cube texture from a specified url
  18135. * @param url defines the url where the data is located
  18136. * @param scene defines the current scene
  18137. * @param size defines the size of the textures
  18138. * @param format defines the format of the data
  18139. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18140. * @param noMipmap defines if the engine should avoid generating the mip levels
  18141. * @param callback defines a callback used to extract texture data from loaded data
  18142. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18143. * @param onLoad defines a callback called when texture is loaded
  18144. * @param onError defines a callback called if there is an error
  18145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18146. * @param invertY defines if data must be stored with Y axis inverted
  18147. * @returns the cube texture as an InternalTexture
  18148. */
  18149. 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;
  18150. /**
  18151. * Creates a new raw 3D texture
  18152. * @param data defines the data used to create the texture
  18153. * @param width defines the width of the texture
  18154. * @param height defines the height of the texture
  18155. * @param depth defines the depth of the texture
  18156. * @param format defines the format of the texture
  18157. * @param generateMipMaps defines if the engine must generate mip levels
  18158. * @param invertY defines if data must be stored with Y axis inverted
  18159. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18160. * @param compression defines the compressed used (can be null)
  18161. * @param textureType defines the compressed used (can be null)
  18162. * @returns a new raw 3D texture (stored in an InternalTexture)
  18163. */
  18164. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18165. /**
  18166. * Update a raw 3D texture
  18167. * @param texture defines the texture to update
  18168. * @param data defines the data to store
  18169. * @param format defines the data format
  18170. * @param invertY defines if data must be stored with Y axis inverted
  18171. */
  18172. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18173. /**
  18174. * Update a raw 3D texture
  18175. * @param texture defines the texture to update
  18176. * @param data defines the data to store
  18177. * @param format defines the data format
  18178. * @param invertY defines if data must be stored with Y axis inverted
  18179. * @param compression defines the used compression (can be null)
  18180. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18181. */
  18182. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. /**
  18187. * Raw texture can help creating a texture directly from an array of data.
  18188. * This can be super useful if you either get the data from an uncompressed source or
  18189. * if you wish to create your texture pixel by pixel.
  18190. */
  18191. export class RawTexture extends Texture {
  18192. /**
  18193. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18194. */
  18195. format: number;
  18196. private _engine;
  18197. /**
  18198. * Instantiates a new RawTexture.
  18199. * Raw texture can help creating a texture directly from an array of data.
  18200. * This can be super useful if you either get the data from an uncompressed source or
  18201. * if you wish to create your texture pixel by pixel.
  18202. * @param data define the array of data to use to create the texture
  18203. * @param width define the width of the texture
  18204. * @param height define the height of the texture
  18205. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18206. * @param scene define the scene the texture belongs to
  18207. * @param generateMipMaps define whether mip maps should be generated or not
  18208. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18209. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18210. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18211. */
  18212. constructor(data: ArrayBufferView, width: number, height: number,
  18213. /**
  18214. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18215. */
  18216. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18217. /**
  18218. * Updates the texture underlying data.
  18219. * @param data Define the new data of the texture
  18220. */
  18221. update(data: ArrayBufferView): void;
  18222. /**
  18223. * Creates a luminance texture from some data.
  18224. * @param data Define the texture data
  18225. * @param width Define the width of the texture
  18226. * @param height Define the height of the texture
  18227. * @param scene Define the scene the texture belongs to
  18228. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18229. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18230. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18231. * @returns the luminance texture
  18232. */
  18233. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18234. /**
  18235. * Creates a luminance alpha texture from some data.
  18236. * @param data Define the texture data
  18237. * @param width Define the width of the texture
  18238. * @param height Define the height of the texture
  18239. * @param scene Define the scene the texture belongs to
  18240. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18241. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18242. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18243. * @returns the luminance alpha texture
  18244. */
  18245. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18246. /**
  18247. * Creates an alpha texture from some data.
  18248. * @param data Define the texture data
  18249. * @param width Define the width of the texture
  18250. * @param height Define the height of the texture
  18251. * @param scene Define the scene the texture belongs to
  18252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18255. * @returns the alpha texture
  18256. */
  18257. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18258. /**
  18259. * Creates a RGB texture from some data.
  18260. * @param data Define the texture data
  18261. * @param width Define the width of the texture
  18262. * @param height Define the height of the texture
  18263. * @param scene Define the scene the texture belongs to
  18264. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18265. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18266. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18267. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18268. * @returns the RGB alpha texture
  18269. */
  18270. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18271. /**
  18272. * Creates a RGBA texture from some data.
  18273. * @param data Define the texture data
  18274. * @param width Define the width of the texture
  18275. * @param height Define the height of the texture
  18276. * @param scene Define the scene the texture belongs to
  18277. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18278. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18279. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18280. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18281. * @returns the RGBA texture
  18282. */
  18283. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18284. /**
  18285. * Creates a R texture from some data.
  18286. * @param data Define the texture data
  18287. * @param width Define the width of the texture
  18288. * @param height Define the height of the texture
  18289. * @param scene Define the scene the texture belongs to
  18290. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18293. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18294. * @returns the R texture
  18295. */
  18296. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Defines a runtime animation
  18302. */
  18303. export class RuntimeAnimation {
  18304. private _events;
  18305. /**
  18306. * The current frame of the runtime animation
  18307. */
  18308. private _currentFrame;
  18309. /**
  18310. * The animation used by the runtime animation
  18311. */
  18312. private _animation;
  18313. /**
  18314. * The target of the runtime animation
  18315. */
  18316. private _target;
  18317. /**
  18318. * The initiating animatable
  18319. */
  18320. private _host;
  18321. /**
  18322. * The original value of the runtime animation
  18323. */
  18324. private _originalValue;
  18325. /**
  18326. * The original blend value of the runtime animation
  18327. */
  18328. private _originalBlendValue;
  18329. /**
  18330. * The offsets cache of the runtime animation
  18331. */
  18332. private _offsetsCache;
  18333. /**
  18334. * The high limits cache of the runtime animation
  18335. */
  18336. private _highLimitsCache;
  18337. /**
  18338. * Specifies if the runtime animation has been stopped
  18339. */
  18340. private _stopped;
  18341. /**
  18342. * The blending factor of the runtime animation
  18343. */
  18344. private _blendingFactor;
  18345. /**
  18346. * The BabylonJS scene
  18347. */
  18348. private _scene;
  18349. /**
  18350. * The current value of the runtime animation
  18351. */
  18352. private _currentValue;
  18353. /** @hidden */ animationState: _IAnimationState;
  18354. /**
  18355. * The active target of the runtime animation
  18356. */
  18357. private _activeTargets;
  18358. private _currentActiveTarget;
  18359. private _directTarget;
  18360. /**
  18361. * The target path of the runtime animation
  18362. */
  18363. private _targetPath;
  18364. /**
  18365. * The weight of the runtime animation
  18366. */
  18367. private _weight;
  18368. /**
  18369. * The ratio offset of the runtime animation
  18370. */
  18371. private _ratioOffset;
  18372. /**
  18373. * The previous delay of the runtime animation
  18374. */
  18375. private _previousDelay;
  18376. /**
  18377. * The previous ratio of the runtime animation
  18378. */
  18379. private _previousRatio;
  18380. private _enableBlending;
  18381. private _keys;
  18382. private _minFrame;
  18383. private _maxFrame;
  18384. private _minValue;
  18385. private _maxValue;
  18386. private _targetIsArray;
  18387. /**
  18388. * Gets the current frame of the runtime animation
  18389. */
  18390. readonly currentFrame: number;
  18391. /**
  18392. * Gets the weight of the runtime animation
  18393. */
  18394. readonly weight: number;
  18395. /**
  18396. * Gets the current value of the runtime animation
  18397. */
  18398. readonly currentValue: any;
  18399. /**
  18400. * Gets the target path of the runtime animation
  18401. */
  18402. readonly targetPath: string;
  18403. /**
  18404. * Gets the actual target of the runtime animation
  18405. */
  18406. readonly target: any;
  18407. /** @hidden */ onLoop: () => void;
  18408. /**
  18409. * Create a new RuntimeAnimation object
  18410. * @param target defines the target of the animation
  18411. * @param animation defines the source animation object
  18412. * @param scene defines the hosting scene
  18413. * @param host defines the initiating Animatable
  18414. */
  18415. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18416. private _preparePath;
  18417. /**
  18418. * Gets the animation from the runtime animation
  18419. */
  18420. readonly animation: Animation;
  18421. /**
  18422. * Resets the runtime animation to the beginning
  18423. * @param restoreOriginal defines whether to restore the target property to the original value
  18424. */
  18425. reset(restoreOriginal?: boolean): void;
  18426. /**
  18427. * Specifies if the runtime animation is stopped
  18428. * @returns Boolean specifying if the runtime animation is stopped
  18429. */
  18430. isStopped(): boolean;
  18431. /**
  18432. * Disposes of the runtime animation
  18433. */
  18434. dispose(): void;
  18435. /**
  18436. * Apply the interpolated value to the target
  18437. * @param currentValue defines the value computed by the animation
  18438. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18439. */
  18440. setValue(currentValue: any, weight: number): void;
  18441. private _getOriginalValues;
  18442. private _setValue;
  18443. /**
  18444. * Gets the loop pmode of the runtime animation
  18445. * @returns Loop Mode
  18446. */
  18447. private _getCorrectLoopMode;
  18448. /**
  18449. * Move the current animation to a given frame
  18450. * @param frame defines the frame to move to
  18451. */
  18452. goToFrame(frame: number): void;
  18453. /**
  18454. * @hidden Internal use only
  18455. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18456. /**
  18457. * Execute the current animation
  18458. * @param delay defines the delay to add to the current frame
  18459. * @param from defines the lower bound of the animation range
  18460. * @param to defines the upper bound of the animation range
  18461. * @param loop defines if the current animation must loop
  18462. * @param speedRatio defines the current speed ratio
  18463. * @param weight defines the weight of the animation (default is -1 so no weight)
  18464. * @param onLoop optional callback called when animation loops
  18465. * @returns a boolean indicating if the animation is running
  18466. */
  18467. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18468. }
  18469. }
  18470. declare module BABYLON {
  18471. /**
  18472. * Class used to store an actual running animation
  18473. */
  18474. export class Animatable {
  18475. /** defines the target object */
  18476. target: any;
  18477. /** defines the starting frame number (default is 0) */
  18478. fromFrame: number;
  18479. /** defines the ending frame number (default is 100) */
  18480. toFrame: number;
  18481. /** defines if the animation must loop (default is false) */
  18482. loopAnimation: boolean;
  18483. /** defines a callback to call when animation ends if it is not looping */
  18484. onAnimationEnd?: (() => void) | null | undefined;
  18485. /** defines a callback to call when animation loops */
  18486. onAnimationLoop?: (() => void) | null | undefined;
  18487. private _localDelayOffset;
  18488. private _pausedDelay;
  18489. private _runtimeAnimations;
  18490. private _paused;
  18491. private _scene;
  18492. private _speedRatio;
  18493. private _weight;
  18494. private _syncRoot;
  18495. /**
  18496. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18497. * This will only apply for non looping animation (default is true)
  18498. */
  18499. disposeOnEnd: boolean;
  18500. /**
  18501. * Gets a boolean indicating if the animation has started
  18502. */
  18503. animationStarted: boolean;
  18504. /**
  18505. * Observer raised when the animation ends
  18506. */
  18507. onAnimationEndObservable: Observable<Animatable>;
  18508. /**
  18509. * Observer raised when the animation loops
  18510. */
  18511. onAnimationLoopObservable: Observable<Animatable>;
  18512. /**
  18513. * Gets the root Animatable used to synchronize and normalize animations
  18514. */
  18515. readonly syncRoot: Nullable<Animatable>;
  18516. /**
  18517. * Gets the current frame of the first RuntimeAnimation
  18518. * Used to synchronize Animatables
  18519. */
  18520. readonly masterFrame: number;
  18521. /**
  18522. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18523. */
  18524. weight: number;
  18525. /**
  18526. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18527. */
  18528. speedRatio: number;
  18529. /**
  18530. * Creates a new Animatable
  18531. * @param scene defines the hosting scene
  18532. * @param target defines the target object
  18533. * @param fromFrame defines the starting frame number (default is 0)
  18534. * @param toFrame defines the ending frame number (default is 100)
  18535. * @param loopAnimation defines if the animation must loop (default is false)
  18536. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18537. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18538. * @param animations defines a group of animation to add to the new Animatable
  18539. * @param onAnimationLoop defines a callback to call when animation loops
  18540. */
  18541. constructor(scene: Scene,
  18542. /** defines the target object */
  18543. target: any,
  18544. /** defines the starting frame number (default is 0) */
  18545. fromFrame?: number,
  18546. /** defines the ending frame number (default is 100) */
  18547. toFrame?: number,
  18548. /** defines if the animation must loop (default is false) */
  18549. loopAnimation?: boolean, speedRatio?: number,
  18550. /** defines a callback to call when animation ends if it is not looping */
  18551. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18552. /** defines a callback to call when animation loops */
  18553. onAnimationLoop?: (() => void) | null | undefined);
  18554. /**
  18555. * Synchronize and normalize current Animatable with a source Animatable
  18556. * This is useful when using animation weights and when animations are not of the same length
  18557. * @param root defines the root Animatable to synchronize with
  18558. * @returns the current Animatable
  18559. */
  18560. syncWith(root: Animatable): Animatable;
  18561. /**
  18562. * Gets the list of runtime animations
  18563. * @returns an array of RuntimeAnimation
  18564. */
  18565. getAnimations(): RuntimeAnimation[];
  18566. /**
  18567. * Adds more animations to the current animatable
  18568. * @param target defines the target of the animations
  18569. * @param animations defines the new animations to add
  18570. */
  18571. appendAnimations(target: any, animations: Animation[]): void;
  18572. /**
  18573. * Gets the source animation for a specific property
  18574. * @param property defines the propertyu to look for
  18575. * @returns null or the source animation for the given property
  18576. */
  18577. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18578. /**
  18579. * Gets the runtime animation for a specific property
  18580. * @param property defines the propertyu to look for
  18581. * @returns null or the runtime animation for the given property
  18582. */
  18583. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18584. /**
  18585. * Resets the animatable to its original state
  18586. */
  18587. reset(): void;
  18588. /**
  18589. * Allows the animatable to blend with current running animations
  18590. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18591. * @param blendingSpeed defines the blending speed to use
  18592. */
  18593. enableBlending(blendingSpeed: number): void;
  18594. /**
  18595. * Disable animation blending
  18596. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18597. */
  18598. disableBlending(): void;
  18599. /**
  18600. * Jump directly to a given frame
  18601. * @param frame defines the frame to jump to
  18602. */
  18603. goToFrame(frame: number): void;
  18604. /**
  18605. * Pause the animation
  18606. */
  18607. pause(): void;
  18608. /**
  18609. * Restart the animation
  18610. */
  18611. restart(): void;
  18612. private _raiseOnAnimationEnd;
  18613. /**
  18614. * Stop and delete the current animation
  18615. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18616. * @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)
  18617. */
  18618. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18619. /**
  18620. * Wait asynchronously for the animation to end
  18621. * @returns a promise which will be fullfilled when the animation ends
  18622. */
  18623. waitAsync(): Promise<Animatable>;
  18624. /** @hidden */ animate(delay: number): boolean;
  18625. }
  18626. interface Scene {
  18627. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18628. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18629. totalWeight: number;
  18630. animations: RuntimeAnimation[];
  18631. originalValue: Matrix;
  18632. }): any;
  18633. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18634. totalWeight: number;
  18635. animations: RuntimeAnimation[];
  18636. originalValue: Quaternion;
  18637. }, refQuaternion: Quaternion): Quaternion;
  18638. /** @hidden */ processLateAnimationBindings(): void;
  18639. /**
  18640. * Will start the animation sequence of a given target
  18641. * @param target defines the target
  18642. * @param from defines from which frame should animation start
  18643. * @param to defines until which frame should animation run.
  18644. * @param weight defines the weight to apply to the animation (1.0 by default)
  18645. * @param loop defines if the animation loops
  18646. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18647. * @param onAnimationEnd defines the function to be executed when the animation ends
  18648. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18649. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18650. * @param onAnimationLoop defines the callback to call when an animation loops
  18651. * @returns the animatable object created for this animation
  18652. */
  18653. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18654. /**
  18655. * Will start the animation sequence of a given target
  18656. * @param target defines the target
  18657. * @param from defines from which frame should animation start
  18658. * @param to defines until which frame should animation run.
  18659. * @param loop defines if the animation loops
  18660. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18661. * @param onAnimationEnd defines the function to be executed when the animation ends
  18662. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18663. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18664. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18665. * @param onAnimationLoop defines the callback to call when an animation loops
  18666. * @returns the animatable object created for this animation
  18667. */
  18668. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18669. /**
  18670. * Will start the animation sequence of a given target and its hierarchy
  18671. * @param target defines the target
  18672. * @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.
  18673. * @param from defines from which frame should animation start
  18674. * @param to defines until which frame should animation run.
  18675. * @param loop defines if the animation loops
  18676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18677. * @param onAnimationEnd defines the function to be executed when the animation ends
  18678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18679. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18680. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18681. * @param onAnimationLoop defines the callback to call when an animation loops
  18682. * @returns the list of created animatables
  18683. */
  18684. 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[];
  18685. /**
  18686. * Begin a new animation on a given node
  18687. * @param target defines the target where the animation will take place
  18688. * @param animations defines the list of animations to start
  18689. * @param from defines the initial value
  18690. * @param to defines the final value
  18691. * @param loop defines if you want animation to loop (off by default)
  18692. * @param speedRatio defines the speed ratio to apply to all animations
  18693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18694. * @param onAnimationLoop defines the callback to call when an animation loops
  18695. * @returns the list of created animatables
  18696. */
  18697. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18698. /**
  18699. * Begin a new animation on a given node and its hierarchy
  18700. * @param target defines the root node where the animation will take place
  18701. * @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.
  18702. * @param animations defines the list of animations to start
  18703. * @param from defines the initial value
  18704. * @param to defines the final value
  18705. * @param loop defines if you want animation to loop (off by default)
  18706. * @param speedRatio defines the speed ratio to apply to all animations
  18707. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18708. * @param onAnimationLoop defines the callback to call when an animation loops
  18709. * @returns the list of animatables created for all nodes
  18710. */
  18711. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18712. /**
  18713. * Gets the animatable associated with a specific target
  18714. * @param target defines the target of the animatable
  18715. * @returns the required animatable if found
  18716. */
  18717. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18718. /**
  18719. * Gets all animatables associated with a given target
  18720. * @param target defines the target to look animatables for
  18721. * @returns an array of Animatables
  18722. */
  18723. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18724. /**
  18725. * Will stop the animation of the given target
  18726. * @param target - the target
  18727. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18728. * @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)
  18729. */
  18730. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18731. /**
  18732. * Stops and removes all animations that have been applied to the scene
  18733. */
  18734. stopAllAnimations(): void;
  18735. }
  18736. interface Bone {
  18737. /**
  18738. * Copy an animation range from another bone
  18739. * @param source defines the source bone
  18740. * @param rangeName defines the range name to copy
  18741. * @param frameOffset defines the frame offset
  18742. * @param rescaleAsRequired defines if rescaling must be applied if required
  18743. * @param skelDimensionsRatio defines the scaling ratio
  18744. * @returns true if operation was successful
  18745. */
  18746. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18747. }
  18748. }
  18749. declare module BABYLON {
  18750. /**
  18751. * Class used to handle skinning animations
  18752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18753. */
  18754. export class Skeleton implements IAnimatable {
  18755. /** defines the skeleton name */
  18756. name: string;
  18757. /** defines the skeleton Id */
  18758. id: string;
  18759. /**
  18760. * Defines the list of child bones
  18761. */
  18762. bones: Bone[];
  18763. /**
  18764. * Defines an estimate of the dimension of the skeleton at rest
  18765. */
  18766. dimensionsAtRest: Vector3;
  18767. /**
  18768. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18769. */
  18770. needInitialSkinMatrix: boolean;
  18771. /**
  18772. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18773. */
  18774. overrideMesh: Nullable<AbstractMesh>;
  18775. /**
  18776. * Gets the list of animations attached to this skeleton
  18777. */
  18778. animations: Array<Animation>;
  18779. private _scene;
  18780. private _isDirty;
  18781. private _transformMatrices;
  18782. private _transformMatrixTexture;
  18783. private _meshesWithPoseMatrix;
  18784. private _animatables;
  18785. private _identity;
  18786. private _synchronizedWithMesh;
  18787. private _ranges;
  18788. private _lastAbsoluteTransformsUpdateId;
  18789. private _canUseTextureForBones;
  18790. private _uniqueId;
  18791. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18792. /**
  18793. * Specifies if the skeleton should be serialized
  18794. */
  18795. doNotSerialize: boolean;
  18796. private _useTextureToStoreBoneMatrices;
  18797. /**
  18798. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18799. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18800. */
  18801. useTextureToStoreBoneMatrices: boolean;
  18802. private _animationPropertiesOverride;
  18803. /**
  18804. * Gets or sets the animation properties override
  18805. */
  18806. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18807. /**
  18808. * List of inspectable custom properties (used by the Inspector)
  18809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18810. */
  18811. inspectableCustomProperties: IInspectable[];
  18812. /**
  18813. * An observable triggered before computing the skeleton's matrices
  18814. */
  18815. onBeforeComputeObservable: Observable<Skeleton>;
  18816. /**
  18817. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18818. */
  18819. readonly isUsingTextureForMatrices: boolean;
  18820. /**
  18821. * Gets the unique ID of this skeleton
  18822. */
  18823. readonly uniqueId: number;
  18824. /**
  18825. * Creates a new skeleton
  18826. * @param name defines the skeleton name
  18827. * @param id defines the skeleton Id
  18828. * @param scene defines the hosting scene
  18829. */
  18830. constructor(
  18831. /** defines the skeleton name */
  18832. name: string,
  18833. /** defines the skeleton Id */
  18834. id: string, scene: Scene);
  18835. /**
  18836. * Gets the current object class name.
  18837. * @return the class name
  18838. */
  18839. getClassName(): string;
  18840. /**
  18841. * Returns an array containing the root bones
  18842. * @returns an array containing the root bones
  18843. */
  18844. getChildren(): Array<Bone>;
  18845. /**
  18846. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18847. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18848. * @returns a Float32Array containing matrices data
  18849. */
  18850. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18851. /**
  18852. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18853. * @returns a raw texture containing the data
  18854. */
  18855. getTransformMatrixTexture(): Nullable<RawTexture>;
  18856. /**
  18857. * Gets the current hosting scene
  18858. * @returns a scene object
  18859. */
  18860. getScene(): Scene;
  18861. /**
  18862. * Gets a string representing the current skeleton data
  18863. * @param fullDetails defines a boolean indicating if we want a verbose version
  18864. * @returns a string representing the current skeleton data
  18865. */
  18866. toString(fullDetails?: boolean): string;
  18867. /**
  18868. * Get bone's index searching by name
  18869. * @param name defines bone's name to search for
  18870. * @return the indice of the bone. Returns -1 if not found
  18871. */
  18872. getBoneIndexByName(name: string): number;
  18873. /**
  18874. * Creater a new animation range
  18875. * @param name defines the name of the range
  18876. * @param from defines the start key
  18877. * @param to defines the end key
  18878. */
  18879. createAnimationRange(name: string, from: number, to: number): void;
  18880. /**
  18881. * Delete a specific animation range
  18882. * @param name defines the name of the range
  18883. * @param deleteFrames defines if frames must be removed as well
  18884. */
  18885. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18886. /**
  18887. * Gets a specific animation range
  18888. * @param name defines the name of the range to look for
  18889. * @returns the requested animation range or null if not found
  18890. */
  18891. getAnimationRange(name: string): Nullable<AnimationRange>;
  18892. /**
  18893. * Gets the list of all animation ranges defined on this skeleton
  18894. * @returns an array
  18895. */
  18896. getAnimationRanges(): Nullable<AnimationRange>[];
  18897. /**
  18898. * Copy animation range from a source skeleton.
  18899. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18900. * @param source defines the source skeleton
  18901. * @param name defines the name of the range to copy
  18902. * @param rescaleAsRequired defines if rescaling must be applied if required
  18903. * @returns true if operation was successful
  18904. */
  18905. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18906. /**
  18907. * Forces the skeleton to go to rest pose
  18908. */
  18909. returnToRest(): void;
  18910. private _getHighestAnimationFrame;
  18911. /**
  18912. * Begin a specific animation range
  18913. * @param name defines the name of the range to start
  18914. * @param loop defines if looping must be turned on (false by default)
  18915. * @param speedRatio defines the speed ratio to apply (1 by default)
  18916. * @param onAnimationEnd defines a callback which will be called when animation will end
  18917. * @returns a new animatable
  18918. */
  18919. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18920. /** @hidden */ markAsDirty(): void;
  18921. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18922. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18923. private _computeTransformMatrices;
  18924. /**
  18925. * Build all resources required to render a skeleton
  18926. */
  18927. prepare(): void;
  18928. /**
  18929. * Gets the list of animatables currently running for this skeleton
  18930. * @returns an array of animatables
  18931. */
  18932. getAnimatables(): IAnimatable[];
  18933. /**
  18934. * Clone the current skeleton
  18935. * @param name defines the name of the new skeleton
  18936. * @param id defines the id of the new skeleton
  18937. * @returns the new skeleton
  18938. */
  18939. clone(name: string, id: string): Skeleton;
  18940. /**
  18941. * Enable animation blending for this skeleton
  18942. * @param blendingSpeed defines the blending speed to apply
  18943. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18944. */
  18945. enableBlending(blendingSpeed?: number): void;
  18946. /**
  18947. * Releases all resources associated with the current skeleton
  18948. */
  18949. dispose(): void;
  18950. /**
  18951. * Serialize the skeleton in a JSON object
  18952. * @returns a JSON object
  18953. */
  18954. serialize(): any;
  18955. /**
  18956. * Creates a new skeleton from serialized data
  18957. * @param parsedSkeleton defines the serialized data
  18958. * @param scene defines the hosting scene
  18959. * @returns a new skeleton
  18960. */
  18961. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18962. /**
  18963. * Compute all node absolute transforms
  18964. * @param forceUpdate defines if computation must be done even if cache is up to date
  18965. */
  18966. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18967. /**
  18968. * Gets the root pose matrix
  18969. * @returns a matrix
  18970. */
  18971. getPoseMatrix(): Nullable<Matrix>;
  18972. /**
  18973. * Sorts bones per internal index
  18974. */
  18975. sortBones(): void;
  18976. private _sortBones;
  18977. }
  18978. }
  18979. declare module BABYLON {
  18980. /**
  18981. * Defines a target to use with MorphTargetManager
  18982. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18983. */
  18984. export class MorphTarget implements IAnimatable {
  18985. /** defines the name of the target */
  18986. name: string;
  18987. /**
  18988. * Gets or sets the list of animations
  18989. */
  18990. animations: Animation[];
  18991. private _scene;
  18992. private _positions;
  18993. private _normals;
  18994. private _tangents;
  18995. private _influence;
  18996. /**
  18997. * Observable raised when the influence changes
  18998. */
  18999. onInfluenceChanged: Observable<boolean>;
  19000. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19001. /**
  19002. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19003. */
  19004. influence: number;
  19005. /**
  19006. * Gets or sets the id of the morph Target
  19007. */
  19008. id: string;
  19009. private _animationPropertiesOverride;
  19010. /**
  19011. * Gets or sets the animation properties override
  19012. */
  19013. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19014. /**
  19015. * Creates a new MorphTarget
  19016. * @param name defines the name of the target
  19017. * @param influence defines the influence to use
  19018. * @param scene defines the scene the morphtarget belongs to
  19019. */
  19020. constructor(
  19021. /** defines the name of the target */
  19022. name: string, influence?: number, scene?: Nullable<Scene>);
  19023. /**
  19024. * Gets a boolean defining if the target contains position data
  19025. */
  19026. readonly hasPositions: boolean;
  19027. /**
  19028. * Gets a boolean defining if the target contains normal data
  19029. */
  19030. readonly hasNormals: boolean;
  19031. /**
  19032. * Gets a boolean defining if the target contains tangent data
  19033. */
  19034. readonly hasTangents: boolean;
  19035. /**
  19036. * Affects position data to this target
  19037. * @param data defines the position data to use
  19038. */
  19039. setPositions(data: Nullable<FloatArray>): void;
  19040. /**
  19041. * Gets the position data stored in this target
  19042. * @returns a FloatArray containing the position data (or null if not present)
  19043. */
  19044. getPositions(): Nullable<FloatArray>;
  19045. /**
  19046. * Affects normal data to this target
  19047. * @param data defines the normal data to use
  19048. */
  19049. setNormals(data: Nullable<FloatArray>): void;
  19050. /**
  19051. * Gets the normal data stored in this target
  19052. * @returns a FloatArray containing the normal data (or null if not present)
  19053. */
  19054. getNormals(): Nullable<FloatArray>;
  19055. /**
  19056. * Affects tangent data to this target
  19057. * @param data defines the tangent data to use
  19058. */
  19059. setTangents(data: Nullable<FloatArray>): void;
  19060. /**
  19061. * Gets the tangent data stored in this target
  19062. * @returns a FloatArray containing the tangent data (or null if not present)
  19063. */
  19064. getTangents(): Nullable<FloatArray>;
  19065. /**
  19066. * Serializes the current target into a Serialization object
  19067. * @returns the serialized object
  19068. */
  19069. serialize(): any;
  19070. /**
  19071. * Returns the string "MorphTarget"
  19072. * @returns "MorphTarget"
  19073. */
  19074. getClassName(): string;
  19075. /**
  19076. * Creates a new target from serialized data
  19077. * @param serializationObject defines the serialized data to use
  19078. * @returns a new MorphTarget
  19079. */
  19080. static Parse(serializationObject: any): MorphTarget;
  19081. /**
  19082. * Creates a MorphTarget from mesh data
  19083. * @param mesh defines the source mesh
  19084. * @param name defines the name to use for the new target
  19085. * @param influence defines the influence to attach to the target
  19086. * @returns a new MorphTarget
  19087. */
  19088. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19089. }
  19090. }
  19091. declare module BABYLON {
  19092. /**
  19093. * This class is used to deform meshes using morphing between different targets
  19094. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19095. */
  19096. export class MorphTargetManager {
  19097. private _targets;
  19098. private _targetInfluenceChangedObservers;
  19099. private _targetDataLayoutChangedObservers;
  19100. private _activeTargets;
  19101. private _scene;
  19102. private _influences;
  19103. private _supportsNormals;
  19104. private _supportsTangents;
  19105. private _vertexCount;
  19106. private _uniqueId;
  19107. private _tempInfluences;
  19108. /**
  19109. * Creates a new MorphTargetManager
  19110. * @param scene defines the current scene
  19111. */
  19112. constructor(scene?: Nullable<Scene>);
  19113. /**
  19114. * Gets the unique ID of this manager
  19115. */
  19116. readonly uniqueId: number;
  19117. /**
  19118. * Gets the number of vertices handled by this manager
  19119. */
  19120. readonly vertexCount: number;
  19121. /**
  19122. * Gets a boolean indicating if this manager supports morphing of normals
  19123. */
  19124. readonly supportsNormals: boolean;
  19125. /**
  19126. * Gets a boolean indicating if this manager supports morphing of tangents
  19127. */
  19128. readonly supportsTangents: boolean;
  19129. /**
  19130. * Gets the number of targets stored in this manager
  19131. */
  19132. readonly numTargets: number;
  19133. /**
  19134. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19135. */
  19136. readonly numInfluencers: number;
  19137. /**
  19138. * Gets the list of influences (one per target)
  19139. */
  19140. readonly influences: Float32Array;
  19141. /**
  19142. * Gets the active target at specified index. An active target is a target with an influence > 0
  19143. * @param index defines the index to check
  19144. * @returns the requested target
  19145. */
  19146. getActiveTarget(index: number): MorphTarget;
  19147. /**
  19148. * Gets the target at specified index
  19149. * @param index defines the index to check
  19150. * @returns the requested target
  19151. */
  19152. getTarget(index: number): MorphTarget;
  19153. /**
  19154. * Add a new target to this manager
  19155. * @param target defines the target to add
  19156. */
  19157. addTarget(target: MorphTarget): void;
  19158. /**
  19159. * Removes a target from the manager
  19160. * @param target defines the target to remove
  19161. */
  19162. removeTarget(target: MorphTarget): void;
  19163. /**
  19164. * Serializes the current manager into a Serialization object
  19165. * @returns the serialized object
  19166. */
  19167. serialize(): any;
  19168. private _syncActiveTargets;
  19169. /**
  19170. * Syncrhonize the targets with all the meshes using this morph target manager
  19171. */
  19172. synchronize(): void;
  19173. /**
  19174. * Creates a new MorphTargetManager from serialized data
  19175. * @param serializationObject defines the serialized data
  19176. * @param scene defines the hosting scene
  19177. * @returns the new MorphTargetManager
  19178. */
  19179. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19180. }
  19181. }
  19182. declare module BABYLON {
  19183. /**
  19184. * Class used to represent a specific level of detail of a mesh
  19185. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19186. */
  19187. export class MeshLODLevel {
  19188. /** Defines the distance where this level should star being displayed */
  19189. distance: number;
  19190. /** Defines the mesh to use to render this level */
  19191. mesh: Nullable<Mesh>;
  19192. /**
  19193. * Creates a new LOD level
  19194. * @param distance defines the distance where this level should star being displayed
  19195. * @param mesh defines the mesh to use to render this level
  19196. */
  19197. constructor(
  19198. /** Defines the distance where this level should star being displayed */
  19199. distance: number,
  19200. /** Defines the mesh to use to render this level */
  19201. mesh: Nullable<Mesh>);
  19202. }
  19203. }
  19204. declare module BABYLON {
  19205. /**
  19206. * Mesh representing the gorund
  19207. */
  19208. export class GroundMesh extends Mesh {
  19209. /** If octree should be generated */
  19210. generateOctree: boolean;
  19211. private _heightQuads;
  19212. /** @hidden */ subdivisionsX: number;
  19213. /** @hidden */ subdivisionsY: number;
  19214. /** @hidden */ width: number;
  19215. /** @hidden */ height: number;
  19216. /** @hidden */ minX: number;
  19217. /** @hidden */ maxX: number;
  19218. /** @hidden */ minZ: number;
  19219. /** @hidden */ maxZ: number;
  19220. constructor(name: string, scene: Scene);
  19221. /**
  19222. * "GroundMesh"
  19223. * @returns "GroundMesh"
  19224. */
  19225. getClassName(): string;
  19226. /**
  19227. * The minimum of x and y subdivisions
  19228. */
  19229. readonly subdivisions: number;
  19230. /**
  19231. * X subdivisions
  19232. */
  19233. readonly subdivisionsX: number;
  19234. /**
  19235. * Y subdivisions
  19236. */
  19237. readonly subdivisionsY: number;
  19238. /**
  19239. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19240. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19241. * @param chunksCount the number of subdivisions for x and y
  19242. * @param octreeBlocksSize (Default: 32)
  19243. */
  19244. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19245. /**
  19246. * Returns a height (y) value in the Worl system :
  19247. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19248. * @param x x coordinate
  19249. * @param z z coordinate
  19250. * @returns the ground y position if (x, z) are outside the ground surface.
  19251. */
  19252. getHeightAtCoordinates(x: number, z: number): number;
  19253. /**
  19254. * Returns a normalized vector (Vector3) orthogonal to the ground
  19255. * at the ground coordinates (x, z) expressed in the World system.
  19256. * @param x x coordinate
  19257. * @param z z coordinate
  19258. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19259. */
  19260. getNormalAtCoordinates(x: number, z: number): Vector3;
  19261. /**
  19262. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19263. * at the ground coordinates (x, z) expressed in the World system.
  19264. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19265. * @param x x coordinate
  19266. * @param z z coordinate
  19267. * @param ref vector to store the result
  19268. * @returns the GroundMesh.
  19269. */
  19270. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19271. /**
  19272. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19273. * if the ground has been updated.
  19274. * This can be used in the render loop.
  19275. * @returns the GroundMesh.
  19276. */
  19277. updateCoordinateHeights(): GroundMesh;
  19278. private _getFacetAt;
  19279. private _initHeightQuads;
  19280. private _computeHeightQuads;
  19281. /**
  19282. * Serializes this ground mesh
  19283. * @param serializationObject object to write serialization to
  19284. */
  19285. serialize(serializationObject: any): void;
  19286. /**
  19287. * Parses a serialized ground mesh
  19288. * @param parsedMesh the serialized mesh
  19289. * @param scene the scene to create the ground mesh in
  19290. * @returns the created ground mesh
  19291. */
  19292. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19293. }
  19294. }
  19295. declare module BABYLON {
  19296. /**
  19297. * Interface for Physics-Joint data
  19298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19299. */
  19300. export interface PhysicsJointData {
  19301. /**
  19302. * The main pivot of the joint
  19303. */
  19304. mainPivot?: Vector3;
  19305. /**
  19306. * The connected pivot of the joint
  19307. */
  19308. connectedPivot?: Vector3;
  19309. /**
  19310. * The main axis of the joint
  19311. */
  19312. mainAxis?: Vector3;
  19313. /**
  19314. * The connected axis of the joint
  19315. */
  19316. connectedAxis?: Vector3;
  19317. /**
  19318. * The collision of the joint
  19319. */
  19320. collision?: boolean;
  19321. /**
  19322. * Native Oimo/Cannon/Energy data
  19323. */
  19324. nativeParams?: any;
  19325. }
  19326. /**
  19327. * This is a holder class for the physics joint created by the physics plugin
  19328. * It holds a set of functions to control the underlying joint
  19329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19330. */
  19331. export class PhysicsJoint {
  19332. /**
  19333. * The type of the physics joint
  19334. */
  19335. type: number;
  19336. /**
  19337. * The data for the physics joint
  19338. */
  19339. jointData: PhysicsJointData;
  19340. private _physicsJoint;
  19341. protected _physicsPlugin: IPhysicsEnginePlugin;
  19342. /**
  19343. * Initializes the physics joint
  19344. * @param type The type of the physics joint
  19345. * @param jointData The data for the physics joint
  19346. */
  19347. constructor(
  19348. /**
  19349. * The type of the physics joint
  19350. */
  19351. type: number,
  19352. /**
  19353. * The data for the physics joint
  19354. */
  19355. jointData: PhysicsJointData);
  19356. /**
  19357. * Gets the physics joint
  19358. */
  19359. /**
  19360. * Sets the physics joint
  19361. */
  19362. physicsJoint: any;
  19363. /**
  19364. * Sets the physics plugin
  19365. */
  19366. physicsPlugin: IPhysicsEnginePlugin;
  19367. /**
  19368. * Execute a function that is physics-plugin specific.
  19369. * @param {Function} func the function that will be executed.
  19370. * It accepts two parameters: the physics world and the physics joint
  19371. */
  19372. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19373. /**
  19374. * Distance-Joint type
  19375. */
  19376. static DistanceJoint: number;
  19377. /**
  19378. * Hinge-Joint type
  19379. */
  19380. static HingeJoint: number;
  19381. /**
  19382. * Ball-and-Socket joint type
  19383. */
  19384. static BallAndSocketJoint: number;
  19385. /**
  19386. * Wheel-Joint type
  19387. */
  19388. static WheelJoint: number;
  19389. /**
  19390. * Slider-Joint type
  19391. */
  19392. static SliderJoint: number;
  19393. /**
  19394. * Prismatic-Joint type
  19395. */
  19396. static PrismaticJoint: number;
  19397. /**
  19398. * Universal-Joint type
  19399. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19400. */
  19401. static UniversalJoint: number;
  19402. /**
  19403. * Hinge-Joint 2 type
  19404. */
  19405. static Hinge2Joint: number;
  19406. /**
  19407. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19408. */
  19409. static PointToPointJoint: number;
  19410. /**
  19411. * Spring-Joint type
  19412. */
  19413. static SpringJoint: number;
  19414. /**
  19415. * Lock-Joint type
  19416. */
  19417. static LockJoint: number;
  19418. }
  19419. /**
  19420. * A class representing a physics distance joint
  19421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19422. */
  19423. export class DistanceJoint extends PhysicsJoint {
  19424. /**
  19425. *
  19426. * @param jointData The data for the Distance-Joint
  19427. */
  19428. constructor(jointData: DistanceJointData);
  19429. /**
  19430. * Update the predefined distance.
  19431. * @param maxDistance The maximum preferred distance
  19432. * @param minDistance The minimum preferred distance
  19433. */
  19434. updateDistance(maxDistance: number, minDistance?: number): void;
  19435. }
  19436. /**
  19437. * Represents a Motor-Enabled Joint
  19438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19439. */
  19440. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19441. /**
  19442. * Initializes the Motor-Enabled Joint
  19443. * @param type The type of the joint
  19444. * @param jointData The physica joint data for the joint
  19445. */
  19446. constructor(type: number, jointData: PhysicsJointData);
  19447. /**
  19448. * Set the motor values.
  19449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19450. * @param force the force to apply
  19451. * @param maxForce max force for this motor.
  19452. */
  19453. setMotor(force?: number, maxForce?: number): void;
  19454. /**
  19455. * Set the motor's limits.
  19456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19457. * @param upperLimit The upper limit of the motor
  19458. * @param lowerLimit The lower limit of the motor
  19459. */
  19460. setLimit(upperLimit: number, lowerLimit?: number): void;
  19461. }
  19462. /**
  19463. * This class represents a single physics Hinge-Joint
  19464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19465. */
  19466. export class HingeJoint extends MotorEnabledJoint {
  19467. /**
  19468. * Initializes the Hinge-Joint
  19469. * @param jointData The joint data for the Hinge-Joint
  19470. */
  19471. constructor(jointData: PhysicsJointData);
  19472. /**
  19473. * Set the motor values.
  19474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19475. * @param {number} force the force to apply
  19476. * @param {number} maxForce max force for this motor.
  19477. */
  19478. setMotor(force?: number, maxForce?: number): void;
  19479. /**
  19480. * Set the motor's limits.
  19481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19482. * @param upperLimit The upper limit of the motor
  19483. * @param lowerLimit The lower limit of the motor
  19484. */
  19485. setLimit(upperLimit: number, lowerLimit?: number): void;
  19486. }
  19487. /**
  19488. * This class represents a dual hinge physics joint (same as wheel joint)
  19489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19490. */
  19491. export class Hinge2Joint extends MotorEnabledJoint {
  19492. /**
  19493. * Initializes the Hinge2-Joint
  19494. * @param jointData The joint data for the Hinge2-Joint
  19495. */
  19496. constructor(jointData: PhysicsJointData);
  19497. /**
  19498. * Set the motor values.
  19499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19500. * @param {number} targetSpeed the speed the motor is to reach
  19501. * @param {number} maxForce max force for this motor.
  19502. * @param {motorIndex} the motor's index, 0 or 1.
  19503. */
  19504. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19505. /**
  19506. * Set the motor limits.
  19507. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19508. * @param {number} upperLimit the upper limit
  19509. * @param {number} lowerLimit lower limit
  19510. * @param {motorIndex} the motor's index, 0 or 1.
  19511. */
  19512. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19513. }
  19514. /**
  19515. * Interface for a motor enabled joint
  19516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19517. */
  19518. export interface IMotorEnabledJoint {
  19519. /**
  19520. * Physics joint
  19521. */
  19522. physicsJoint: any;
  19523. /**
  19524. * Sets the motor of the motor-enabled joint
  19525. * @param force The force of the motor
  19526. * @param maxForce The maximum force of the motor
  19527. * @param motorIndex The index of the motor
  19528. */
  19529. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19530. /**
  19531. * Sets the limit of the motor
  19532. * @param upperLimit The upper limit of the motor
  19533. * @param lowerLimit The lower limit of the motor
  19534. * @param motorIndex The index of the motor
  19535. */
  19536. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19537. }
  19538. /**
  19539. * Joint data for a Distance-Joint
  19540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19541. */
  19542. export interface DistanceJointData extends PhysicsJointData {
  19543. /**
  19544. * Max distance the 2 joint objects can be apart
  19545. */
  19546. maxDistance: number;
  19547. }
  19548. /**
  19549. * Joint data from a spring joint
  19550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19551. */
  19552. export interface SpringJointData extends PhysicsJointData {
  19553. /**
  19554. * Length of the spring
  19555. */
  19556. length: number;
  19557. /**
  19558. * Stiffness of the spring
  19559. */
  19560. stiffness: number;
  19561. /**
  19562. * Damping of the spring
  19563. */
  19564. damping: number;
  19565. /** this callback will be called when applying the force to the impostors. */
  19566. forceApplicationCallback: () => void;
  19567. }
  19568. }
  19569. declare module BABYLON {
  19570. /**
  19571. * Holds the data for the raycast result
  19572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19573. */
  19574. export class PhysicsRaycastResult {
  19575. private _hasHit;
  19576. private _hitDistance;
  19577. private _hitNormalWorld;
  19578. private _hitPointWorld;
  19579. private _rayFromWorld;
  19580. private _rayToWorld;
  19581. /**
  19582. * Gets if there was a hit
  19583. */
  19584. readonly hasHit: boolean;
  19585. /**
  19586. * Gets the distance from the hit
  19587. */
  19588. readonly hitDistance: number;
  19589. /**
  19590. * Gets the hit normal/direction in the world
  19591. */
  19592. readonly hitNormalWorld: Vector3;
  19593. /**
  19594. * Gets the hit point in the world
  19595. */
  19596. readonly hitPointWorld: Vector3;
  19597. /**
  19598. * Gets the ray "start point" of the ray in the world
  19599. */
  19600. readonly rayFromWorld: Vector3;
  19601. /**
  19602. * Gets the ray "end point" of the ray in the world
  19603. */
  19604. readonly rayToWorld: Vector3;
  19605. /**
  19606. * Sets the hit data (normal & point in world space)
  19607. * @param hitNormalWorld defines the normal in world space
  19608. * @param hitPointWorld defines the point in world space
  19609. */
  19610. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19611. /**
  19612. * Sets the distance from the start point to the hit point
  19613. * @param distance
  19614. */
  19615. setHitDistance(distance: number): void;
  19616. /**
  19617. * Calculates the distance manually
  19618. */
  19619. calculateHitDistance(): void;
  19620. /**
  19621. * Resets all the values to default
  19622. * @param from The from point on world space
  19623. * @param to The to point on world space
  19624. */
  19625. reset(from?: Vector3, to?: Vector3): void;
  19626. }
  19627. /**
  19628. * Interface for the size containing width and height
  19629. */
  19630. interface IXYZ {
  19631. /**
  19632. * X
  19633. */
  19634. x: number;
  19635. /**
  19636. * Y
  19637. */
  19638. y: number;
  19639. /**
  19640. * Z
  19641. */
  19642. z: number;
  19643. }
  19644. }
  19645. declare module BABYLON {
  19646. /**
  19647. * Interface used to describe a physics joint
  19648. */
  19649. export interface PhysicsImpostorJoint {
  19650. /** Defines the main impostor to which the joint is linked */
  19651. mainImpostor: PhysicsImpostor;
  19652. /** Defines the impostor that is connected to the main impostor using this joint */
  19653. connectedImpostor: PhysicsImpostor;
  19654. /** Defines the joint itself */
  19655. joint: PhysicsJoint;
  19656. }
  19657. /** @hidden */
  19658. export interface IPhysicsEnginePlugin {
  19659. world: any;
  19660. name: string;
  19661. setGravity(gravity: Vector3): void;
  19662. setTimeStep(timeStep: number): void;
  19663. getTimeStep(): number;
  19664. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19665. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19666. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19667. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19668. removePhysicsBody(impostor: PhysicsImpostor): void;
  19669. generateJoint(joint: PhysicsImpostorJoint): void;
  19670. removeJoint(joint: PhysicsImpostorJoint): void;
  19671. isSupported(): boolean;
  19672. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19673. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19675. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19676. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19677. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19678. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19679. getBodyMass(impostor: PhysicsImpostor): number;
  19680. getBodyFriction(impostor: PhysicsImpostor): number;
  19681. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19682. getBodyRestitution(impostor: PhysicsImpostor): number;
  19683. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19684. getBodyPressure?(impostor: PhysicsImpostor): number;
  19685. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19686. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19687. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19688. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19689. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19690. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19691. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19692. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19693. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19694. sleepBody(impostor: PhysicsImpostor): void;
  19695. wakeUpBody(impostor: PhysicsImpostor): void;
  19696. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19697. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19698. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19699. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19700. getRadius(impostor: PhysicsImpostor): number;
  19701. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19703. dispose(): void;
  19704. }
  19705. /**
  19706. * Interface used to define a physics engine
  19707. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19708. */
  19709. export interface IPhysicsEngine {
  19710. /**
  19711. * Gets the gravity vector used by the simulation
  19712. */
  19713. gravity: Vector3;
  19714. /**
  19715. * Sets the gravity vector used by the simulation
  19716. * @param gravity defines the gravity vector to use
  19717. */
  19718. setGravity(gravity: Vector3): void;
  19719. /**
  19720. * Set the time step of the physics engine.
  19721. * Default is 1/60.
  19722. * To slow it down, enter 1/600 for example.
  19723. * To speed it up, 1/30
  19724. * @param newTimeStep the new timestep to apply to this world.
  19725. */
  19726. setTimeStep(newTimeStep: number): void;
  19727. /**
  19728. * Get the time step of the physics engine.
  19729. * @returns the current time step
  19730. */
  19731. getTimeStep(): number;
  19732. /**
  19733. * Release all resources
  19734. */
  19735. dispose(): void;
  19736. /**
  19737. * Gets the name of the current physics plugin
  19738. * @returns the name of the plugin
  19739. */
  19740. getPhysicsPluginName(): string;
  19741. /**
  19742. * Adding a new impostor for the impostor tracking.
  19743. * This will be done by the impostor itself.
  19744. * @param impostor the impostor to add
  19745. */
  19746. addImpostor(impostor: PhysicsImpostor): void;
  19747. /**
  19748. * Remove an impostor from the engine.
  19749. * This impostor and its mesh will not longer be updated by the physics engine.
  19750. * @param impostor the impostor to remove
  19751. */
  19752. removeImpostor(impostor: PhysicsImpostor): void;
  19753. /**
  19754. * Add a joint to the physics engine
  19755. * @param mainImpostor defines the main impostor to which the joint is added.
  19756. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19757. * @param joint defines the joint that will connect both impostors.
  19758. */
  19759. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19760. /**
  19761. * Removes a joint from the simulation
  19762. * @param mainImpostor defines the impostor used with the joint
  19763. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19764. * @param joint defines the joint to remove
  19765. */
  19766. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19767. /**
  19768. * Gets the current plugin used to run the simulation
  19769. * @returns current plugin
  19770. */
  19771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19772. /**
  19773. * Gets the list of physic impostors
  19774. * @returns an array of PhysicsImpostor
  19775. */
  19776. getImpostors(): Array<PhysicsImpostor>;
  19777. /**
  19778. * Gets the impostor for a physics enabled object
  19779. * @param object defines the object impersonated by the impostor
  19780. * @returns the PhysicsImpostor or null if not found
  19781. */
  19782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19783. /**
  19784. * Gets the impostor for a physics body object
  19785. * @param body defines physics body used by the impostor
  19786. * @returns the PhysicsImpostor or null if not found
  19787. */
  19788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19789. /**
  19790. * Does a raycast in the physics world
  19791. * @param from when should the ray start?
  19792. * @param to when should the ray end?
  19793. * @returns PhysicsRaycastResult
  19794. */
  19795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19796. /**
  19797. * Called by the scene. No need to call it.
  19798. * @param delta defines the timespam between frames
  19799. */ step(delta: number): void;
  19800. }
  19801. }
  19802. declare module BABYLON {
  19803. /**
  19804. * The interface for the physics imposter parameters
  19805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19806. */
  19807. export interface PhysicsImpostorParameters {
  19808. /**
  19809. * The mass of the physics imposter
  19810. */
  19811. mass: number;
  19812. /**
  19813. * The friction of the physics imposter
  19814. */
  19815. friction?: number;
  19816. /**
  19817. * The coefficient of restitution of the physics imposter
  19818. */
  19819. restitution?: number;
  19820. /**
  19821. * The native options of the physics imposter
  19822. */
  19823. nativeOptions?: any;
  19824. /**
  19825. * Specifies if the parent should be ignored
  19826. */
  19827. ignoreParent?: boolean;
  19828. /**
  19829. * Specifies if bi-directional transformations should be disabled
  19830. */
  19831. disableBidirectionalTransformation?: boolean;
  19832. /**
  19833. * The pressure inside the physics imposter, soft object only
  19834. */
  19835. pressure?: number;
  19836. /**
  19837. * The stiffness the physics imposter, soft object only
  19838. */
  19839. stiffness?: number;
  19840. /**
  19841. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19842. */
  19843. velocityIterations?: number;
  19844. /**
  19845. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19846. */
  19847. positionIterations?: number;
  19848. /**
  19849. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19850. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19851. * Add to fix multiple points
  19852. */
  19853. fixedPoints?: number;
  19854. /**
  19855. * The collision margin around a soft object
  19856. */
  19857. margin?: number;
  19858. /**
  19859. * The collision margin around a soft object
  19860. */
  19861. damping?: number;
  19862. /**
  19863. * The path for a rope based on an extrusion
  19864. */
  19865. path?: any;
  19866. /**
  19867. * The shape of an extrusion used for a rope based on an extrusion
  19868. */
  19869. shape?: any;
  19870. }
  19871. /**
  19872. * Interface for a physics-enabled object
  19873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19874. */
  19875. export interface IPhysicsEnabledObject {
  19876. /**
  19877. * The position of the physics-enabled object
  19878. */
  19879. position: Vector3;
  19880. /**
  19881. * The rotation of the physics-enabled object
  19882. */
  19883. rotationQuaternion: Nullable<Quaternion>;
  19884. /**
  19885. * The scale of the physics-enabled object
  19886. */
  19887. scaling: Vector3;
  19888. /**
  19889. * The rotation of the physics-enabled object
  19890. */
  19891. rotation?: Vector3;
  19892. /**
  19893. * The parent of the physics-enabled object
  19894. */
  19895. parent?: any;
  19896. /**
  19897. * The bounding info of the physics-enabled object
  19898. * @returns The bounding info of the physics-enabled object
  19899. */
  19900. getBoundingInfo(): BoundingInfo;
  19901. /**
  19902. * Computes the world matrix
  19903. * @param force Specifies if the world matrix should be computed by force
  19904. * @returns A world matrix
  19905. */
  19906. computeWorldMatrix(force: boolean): Matrix;
  19907. /**
  19908. * Gets the world matrix
  19909. * @returns A world matrix
  19910. */
  19911. getWorldMatrix?(): Matrix;
  19912. /**
  19913. * Gets the child meshes
  19914. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19915. * @returns An array of abstract meshes
  19916. */
  19917. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19918. /**
  19919. * Gets the vertex data
  19920. * @param kind The type of vertex data
  19921. * @returns A nullable array of numbers, or a float32 array
  19922. */
  19923. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19924. /**
  19925. * Gets the indices from the mesh
  19926. * @returns A nullable array of index arrays
  19927. */
  19928. getIndices?(): Nullable<IndicesArray>;
  19929. /**
  19930. * Gets the scene from the mesh
  19931. * @returns the indices array or null
  19932. */
  19933. getScene?(): Scene;
  19934. /**
  19935. * Gets the absolute position from the mesh
  19936. * @returns the absolute position
  19937. */
  19938. getAbsolutePosition(): Vector3;
  19939. /**
  19940. * Gets the absolute pivot point from the mesh
  19941. * @returns the absolute pivot point
  19942. */
  19943. getAbsolutePivotPoint(): Vector3;
  19944. /**
  19945. * Rotates the mesh
  19946. * @param axis The axis of rotation
  19947. * @param amount The amount of rotation
  19948. * @param space The space of the rotation
  19949. * @returns The rotation transform node
  19950. */
  19951. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19952. /**
  19953. * Translates the mesh
  19954. * @param axis The axis of translation
  19955. * @param distance The distance of translation
  19956. * @param space The space of the translation
  19957. * @returns The transform node
  19958. */
  19959. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19960. /**
  19961. * Sets the absolute position of the mesh
  19962. * @param absolutePosition The absolute position of the mesh
  19963. * @returns The transform node
  19964. */
  19965. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19966. /**
  19967. * Gets the class name of the mesh
  19968. * @returns The class name
  19969. */
  19970. getClassName(): string;
  19971. }
  19972. /**
  19973. * Represents a physics imposter
  19974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19975. */
  19976. export class PhysicsImpostor {
  19977. /**
  19978. * The physics-enabled object used as the physics imposter
  19979. */
  19980. object: IPhysicsEnabledObject;
  19981. /**
  19982. * The type of the physics imposter
  19983. */
  19984. type: number;
  19985. private _options;
  19986. private _scene?;
  19987. /**
  19988. * The default object size of the imposter
  19989. */
  19990. static DEFAULT_OBJECT_SIZE: Vector3;
  19991. /**
  19992. * The identity quaternion of the imposter
  19993. */
  19994. static IDENTITY_QUATERNION: Quaternion;
  19995. /** @hidden */ pluginData: any;
  19996. private _physicsEngine;
  19997. private _physicsBody;
  19998. private _bodyUpdateRequired;
  19999. private _onBeforePhysicsStepCallbacks;
  20000. private _onAfterPhysicsStepCallbacks;
  20001. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20002. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20003. otherImpostors: Array<PhysicsImpostor>;
  20004. }>;
  20005. private _deltaPosition;
  20006. private _deltaRotation;
  20007. private _deltaRotationConjugated;
  20008. /** hidden */ isFromLine: boolean;
  20009. private _parent;
  20010. private _isDisposed;
  20011. private static _tmpVecs;
  20012. private static _tmpQuat;
  20013. /**
  20014. * Specifies if the physics imposter is disposed
  20015. */
  20016. readonly isDisposed: boolean;
  20017. /**
  20018. * Gets the mass of the physics imposter
  20019. */
  20020. mass: number;
  20021. /**
  20022. * Gets the coefficient of friction
  20023. */
  20024. /**
  20025. * Sets the coefficient of friction
  20026. */
  20027. friction: number;
  20028. /**
  20029. * Gets the coefficient of restitution
  20030. */
  20031. /**
  20032. * Sets the coefficient of restitution
  20033. */
  20034. restitution: number;
  20035. /**
  20036. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20037. */
  20038. /**
  20039. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20040. */
  20041. pressure: number;
  20042. /**
  20043. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20044. */
  20045. /**
  20046. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20047. */
  20048. stiffness: number;
  20049. /**
  20050. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20051. */
  20052. /**
  20053. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20054. */
  20055. velocityIterations: number;
  20056. /**
  20057. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20058. */
  20059. /**
  20060. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20061. */
  20062. positionIterations: number;
  20063. /**
  20064. * The unique id of the physics imposter
  20065. * set by the physics engine when adding this impostor to the array
  20066. */
  20067. uniqueId: number;
  20068. /**
  20069. * @hidden
  20070. */
  20071. soft: boolean;
  20072. /**
  20073. * @hidden
  20074. */
  20075. segments: number;
  20076. private _joints;
  20077. /**
  20078. * Initializes the physics imposter
  20079. * @param object The physics-enabled object used as the physics imposter
  20080. * @param type The type of the physics imposter
  20081. * @param _options The options for the physics imposter
  20082. * @param _scene The Babylon scene
  20083. */
  20084. constructor(
  20085. /**
  20086. * The physics-enabled object used as the physics imposter
  20087. */
  20088. object: IPhysicsEnabledObject,
  20089. /**
  20090. * The type of the physics imposter
  20091. */
  20092. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20093. /**
  20094. * This function will completly initialize this impostor.
  20095. * It will create a new body - but only if this mesh has no parent.
  20096. * If it has, this impostor will not be used other than to define the impostor
  20097. * of the child mesh.
  20098. * @hidden
  20099. */ init(): void;
  20100. private _getPhysicsParent;
  20101. /**
  20102. * Should a new body be generated.
  20103. * @returns boolean specifying if body initialization is required
  20104. */
  20105. isBodyInitRequired(): boolean;
  20106. /**
  20107. * Sets the updated scaling
  20108. * @param updated Specifies if the scaling is updated
  20109. */
  20110. setScalingUpdated(): void;
  20111. /**
  20112. * Force a regeneration of this or the parent's impostor's body.
  20113. * Use under cautious - This will remove all joints already implemented.
  20114. */
  20115. forceUpdate(): void;
  20116. /**
  20117. * Gets the body that holds this impostor. Either its own, or its parent.
  20118. */
  20119. /**
  20120. * Set the physics body. Used mainly by the physics engine/plugin
  20121. */
  20122. physicsBody: any;
  20123. /**
  20124. * Get the parent of the physics imposter
  20125. * @returns Physics imposter or null
  20126. */
  20127. /**
  20128. * Sets the parent of the physics imposter
  20129. */
  20130. parent: Nullable<PhysicsImpostor>;
  20131. /**
  20132. * Resets the update flags
  20133. */
  20134. resetUpdateFlags(): void;
  20135. /**
  20136. * Gets the object extend size
  20137. * @returns the object extend size
  20138. */
  20139. getObjectExtendSize(): Vector3;
  20140. /**
  20141. * Gets the object center
  20142. * @returns The object center
  20143. */
  20144. getObjectCenter(): Vector3;
  20145. /**
  20146. * Get a specific parametes from the options parameter
  20147. * @param paramName The object parameter name
  20148. * @returns The object parameter
  20149. */
  20150. getParam(paramName: string): any;
  20151. /**
  20152. * Sets a specific parameter in the options given to the physics plugin
  20153. * @param paramName The parameter name
  20154. * @param value The value of the parameter
  20155. */
  20156. setParam(paramName: string, value: number): void;
  20157. /**
  20158. * Specifically change the body's mass option. Won't recreate the physics body object
  20159. * @param mass The mass of the physics imposter
  20160. */
  20161. setMass(mass: number): void;
  20162. /**
  20163. * Gets the linear velocity
  20164. * @returns linear velocity or null
  20165. */
  20166. getLinearVelocity(): Nullable<Vector3>;
  20167. /**
  20168. * Sets the linear velocity
  20169. * @param velocity linear velocity or null
  20170. */
  20171. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20172. /**
  20173. * Gets the angular velocity
  20174. * @returns angular velocity or null
  20175. */
  20176. getAngularVelocity(): Nullable<Vector3>;
  20177. /**
  20178. * Sets the angular velocity
  20179. * @param velocity The velocity or null
  20180. */
  20181. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20182. /**
  20183. * Execute a function with the physics plugin native code
  20184. * Provide a function the will have two variables - the world object and the physics body object
  20185. * @param func The function to execute with the physics plugin native code
  20186. */
  20187. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20188. /**
  20189. * Register a function that will be executed before the physics world is stepping forward
  20190. * @param func The function to execute before the physics world is stepped forward
  20191. */
  20192. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20193. /**
  20194. * Unregister a function that will be executed before the physics world is stepping forward
  20195. * @param func The function to execute before the physics world is stepped forward
  20196. */
  20197. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20198. /**
  20199. * Register a function that will be executed after the physics step
  20200. * @param func The function to execute after physics step
  20201. */
  20202. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20203. /**
  20204. * Unregisters a function that will be executed after the physics step
  20205. * @param func The function to execute after physics step
  20206. */
  20207. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20208. /**
  20209. * register a function that will be executed when this impostor collides against a different body
  20210. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20211. * @param func Callback that is executed on collision
  20212. */
  20213. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20214. /**
  20215. * Unregisters the physics imposter on contact
  20216. * @param collideAgainst The physics object to collide against
  20217. * @param func Callback to execute on collision
  20218. */
  20219. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20220. private _tmpQuat;
  20221. private _tmpQuat2;
  20222. /**
  20223. * Get the parent rotation
  20224. * @returns The parent rotation
  20225. */
  20226. getParentsRotation(): Quaternion;
  20227. /**
  20228. * this function is executed by the physics engine.
  20229. */
  20230. beforeStep: () => void;
  20231. /**
  20232. * this function is executed by the physics engine
  20233. */
  20234. afterStep: () => void;
  20235. /**
  20236. * Legacy collision detection event support
  20237. */
  20238. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20239. /**
  20240. * event and body object due to cannon's event-based architecture.
  20241. */
  20242. onCollide: (e: {
  20243. body: any;
  20244. }) => void;
  20245. /**
  20246. * Apply a force
  20247. * @param force The force to apply
  20248. * @param contactPoint The contact point for the force
  20249. * @returns The physics imposter
  20250. */
  20251. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20252. /**
  20253. * Apply an impulse
  20254. * @param force The impulse force
  20255. * @param contactPoint The contact point for the impulse force
  20256. * @returns The physics imposter
  20257. */
  20258. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20259. /**
  20260. * A help function to create a joint
  20261. * @param otherImpostor A physics imposter used to create a joint
  20262. * @param jointType The type of joint
  20263. * @param jointData The data for the joint
  20264. * @returns The physics imposter
  20265. */
  20266. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20267. /**
  20268. * Add a joint to this impostor with a different impostor
  20269. * @param otherImpostor A physics imposter used to add a joint
  20270. * @param joint The joint to add
  20271. * @returns The physics imposter
  20272. */
  20273. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20274. /**
  20275. * Add an anchor to a cloth impostor
  20276. * @param otherImpostor rigid impostor to anchor to
  20277. * @param width ratio across width from 0 to 1
  20278. * @param height ratio up height from 0 to 1
  20279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20280. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20281. * @returns impostor the soft imposter
  20282. */
  20283. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20284. /**
  20285. * Add a hook to a rope impostor
  20286. * @param otherImpostor rigid impostor to anchor to
  20287. * @param length ratio across rope from 0 to 1
  20288. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20290. * @returns impostor the rope imposter
  20291. */
  20292. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20293. /**
  20294. * Will keep this body still, in a sleep mode.
  20295. * @returns the physics imposter
  20296. */
  20297. sleep(): PhysicsImpostor;
  20298. /**
  20299. * Wake the body up.
  20300. * @returns The physics imposter
  20301. */
  20302. wakeUp(): PhysicsImpostor;
  20303. /**
  20304. * Clones the physics imposter
  20305. * @param newObject The physics imposter clones to this physics-enabled object
  20306. * @returns A nullable physics imposter
  20307. */
  20308. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20309. /**
  20310. * Disposes the physics imposter
  20311. */
  20312. dispose(): void;
  20313. /**
  20314. * Sets the delta position
  20315. * @param position The delta position amount
  20316. */
  20317. setDeltaPosition(position: Vector3): void;
  20318. /**
  20319. * Sets the delta rotation
  20320. * @param rotation The delta rotation amount
  20321. */
  20322. setDeltaRotation(rotation: Quaternion): void;
  20323. /**
  20324. * Gets the box size of the physics imposter and stores the result in the input parameter
  20325. * @param result Stores the box size
  20326. * @returns The physics imposter
  20327. */
  20328. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20329. /**
  20330. * Gets the radius of the physics imposter
  20331. * @returns Radius of the physics imposter
  20332. */
  20333. getRadius(): number;
  20334. /**
  20335. * Sync a bone with this impostor
  20336. * @param bone The bone to sync to the impostor.
  20337. * @param boneMesh The mesh that the bone is influencing.
  20338. * @param jointPivot The pivot of the joint / bone in local space.
  20339. * @param distToJoint Optional distance from the impostor to the joint.
  20340. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20341. */
  20342. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20343. /**
  20344. * Sync impostor to a bone
  20345. * @param bone The bone that the impostor will be synced to.
  20346. * @param boneMesh The mesh that the bone is influencing.
  20347. * @param jointPivot The pivot of the joint / bone in local space.
  20348. * @param distToJoint Optional distance from the impostor to the joint.
  20349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20350. * @param boneAxis Optional vector3 axis the bone is aligned with
  20351. */
  20352. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20353. /**
  20354. * No-Imposter type
  20355. */
  20356. static NoImpostor: number;
  20357. /**
  20358. * Sphere-Imposter type
  20359. */
  20360. static SphereImpostor: number;
  20361. /**
  20362. * Box-Imposter type
  20363. */
  20364. static BoxImpostor: number;
  20365. /**
  20366. * Plane-Imposter type
  20367. */
  20368. static PlaneImpostor: number;
  20369. /**
  20370. * Mesh-imposter type
  20371. */
  20372. static MeshImpostor: number;
  20373. /**
  20374. * Cylinder-Imposter type
  20375. */
  20376. static CylinderImpostor: number;
  20377. /**
  20378. * Particle-Imposter type
  20379. */
  20380. static ParticleImpostor: number;
  20381. /**
  20382. * Heightmap-Imposter type
  20383. */
  20384. static HeightmapImpostor: number;
  20385. /**
  20386. * ConvexHull-Impostor type (Ammo.js plugin only)
  20387. */
  20388. static ConvexHullImpostor: number;
  20389. /**
  20390. * Rope-Imposter type
  20391. */
  20392. static RopeImpostor: number;
  20393. /**
  20394. * Cloth-Imposter type
  20395. */
  20396. static ClothImpostor: number;
  20397. /**
  20398. * Softbody-Imposter type
  20399. */
  20400. static SoftbodyImpostor: number;
  20401. }
  20402. }
  20403. declare module BABYLON {
  20404. /**
  20405. * @hidden
  20406. **/
  20407. export class _CreationDataStorage {
  20408. closePath?: boolean;
  20409. closeArray?: boolean;
  20410. idx: number[];
  20411. dashSize: number;
  20412. gapSize: number;
  20413. path3D: Path3D;
  20414. pathArray: Vector3[][];
  20415. arc: number;
  20416. radius: number;
  20417. cap: number;
  20418. tessellation: number;
  20419. }
  20420. /**
  20421. * @hidden
  20422. **/ private class _InstanceDataStorage {
  20423. visibleInstances: any;
  20424. batchCache: _InstancesBatch;
  20425. instancesBufferSize: number;
  20426. instancesBuffer: Nullable<Buffer>;
  20427. instancesData: Float32Array;
  20428. overridenInstanceCount: number;
  20429. isFrozen: boolean;
  20430. previousBatch: _InstancesBatch;
  20431. hardwareInstancedRendering: boolean;
  20432. sideOrientation: number;
  20433. }
  20434. /**
  20435. * @hidden
  20436. **/
  20437. export class _InstancesBatch {
  20438. mustReturn: boolean;
  20439. visibleInstances: Nullable<InstancedMesh[]>[];
  20440. renderSelf: boolean[];
  20441. hardwareInstancedRendering: boolean[];
  20442. }
  20443. /**
  20444. * Class used to represent renderable models
  20445. */
  20446. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20447. /**
  20448. * Mesh side orientation : usually the external or front surface
  20449. */
  20450. static readonly FRONTSIDE: number;
  20451. /**
  20452. * Mesh side orientation : usually the internal or back surface
  20453. */
  20454. static readonly BACKSIDE: number;
  20455. /**
  20456. * Mesh side orientation : both internal and external or front and back surfaces
  20457. */
  20458. static readonly DOUBLESIDE: number;
  20459. /**
  20460. * Mesh side orientation : by default, `FRONTSIDE`
  20461. */
  20462. static readonly DEFAULTSIDE: number;
  20463. /**
  20464. * Mesh cap setting : no cap
  20465. */
  20466. static readonly NO_CAP: number;
  20467. /**
  20468. * Mesh cap setting : one cap at the beginning of the mesh
  20469. */
  20470. static readonly CAP_START: number;
  20471. /**
  20472. * Mesh cap setting : one cap at the end of the mesh
  20473. */
  20474. static readonly CAP_END: number;
  20475. /**
  20476. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20477. */
  20478. static readonly CAP_ALL: number;
  20479. /**
  20480. * Gets the default side orientation.
  20481. * @param orientation the orientation to value to attempt to get
  20482. * @returns the default orientation
  20483. * @hidden
  20484. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20485. private _onBeforeRenderObservable;
  20486. private _onBeforeBindObservable;
  20487. private _onAfterRenderObservable;
  20488. private _onBeforeDrawObservable;
  20489. /**
  20490. * An event triggered before rendering the mesh
  20491. */
  20492. readonly onBeforeRenderObservable: Observable<Mesh>;
  20493. /**
  20494. * An event triggered before binding the mesh
  20495. */
  20496. readonly onBeforeBindObservable: Observable<Mesh>;
  20497. /**
  20498. * An event triggered after rendering the mesh
  20499. */
  20500. readonly onAfterRenderObservable: Observable<Mesh>;
  20501. /**
  20502. * An event triggered before drawing the mesh
  20503. */
  20504. readonly onBeforeDrawObservable: Observable<Mesh>;
  20505. private _onBeforeDrawObserver;
  20506. /**
  20507. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20508. */
  20509. onBeforeDraw: () => void;
  20510. /**
  20511. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20512. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20513. */
  20514. delayLoadState: number;
  20515. /**
  20516. * Gets the list of instances created from this mesh
  20517. * it is not supposed to be modified manually.
  20518. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20519. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20520. */
  20521. instances: InstancedMesh[];
  20522. /**
  20523. * Gets the file containing delay loading data for this mesh
  20524. */
  20525. delayLoadingFile: string;
  20526. /** @hidden */ binaryInfo: any;
  20527. private _LODLevels;
  20528. /**
  20529. * User defined function used to change how LOD level selection is done
  20530. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20531. */
  20532. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20533. private _morphTargetManager;
  20534. /**
  20535. * Gets or sets the morph target manager
  20536. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20537. */
  20538. morphTargetManager: Nullable<MorphTargetManager>;
  20539. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20540. /** @hidden */ geometry: Nullable<Geometry>;
  20541. /** @hidden */ delayInfo: Array<string>;
  20542. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20543. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20544. private _effectiveMaterial;
  20545. /** @hidden */ shouldGenerateFlatShading: boolean;
  20546. private _preActivateId;
  20547. /** @hidden */ originalBuilderSideOrientation: number;
  20548. /**
  20549. * Use this property to change the original side orientation defined at construction time
  20550. */
  20551. overrideMaterialSideOrientation: Nullable<number>;
  20552. private _areNormalsFrozen;
  20553. private _sourcePositions;
  20554. private _sourceNormals;
  20555. private _source;
  20556. private meshMap;
  20557. /**
  20558. * Gets the source mesh (the one used to clone this one from)
  20559. */
  20560. readonly source: Nullable<Mesh>;
  20561. /**
  20562. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20563. */
  20564. isUnIndexed: boolean;
  20565. /**
  20566. * @constructor
  20567. * @param name The value used by scene.getMeshByName() to do a lookup.
  20568. * @param scene The scene to add this mesh to.
  20569. * @param parent The parent of this mesh, if it has one
  20570. * @param source An optional Mesh from which geometry is shared, cloned.
  20571. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20572. * When false, achieved by calling a clone(), also passing False.
  20573. * This will make creation of children, recursive.
  20574. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20575. */
  20576. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20577. /**
  20578. * Gets the class name
  20579. * @returns the string "Mesh".
  20580. */
  20581. getClassName(): string;
  20582. /** @hidden */ protected readonly _isMesh: boolean;
  20583. /**
  20584. * Returns a description of this mesh
  20585. * @param fullDetails define if full details about this mesh must be used
  20586. * @returns a descriptive string representing this mesh
  20587. */
  20588. toString(fullDetails?: boolean): string;
  20589. /** @hidden */ unBindEffect(): void;
  20590. /**
  20591. * Gets a boolean indicating if this mesh has LOD
  20592. */
  20593. readonly hasLODLevels: boolean;
  20594. /**
  20595. * Gets the list of MeshLODLevel associated with the current mesh
  20596. * @returns an array of MeshLODLevel
  20597. */
  20598. getLODLevels(): MeshLODLevel[];
  20599. private _sortLODLevels;
  20600. /**
  20601. * Add a mesh as LOD level triggered at the given distance.
  20602. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20603. * @param distance The distance from the center of the object to show this level
  20604. * @param mesh The mesh to be added as LOD level (can be null)
  20605. * @return This mesh (for chaining)
  20606. */
  20607. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20608. /**
  20609. * Returns the LOD level mesh at the passed distance or null if not found.
  20610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20611. * @param distance The distance from the center of the object to show this level
  20612. * @returns a Mesh or `null`
  20613. */
  20614. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20615. /**
  20616. * Remove a mesh from the LOD array
  20617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20618. * @param mesh defines the mesh to be removed
  20619. * @return This mesh (for chaining)
  20620. */
  20621. removeLODLevel(mesh: Mesh): Mesh;
  20622. /**
  20623. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20625. * @param camera defines the camera to use to compute distance
  20626. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20627. * @return This mesh (for chaining)
  20628. */
  20629. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20630. /**
  20631. * Gets the mesh internal Geometry object
  20632. */
  20633. readonly geometry: Nullable<Geometry>;
  20634. /**
  20635. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20636. * @returns the total number of vertices
  20637. */
  20638. getTotalVertices(): number;
  20639. /**
  20640. * Returns the content of an associated vertex buffer
  20641. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20642. * - VertexBuffer.PositionKind
  20643. * - VertexBuffer.UVKind
  20644. * - VertexBuffer.UV2Kind
  20645. * - VertexBuffer.UV3Kind
  20646. * - VertexBuffer.UV4Kind
  20647. * - VertexBuffer.UV5Kind
  20648. * - VertexBuffer.UV6Kind
  20649. * - VertexBuffer.ColorKind
  20650. * - VertexBuffer.MatricesIndicesKind
  20651. * - VertexBuffer.MatricesIndicesExtraKind
  20652. * - VertexBuffer.MatricesWeightsKind
  20653. * - VertexBuffer.MatricesWeightsExtraKind
  20654. * @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
  20655. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20656. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20657. */
  20658. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20659. /**
  20660. * Returns the mesh VertexBuffer object from the requested `kind`
  20661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20662. * - VertexBuffer.PositionKind
  20663. * - VertexBuffer.UVKind
  20664. * - VertexBuffer.UV2Kind
  20665. * - VertexBuffer.UV3Kind
  20666. * - VertexBuffer.UV4Kind
  20667. * - VertexBuffer.UV5Kind
  20668. * - VertexBuffer.UV6Kind
  20669. * - VertexBuffer.ColorKind
  20670. * - VertexBuffer.MatricesIndicesKind
  20671. * - VertexBuffer.MatricesIndicesExtraKind
  20672. * - VertexBuffer.MatricesWeightsKind
  20673. * - VertexBuffer.MatricesWeightsExtraKind
  20674. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20675. */
  20676. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20677. /**
  20678. * Tests if a specific vertex buffer is associated with this mesh
  20679. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20680. * - VertexBuffer.PositionKind
  20681. * - VertexBuffer.UVKind
  20682. * - VertexBuffer.UV2Kind
  20683. * - VertexBuffer.UV3Kind
  20684. * - VertexBuffer.UV4Kind
  20685. * - VertexBuffer.UV5Kind
  20686. * - VertexBuffer.UV6Kind
  20687. * - VertexBuffer.ColorKind
  20688. * - VertexBuffer.MatricesIndicesKind
  20689. * - VertexBuffer.MatricesIndicesExtraKind
  20690. * - VertexBuffer.MatricesWeightsKind
  20691. * - VertexBuffer.MatricesWeightsExtraKind
  20692. * @returns a boolean
  20693. */
  20694. isVerticesDataPresent(kind: string): boolean;
  20695. /**
  20696. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20697. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20698. * - VertexBuffer.PositionKind
  20699. * - VertexBuffer.UVKind
  20700. * - VertexBuffer.UV2Kind
  20701. * - VertexBuffer.UV3Kind
  20702. * - VertexBuffer.UV4Kind
  20703. * - VertexBuffer.UV5Kind
  20704. * - VertexBuffer.UV6Kind
  20705. * - VertexBuffer.ColorKind
  20706. * - VertexBuffer.MatricesIndicesKind
  20707. * - VertexBuffer.MatricesIndicesExtraKind
  20708. * - VertexBuffer.MatricesWeightsKind
  20709. * - VertexBuffer.MatricesWeightsExtraKind
  20710. * @returns a boolean
  20711. */
  20712. isVertexBufferUpdatable(kind: string): boolean;
  20713. /**
  20714. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20715. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20716. * - VertexBuffer.PositionKind
  20717. * - VertexBuffer.UVKind
  20718. * - VertexBuffer.UV2Kind
  20719. * - VertexBuffer.UV3Kind
  20720. * - VertexBuffer.UV4Kind
  20721. * - VertexBuffer.UV5Kind
  20722. * - VertexBuffer.UV6Kind
  20723. * - VertexBuffer.ColorKind
  20724. * - VertexBuffer.MatricesIndicesKind
  20725. * - VertexBuffer.MatricesIndicesExtraKind
  20726. * - VertexBuffer.MatricesWeightsKind
  20727. * - VertexBuffer.MatricesWeightsExtraKind
  20728. * @returns an array of strings
  20729. */
  20730. getVerticesDataKinds(): string[];
  20731. /**
  20732. * Returns a positive integer : the total number of indices in this mesh geometry.
  20733. * @returns the numner of indices or zero if the mesh has no geometry.
  20734. */
  20735. getTotalIndices(): number;
  20736. /**
  20737. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20738. * @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.
  20739. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20740. * @returns the indices array or an empty array if the mesh has no geometry
  20741. */
  20742. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20743. readonly isBlocked: boolean;
  20744. /**
  20745. * Determine if the current mesh is ready to be rendered
  20746. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20747. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20748. * @returns true if all associated assets are ready (material, textures, shaders)
  20749. */
  20750. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20751. /**
  20752. * 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.
  20753. */
  20754. readonly areNormalsFrozen: boolean;
  20755. /**
  20756. * 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.
  20757. * @returns the current mesh
  20758. */
  20759. freezeNormals(): Mesh;
  20760. /**
  20761. * 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
  20762. * @returns the current mesh
  20763. */
  20764. unfreezeNormals(): Mesh;
  20765. /**
  20766. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20767. */
  20768. overridenInstanceCount: number;
  20769. /** @hidden */ preActivate(): Mesh;
  20770. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20771. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20772. /**
  20773. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20774. * This means the mesh underlying bounding box and sphere are recomputed.
  20775. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20776. * @returns the current mesh
  20777. */
  20778. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20779. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20780. /**
  20781. * This function will subdivide the mesh into multiple submeshes
  20782. * @param count defines the expected number of submeshes
  20783. */
  20784. subdivide(count: number): void;
  20785. /**
  20786. * Copy a FloatArray into a specific associated vertex buffer
  20787. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20788. * - VertexBuffer.PositionKind
  20789. * - VertexBuffer.UVKind
  20790. * - VertexBuffer.UV2Kind
  20791. * - VertexBuffer.UV3Kind
  20792. * - VertexBuffer.UV4Kind
  20793. * - VertexBuffer.UV5Kind
  20794. * - VertexBuffer.UV6Kind
  20795. * - VertexBuffer.ColorKind
  20796. * - VertexBuffer.MatricesIndicesKind
  20797. * - VertexBuffer.MatricesIndicesExtraKind
  20798. * - VertexBuffer.MatricesWeightsKind
  20799. * - VertexBuffer.MatricesWeightsExtraKind
  20800. * @param data defines the data source
  20801. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20802. * @param stride defines the data stride size (can be null)
  20803. * @returns the current mesh
  20804. */
  20805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20806. /**
  20807. * Flags an associated vertex buffer as updatable
  20808. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20809. * - VertexBuffer.PositionKind
  20810. * - VertexBuffer.UVKind
  20811. * - VertexBuffer.UV2Kind
  20812. * - VertexBuffer.UV3Kind
  20813. * - VertexBuffer.UV4Kind
  20814. * - VertexBuffer.UV5Kind
  20815. * - VertexBuffer.UV6Kind
  20816. * - VertexBuffer.ColorKind
  20817. * - VertexBuffer.MatricesIndicesKind
  20818. * - VertexBuffer.MatricesIndicesExtraKind
  20819. * - VertexBuffer.MatricesWeightsKind
  20820. * - VertexBuffer.MatricesWeightsExtraKind
  20821. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20822. */
  20823. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20824. /**
  20825. * Sets the mesh global Vertex Buffer
  20826. * @param buffer defines the buffer to use
  20827. * @returns the current mesh
  20828. */
  20829. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20830. /**
  20831. * Update a specific associated vertex buffer
  20832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20833. * - VertexBuffer.PositionKind
  20834. * - VertexBuffer.UVKind
  20835. * - VertexBuffer.UV2Kind
  20836. * - VertexBuffer.UV3Kind
  20837. * - VertexBuffer.UV4Kind
  20838. * - VertexBuffer.UV5Kind
  20839. * - VertexBuffer.UV6Kind
  20840. * - VertexBuffer.ColorKind
  20841. * - VertexBuffer.MatricesIndicesKind
  20842. * - VertexBuffer.MatricesIndicesExtraKind
  20843. * - VertexBuffer.MatricesWeightsKind
  20844. * - VertexBuffer.MatricesWeightsExtraKind
  20845. * @param data defines the data source
  20846. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20847. * @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)
  20848. * @returns the current mesh
  20849. */
  20850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20851. /**
  20852. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20853. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20854. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20855. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20856. * @returns the current mesh
  20857. */
  20858. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20859. /**
  20860. * Creates a un-shared specific occurence of the geometry for the mesh.
  20861. * @returns the current mesh
  20862. */
  20863. makeGeometryUnique(): Mesh;
  20864. /**
  20865. * Set the index buffer of this mesh
  20866. * @param indices defines the source data
  20867. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20868. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20869. * @returns the current mesh
  20870. */
  20871. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20872. /**
  20873. * Update the current index buffer
  20874. * @param indices defines the source data
  20875. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20876. * @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)
  20877. * @returns the current mesh
  20878. */
  20879. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20880. /**
  20881. * Invert the geometry to move from a right handed system to a left handed one.
  20882. * @returns the current mesh
  20883. */
  20884. toLeftHanded(): Mesh;
  20885. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20886. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20887. /**
  20888. * Registers for this mesh a javascript function called just before the rendering process
  20889. * @param func defines the function to call before rendering this mesh
  20890. * @returns the current mesh
  20891. */
  20892. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20893. /**
  20894. * Disposes a previously registered javascript function called before the rendering
  20895. * @param func defines the function to remove
  20896. * @returns the current mesh
  20897. */
  20898. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20899. /**
  20900. * Registers for this mesh a javascript function called just after the rendering is complete
  20901. * @param func defines the function to call after rendering this mesh
  20902. * @returns the current mesh
  20903. */
  20904. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20905. /**
  20906. * Disposes a previously registered javascript function called after the rendering.
  20907. * @param func defines the function to remove
  20908. * @returns the current mesh
  20909. */
  20910. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20911. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20912. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20913. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20914. /** @hidden */ freeze(): void;
  20915. /** @hidden */ unFreeze(): void;
  20916. /**
  20917. * 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
  20918. * @param subMesh defines the subMesh to render
  20919. * @param enableAlphaMode defines if alpha mode can be changed
  20920. * @returns the current mesh
  20921. */
  20922. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20923. private _onBeforeDraw;
  20924. /**
  20925. * Renormalize the mesh and patch it up if there are no weights
  20926. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20927. * However in the case of zero weights then we set just a single influence to 1.
  20928. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20929. */
  20930. cleanMatrixWeights(): void;
  20931. private normalizeSkinFourWeights;
  20932. private normalizeSkinWeightsAndExtra;
  20933. /**
  20934. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20935. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20936. * the user know there was an issue with importing the mesh
  20937. * @returns a validation object with skinned, valid and report string
  20938. */
  20939. validateSkinning(): {
  20940. skinned: boolean;
  20941. valid: boolean;
  20942. report: string;
  20943. };
  20944. /** @hidden */ checkDelayState(): Mesh;
  20945. private _queueLoad;
  20946. /**
  20947. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20948. * A mesh is in the frustum if its bounding box intersects the frustum
  20949. * @param frustumPlanes defines the frustum to test
  20950. * @returns true if the mesh is in the frustum planes
  20951. */
  20952. isInFrustum(frustumPlanes: Plane[]): boolean;
  20953. /**
  20954. * Sets the mesh material by the material or multiMaterial `id` property
  20955. * @param id is a string identifying the material or the multiMaterial
  20956. * @returns the current mesh
  20957. */
  20958. setMaterialByID(id: string): Mesh;
  20959. /**
  20960. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20961. * @returns an array of IAnimatable
  20962. */
  20963. getAnimatables(): IAnimatable[];
  20964. /**
  20965. * Modifies the mesh geometry according to the passed transformation matrix.
  20966. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20967. * The mesh normals are modified using the same transformation.
  20968. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20969. * @param transform defines the transform matrix to use
  20970. * @see http://doc.babylonjs.com/resources/baking_transformations
  20971. * @returns the current mesh
  20972. */
  20973. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20974. /**
  20975. * Modifies the mesh geometry according to its own current World Matrix.
  20976. * The mesh World Matrix is then reset.
  20977. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20978. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20979. * @see http://doc.babylonjs.com/resources/baking_transformations
  20980. * @returns the current mesh
  20981. */
  20982. bakeCurrentTransformIntoVertices(): Mesh;
  20983. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20984. /** @hidden */ resetPointsArrayCache(): Mesh;
  20985. /** @hidden */ generatePointsArray(): boolean;
  20986. /**
  20987. * Returns a new Mesh object generated from the current mesh properties.
  20988. * This method must not get confused with createInstance()
  20989. * @param name is a string, the name given to the new mesh
  20990. * @param newParent can be any Node object (default `null`)
  20991. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20992. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20993. * @returns a new mesh
  20994. */
  20995. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20996. /**
  20997. * Releases resources associated with this mesh.
  20998. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20999. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21000. */
  21001. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21002. /**
  21003. * Modifies the mesh geometry according to a displacement map.
  21004. * 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.
  21005. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21006. * @param url is a string, the URL from the image file is to be downloaded.
  21007. * @param minHeight is the lower limit of the displacement.
  21008. * @param maxHeight is the upper limit of the displacement.
  21009. * @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.
  21010. * @param uvOffset is an optional vector2 used to offset UV.
  21011. * @param uvScale is an optional vector2 used to scale UV.
  21012. * @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.
  21013. * @returns the Mesh.
  21014. */
  21015. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21016. /**
  21017. * Modifies the mesh geometry according to a displacementMap buffer.
  21018. * 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.
  21019. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21020. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21021. * @param heightMapWidth is the width of the buffer image.
  21022. * @param heightMapHeight is the height of the buffer image.
  21023. * @param minHeight is the lower limit of the displacement.
  21024. * @param maxHeight is the upper limit of the displacement.
  21025. * @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.
  21026. * @param uvOffset is an optional vector2 used to offset UV.
  21027. * @param uvScale is an optional vector2 used to scale UV.
  21028. * @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.
  21029. * @returns the Mesh.
  21030. */
  21031. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21032. /**
  21033. * Modify the mesh to get a flat shading rendering.
  21034. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21035. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21036. * @returns current mesh
  21037. */
  21038. convertToFlatShadedMesh(): Mesh;
  21039. /**
  21040. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21041. * In other words, more vertices, no more indices and a single bigger VBO.
  21042. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21043. * @returns current mesh
  21044. */
  21045. convertToUnIndexedMesh(): Mesh;
  21046. /**
  21047. * Inverses facet orientations.
  21048. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21049. * @param flipNormals will also inverts the normals
  21050. * @returns current mesh
  21051. */
  21052. flipFaces(flipNormals?: boolean): Mesh;
  21053. /**
  21054. * Increase the number of facets and hence vertices in a mesh
  21055. * Vertex normals are interpolated from existing vertex normals
  21056. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21057. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21058. */
  21059. increaseVertices(numberPerEdge: number): void;
  21060. /**
  21061. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21062. * This will undo any application of covertToFlatShadedMesh
  21063. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21064. */
  21065. forceSharedVertices(): void;
  21066. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21067. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21068. /**
  21069. * Creates a new InstancedMesh object from the mesh model.
  21070. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21071. * @param name defines the name of the new instance
  21072. * @returns a new InstancedMesh
  21073. */
  21074. createInstance(name: string): InstancedMesh;
  21075. /**
  21076. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21077. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21078. * @returns the current mesh
  21079. */
  21080. synchronizeInstances(): Mesh;
  21081. /**
  21082. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21083. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21084. * This should be used together with the simplification to avoid disappearing triangles.
  21085. * @param successCallback an optional success callback to be called after the optimization finished.
  21086. * @returns the current mesh
  21087. */
  21088. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21089. /**
  21090. * Serialize current mesh
  21091. * @param serializationObject defines the object which will receive the serialization data
  21092. */
  21093. serialize(serializationObject: any): void;
  21094. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21095. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21096. /**
  21097. * Returns a new Mesh object parsed from the source provided.
  21098. * @param parsedMesh is the source
  21099. * @param scene defines the hosting scene
  21100. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21101. * @returns a new Mesh
  21102. */
  21103. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21104. /**
  21105. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21106. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21107. * @param name defines the name of the mesh to create
  21108. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21109. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21110. * @param closePath creates a seam between the first and the last points of each path of the path array
  21111. * @param offset is taken in account only if the `pathArray` is containing a single path
  21112. * @param scene defines the hosting scene
  21113. * @param updatable defines if the mesh must be flagged as updatable
  21114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21115. * @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)
  21116. * @returns a new Mesh
  21117. */
  21118. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21119. /**
  21120. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21121. * @param name defines the name of the mesh to create
  21122. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21123. * @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
  21124. * @param scene defines the hosting scene
  21125. * @param updatable defines if the mesh must be flagged as updatable
  21126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21127. * @returns a new Mesh
  21128. */
  21129. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21130. /**
  21131. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21132. * @param name defines the name of the mesh to create
  21133. * @param size sets the size (float) of each box side (default 1)
  21134. * @param scene defines the hosting scene
  21135. * @param updatable defines if the mesh must be flagged as updatable
  21136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21137. * @returns a new Mesh
  21138. */
  21139. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21140. /**
  21141. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21142. * @param name defines the name of the mesh to create
  21143. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21144. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21145. * @param scene defines the hosting scene
  21146. * @param updatable defines if the mesh must be flagged as updatable
  21147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21148. * @returns a new Mesh
  21149. */
  21150. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21151. /**
  21152. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21153. * @param name defines the name of the mesh to create
  21154. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21155. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21156. * @param scene defines the hosting scene
  21157. * @returns a new Mesh
  21158. */
  21159. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21160. /**
  21161. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21162. * @param name defines the name of the mesh to create
  21163. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21164. * @param diameterTop set the top cap diameter (floats, default 1)
  21165. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21166. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21167. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21168. * @param scene defines the hosting scene
  21169. * @param updatable defines if the mesh must be flagged as updatable
  21170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21171. * @returns a new Mesh
  21172. */
  21173. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21174. /**
  21175. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21176. * @param name defines the name of the mesh to create
  21177. * @param diameter sets the diameter size (float) of the torus (default 1)
  21178. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21179. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21180. * @param scene defines the hosting scene
  21181. * @param updatable defines if the mesh must be flagged as updatable
  21182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21183. * @returns a new Mesh
  21184. */
  21185. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21186. /**
  21187. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @param name defines the name of the mesh to create
  21189. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21190. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21191. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21192. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21193. * @param p the number of windings on X axis (positive integers, default 2)
  21194. * @param q the number of windings on Y axis (positive integers, default 3)
  21195. * @param scene defines the hosting scene
  21196. * @param updatable defines if the mesh must be flagged as updatable
  21197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21201. /**
  21202. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21203. * @param name defines the name of the mesh to create
  21204. * @param points is an array successive Vector3
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @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).
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21211. /**
  21212. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21213. * @param name defines the name of the mesh to create
  21214. * @param points is an array successive Vector3
  21215. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21216. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21217. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21218. * @param scene defines the hosting scene
  21219. * @param updatable defines if the mesh must be flagged as updatable
  21220. * @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)
  21221. * @returns a new Mesh
  21222. */
  21223. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21224. /**
  21225. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21226. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21227. * 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.
  21228. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21229. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21230. * Remember you can only change the shape positions, not their number when updating a polygon.
  21231. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21232. * @param name defines the name of the mesh to create
  21233. * @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
  21234. * @param scene defines the hosting scene
  21235. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21236. * @param updatable defines if the mesh must be flagged as updatable
  21237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21238. * @param earcutInjection can be used to inject your own earcut reference
  21239. * @returns a new Mesh
  21240. */
  21241. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21242. /**
  21243. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21244. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21245. * @param name defines the name of the mesh to create
  21246. * @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
  21247. * @param depth defines the height of extrusion
  21248. * @param scene defines the hosting scene
  21249. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  21253. * @returns a new Mesh
  21254. */
  21255. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21256. /**
  21257. * Creates an extruded shape mesh.
  21258. * 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
  21259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21261. * @param name defines the name of the mesh to create
  21262. * @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
  21263. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21264. * @param scale is the value to scale the shape
  21265. * @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
  21266. * @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
  21267. * @param scene defines the hosting scene
  21268. * @param updatable defines if the mesh must be flagged as updatable
  21269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21270. * @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)
  21271. * @returns a new Mesh
  21272. */
  21273. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21274. /**
  21275. * Creates an custom extruded shape mesh.
  21276. * The custom extrusion is a parametric shape.
  21277. * It has no predefined shape. Its final shape will depend on the input parameters.
  21278. * Please consider using the same method from the MeshBuilder class instead
  21279. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21280. * @param name defines the name of the mesh to create
  21281. * @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
  21282. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21283. * @param scaleFunction is a custom Javascript function called on each path point
  21284. * @param rotationFunction is a custom Javascript function called on each path point
  21285. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21286. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21287. * @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
  21288. * @param scene defines the hosting scene
  21289. * @param updatable defines if the mesh must be flagged as updatable
  21290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21291. * @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)
  21292. * @returns a new Mesh
  21293. */
  21294. 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;
  21295. /**
  21296. * Creates lathe mesh.
  21297. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21298. * Please consider using the same method from the MeshBuilder class instead
  21299. * @param name defines the name of the mesh to create
  21300. * @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
  21301. * @param radius is the radius value of the lathe
  21302. * @param tessellation is the side number of the lathe.
  21303. * @param scene defines the hosting scene
  21304. * @param updatable defines if the mesh must be flagged as updatable
  21305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21306. * @returns a new Mesh
  21307. */
  21308. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21309. /**
  21310. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21311. * @param name defines the name of the mesh to create
  21312. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21313. * @param scene defines the hosting scene
  21314. * @param updatable defines if the mesh must be flagged as updatable
  21315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21316. * @returns a new Mesh
  21317. */
  21318. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21319. /**
  21320. * Creates a ground mesh.
  21321. * Please consider using the same method from the MeshBuilder class instead
  21322. * @param name defines the name of the mesh to create
  21323. * @param width set the width of the ground
  21324. * @param height set the height of the ground
  21325. * @param subdivisions sets the number of subdivisions per side
  21326. * @param scene defines the hosting scene
  21327. * @param updatable defines if the mesh must be flagged as updatable
  21328. * @returns a new Mesh
  21329. */
  21330. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21331. /**
  21332. * Creates a tiled ground mesh.
  21333. * Please consider using the same method from the MeshBuilder class instead
  21334. * @param name defines the name of the mesh to create
  21335. * @param xmin set the ground minimum X coordinate
  21336. * @param zmin set the ground minimum Y coordinate
  21337. * @param xmax set the ground maximum X coordinate
  21338. * @param zmax set the ground maximum Z coordinate
  21339. * @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
  21340. * @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
  21341. * @param scene defines the hosting scene
  21342. * @param updatable defines if the mesh must be flagged as updatable
  21343. * @returns a new Mesh
  21344. */
  21345. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21346. w: number;
  21347. h: number;
  21348. }, precision: {
  21349. w: number;
  21350. h: number;
  21351. }, scene: Scene, updatable?: boolean): Mesh;
  21352. /**
  21353. * Creates a ground mesh from a height map.
  21354. * Please consider using the same method from the MeshBuilder class instead
  21355. * @see http://doc.babylonjs.com/babylon101/height_map
  21356. * @param name defines the name of the mesh to create
  21357. * @param url sets the URL of the height map image resource
  21358. * @param width set the ground width size
  21359. * @param height set the ground height size
  21360. * @param subdivisions sets the number of subdivision per side
  21361. * @param minHeight is the minimum altitude on the ground
  21362. * @param maxHeight is the maximum altitude on the ground
  21363. * @param scene defines the hosting scene
  21364. * @param updatable defines if the mesh must be flagged as updatable
  21365. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21366. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21367. * @returns a new Mesh
  21368. */
  21369. 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;
  21370. /**
  21371. * Creates a tube mesh.
  21372. * The tube is a parametric shape.
  21373. * It has no predefined shape. Its final shape will depend on the input parameters.
  21374. * Please consider using the same method from the MeshBuilder class instead
  21375. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21376. * @param name defines the name of the mesh to create
  21377. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21378. * @param radius sets the tube radius size
  21379. * @param tessellation is the number of sides on the tubular surface
  21380. * @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
  21381. * @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
  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. * @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)
  21386. * @returns a new Mesh
  21387. */
  21388. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21389. (i: number, distance: number): number;
  21390. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21391. /**
  21392. * Creates a polyhedron mesh.
  21393. * Please consider using the same method from the MeshBuilder class instead.
  21394. * * 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
  21395. * * The parameter `size` (positive float, default 1) sets the polygon size
  21396. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21397. * * 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`
  21398. * * 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
  21399. * * 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)`)
  21400. * * 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
  21401. * * 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
  21402. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21403. * * 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
  21404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21405. * @param name defines the name of the mesh to create
  21406. * @param options defines the options used to create the mesh
  21407. * @param scene defines the hosting scene
  21408. * @returns a new Mesh
  21409. */
  21410. static CreatePolyhedron(name: string, options: {
  21411. type?: number;
  21412. size?: number;
  21413. sizeX?: number;
  21414. sizeY?: number;
  21415. sizeZ?: number;
  21416. custom?: any;
  21417. faceUV?: Vector4[];
  21418. faceColors?: Color4[];
  21419. updatable?: boolean;
  21420. sideOrientation?: number;
  21421. }, scene: Scene): Mesh;
  21422. /**
  21423. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21424. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21425. * * 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`)
  21426. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21427. * * 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
  21428. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21429. * * 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
  21430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21431. * @param name defines the name of the mesh
  21432. * @param options defines the options used to create the mesh
  21433. * @param scene defines the hosting scene
  21434. * @returns a new Mesh
  21435. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21436. */
  21437. static CreateIcoSphere(name: string, options: {
  21438. radius?: number;
  21439. flat?: boolean;
  21440. subdivisions?: number;
  21441. sideOrientation?: number;
  21442. updatable?: boolean;
  21443. }, scene: Scene): Mesh;
  21444. /**
  21445. * Creates a decal mesh.
  21446. * Please consider using the same method from the MeshBuilder class instead.
  21447. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21448. * @param name defines the name of the mesh
  21449. * @param sourceMesh defines the mesh receiving the decal
  21450. * @param position sets the position of the decal in world coordinates
  21451. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21452. * @param size sets the decal scaling
  21453. * @param angle sets the angle to rotate the decal
  21454. * @returns a new Mesh
  21455. */
  21456. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21457. /**
  21458. * Prepare internal position array for software CPU skinning
  21459. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21460. */
  21461. setPositionsForCPUSkinning(): Float32Array;
  21462. /**
  21463. * Prepare internal normal array for software CPU skinning
  21464. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21465. */
  21466. setNormalsForCPUSkinning(): Float32Array;
  21467. /**
  21468. * Updates the vertex buffer by applying transformation from the bones
  21469. * @param skeleton defines the skeleton to apply to current mesh
  21470. * @returns the current mesh
  21471. */
  21472. applySkeleton(skeleton: Skeleton): Mesh;
  21473. /**
  21474. * 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
  21475. * @param meshes defines the list of meshes to scan
  21476. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21477. */
  21478. static MinMax(meshes: AbstractMesh[]): {
  21479. min: Vector3;
  21480. max: Vector3;
  21481. };
  21482. /**
  21483. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21484. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21485. * @returns a vector3
  21486. */
  21487. static Center(meshesOrMinMaxVector: {
  21488. min: Vector3;
  21489. max: Vector3;
  21490. } | AbstractMesh[]): Vector3;
  21491. /**
  21492. * Merge the array of meshes into a single mesh for performance reasons.
  21493. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21494. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21495. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21496. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21497. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21498. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21499. * @returns a new mesh
  21500. */
  21501. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21502. /** @hidden */
  21503. addInstance(instance: InstancedMesh): void;
  21504. /** @hidden */
  21505. removeInstance(instance: InstancedMesh): void;
  21506. }
  21507. }
  21508. declare module BABYLON {
  21509. /**
  21510. * Base class for the main features of a material in Babylon.js
  21511. */
  21512. export class Material implements IAnimatable {
  21513. /**
  21514. * Returns the triangle fill mode
  21515. */
  21516. static readonly TriangleFillMode: number;
  21517. /**
  21518. * Returns the wireframe mode
  21519. */
  21520. static readonly WireFrameFillMode: number;
  21521. /**
  21522. * Returns the point fill mode
  21523. */
  21524. static readonly PointFillMode: number;
  21525. /**
  21526. * Returns the point list draw mode
  21527. */
  21528. static readonly PointListDrawMode: number;
  21529. /**
  21530. * Returns the line list draw mode
  21531. */
  21532. static readonly LineListDrawMode: number;
  21533. /**
  21534. * Returns the line loop draw mode
  21535. */
  21536. static readonly LineLoopDrawMode: number;
  21537. /**
  21538. * Returns the line strip draw mode
  21539. */
  21540. static readonly LineStripDrawMode: number;
  21541. /**
  21542. * Returns the triangle strip draw mode
  21543. */
  21544. static readonly TriangleStripDrawMode: number;
  21545. /**
  21546. * Returns the triangle fan draw mode
  21547. */
  21548. static readonly TriangleFanDrawMode: number;
  21549. /**
  21550. * Stores the clock-wise side orientation
  21551. */
  21552. static readonly ClockWiseSideOrientation: number;
  21553. /**
  21554. * Stores the counter clock-wise side orientation
  21555. */
  21556. static readonly CounterClockWiseSideOrientation: number;
  21557. /**
  21558. * The dirty texture flag value
  21559. */
  21560. static readonly TextureDirtyFlag: number;
  21561. /**
  21562. * The dirty light flag value
  21563. */
  21564. static readonly LightDirtyFlag: number;
  21565. /**
  21566. * The dirty fresnel flag value
  21567. */
  21568. static readonly FresnelDirtyFlag: number;
  21569. /**
  21570. * The dirty attribute flag value
  21571. */
  21572. static readonly AttributesDirtyFlag: number;
  21573. /**
  21574. * The dirty misc flag value
  21575. */
  21576. static readonly MiscDirtyFlag: number;
  21577. /**
  21578. * The all dirty flag value
  21579. */
  21580. static readonly AllDirtyFlag: number;
  21581. /**
  21582. * The ID of the material
  21583. */
  21584. id: string;
  21585. /**
  21586. * Gets or sets the unique id of the material
  21587. */
  21588. uniqueId: number;
  21589. /**
  21590. * The name of the material
  21591. */
  21592. name: string;
  21593. /**
  21594. * Gets or sets user defined metadata
  21595. */
  21596. metadata: any;
  21597. /**
  21598. * For internal use only. Please do not use.
  21599. */
  21600. reservedDataStore: any;
  21601. /**
  21602. * Specifies if the ready state should be checked on each call
  21603. */
  21604. checkReadyOnEveryCall: boolean;
  21605. /**
  21606. * Specifies if the ready state should be checked once
  21607. */
  21608. checkReadyOnlyOnce: boolean;
  21609. /**
  21610. * The state of the material
  21611. */
  21612. state: string;
  21613. /**
  21614. * The alpha value of the material
  21615. */
  21616. protected _alpha: number;
  21617. /**
  21618. * List of inspectable custom properties (used by the Inspector)
  21619. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21620. */
  21621. inspectableCustomProperties: IInspectable[];
  21622. /**
  21623. * Sets the alpha value of the material
  21624. */
  21625. /**
  21626. * Gets the alpha value of the material
  21627. */
  21628. alpha: number;
  21629. /**
  21630. * Specifies if back face culling is enabled
  21631. */
  21632. protected _backFaceCulling: boolean;
  21633. /**
  21634. * Sets the back-face culling state
  21635. */
  21636. /**
  21637. * Gets the back-face culling state
  21638. */
  21639. backFaceCulling: boolean;
  21640. /**
  21641. * Stores the value for side orientation
  21642. */
  21643. sideOrientation: number;
  21644. /**
  21645. * Callback triggered when the material is compiled
  21646. */
  21647. onCompiled: Nullable<(effect: Effect) => void>;
  21648. /**
  21649. * Callback triggered when an error occurs
  21650. */
  21651. onError: Nullable<(effect: Effect, errors: string) => void>;
  21652. /**
  21653. * Callback triggered to get the render target textures
  21654. */
  21655. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21656. /**
  21657. * Gets a boolean indicating that current material needs to register RTT
  21658. */
  21659. readonly hasRenderTargetTextures: boolean;
  21660. /**
  21661. * Specifies if the material should be serialized
  21662. */
  21663. doNotSerialize: boolean;
  21664. /**
  21665. * @hidden
  21666. */ storeEffectOnSubMeshes: boolean;
  21667. /**
  21668. * Stores the animations for the material
  21669. */
  21670. animations: Nullable<Array<Animation>>;
  21671. /**
  21672. * An event triggered when the material is disposed
  21673. */
  21674. onDisposeObservable: Observable<Material>;
  21675. /**
  21676. * An observer which watches for dispose events
  21677. */
  21678. private _onDisposeObserver;
  21679. private _onUnBindObservable;
  21680. /**
  21681. * Called during a dispose event
  21682. */
  21683. onDispose: () => void;
  21684. private _onBindObservable;
  21685. /**
  21686. * An event triggered when the material is bound
  21687. */
  21688. readonly onBindObservable: Observable<AbstractMesh>;
  21689. /**
  21690. * An observer which watches for bind events
  21691. */
  21692. private _onBindObserver;
  21693. /**
  21694. * Called during a bind event
  21695. */
  21696. onBind: (Mesh: AbstractMesh) => void;
  21697. /**
  21698. * An event triggered when the material is unbound
  21699. */
  21700. readonly onUnBindObservable: Observable<Material>;
  21701. /**
  21702. * Stores the value of the alpha mode
  21703. */
  21704. private _alphaMode;
  21705. /**
  21706. * Sets the value of the alpha mode.
  21707. *
  21708. * | Value | Type | Description |
  21709. * | --- | --- | --- |
  21710. * | 0 | ALPHA_DISABLE | |
  21711. * | 1 | ALPHA_ADD | |
  21712. * | 2 | ALPHA_COMBINE | |
  21713. * | 3 | ALPHA_SUBTRACT | |
  21714. * | 4 | ALPHA_MULTIPLY | |
  21715. * | 5 | ALPHA_MAXIMIZED | |
  21716. * | 6 | ALPHA_ONEONE | |
  21717. * | 7 | ALPHA_PREMULTIPLIED | |
  21718. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21719. * | 9 | ALPHA_INTERPOLATE | |
  21720. * | 10 | ALPHA_SCREENMODE | |
  21721. *
  21722. */
  21723. /**
  21724. * Gets the value of the alpha mode
  21725. */
  21726. alphaMode: number;
  21727. /**
  21728. * Stores the state of the need depth pre-pass value
  21729. */
  21730. private _needDepthPrePass;
  21731. /**
  21732. * Sets the need depth pre-pass value
  21733. */
  21734. /**
  21735. * Gets the depth pre-pass value
  21736. */
  21737. needDepthPrePass: boolean;
  21738. /**
  21739. * Specifies if depth writing should be disabled
  21740. */
  21741. disableDepthWrite: boolean;
  21742. /**
  21743. * Specifies if depth writing should be forced
  21744. */
  21745. forceDepthWrite: boolean;
  21746. /**
  21747. * Specifies if there should be a separate pass for culling
  21748. */
  21749. separateCullingPass: boolean;
  21750. /**
  21751. * Stores the state specifing if fog should be enabled
  21752. */
  21753. private _fogEnabled;
  21754. /**
  21755. * Sets the state for enabling fog
  21756. */
  21757. /**
  21758. * Gets the value of the fog enabled state
  21759. */
  21760. fogEnabled: boolean;
  21761. /**
  21762. * Stores the size of points
  21763. */
  21764. pointSize: number;
  21765. /**
  21766. * Stores the z offset value
  21767. */
  21768. zOffset: number;
  21769. /**
  21770. * Gets a value specifying if wireframe mode is enabled
  21771. */
  21772. /**
  21773. * Sets the state of wireframe mode
  21774. */
  21775. wireframe: boolean;
  21776. /**
  21777. * Gets the value specifying if point clouds are enabled
  21778. */
  21779. /**
  21780. * Sets the state of point cloud mode
  21781. */
  21782. pointsCloud: boolean;
  21783. /**
  21784. * Gets the material fill mode
  21785. */
  21786. /**
  21787. * Sets the material fill mode
  21788. */
  21789. fillMode: number;
  21790. /**
  21791. * @hidden
  21792. * Stores the effects for the material
  21793. */ effect: Nullable<Effect>;
  21794. /**
  21795. * @hidden
  21796. * Specifies if the material was previously ready
  21797. */ wasPreviouslyReady: boolean;
  21798. /**
  21799. * Specifies if uniform buffers should be used
  21800. */
  21801. private _useUBO;
  21802. /**
  21803. * Stores a reference to the scene
  21804. */
  21805. private _scene;
  21806. /**
  21807. * Stores the fill mode state
  21808. */
  21809. private _fillMode;
  21810. /**
  21811. * Specifies if the depth write state should be cached
  21812. */
  21813. private _cachedDepthWriteState;
  21814. /**
  21815. * Stores the uniform buffer
  21816. */
  21817. protected _uniformBuffer: UniformBuffer;
  21818. /** @hidden */ indexInSceneMaterialArray: number;
  21819. /** @hidden */
  21820. meshMap: Nullable<{
  21821. [id: string]: AbstractMesh | undefined;
  21822. }>;
  21823. /**
  21824. * Creates a material instance
  21825. * @param name defines the name of the material
  21826. * @param scene defines the scene to reference
  21827. * @param doNotAdd specifies if the material should be added to the scene
  21828. */
  21829. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21830. /**
  21831. * Returns a string representation of the current material
  21832. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21833. * @returns a string with material information
  21834. */
  21835. toString(fullDetails?: boolean): string;
  21836. /**
  21837. * Gets the class name of the material
  21838. * @returns a string with the class name of the material
  21839. */
  21840. getClassName(): string;
  21841. /**
  21842. * Specifies if updates for the material been locked
  21843. */
  21844. readonly isFrozen: boolean;
  21845. /**
  21846. * Locks updates for the material
  21847. */
  21848. freeze(): void;
  21849. /**
  21850. * Unlocks updates for the material
  21851. */
  21852. unfreeze(): void;
  21853. /**
  21854. * Specifies if the material is ready to be used
  21855. * @param mesh defines the mesh to check
  21856. * @param useInstances specifies if instances should be used
  21857. * @returns a boolean indicating if the material is ready to be used
  21858. */
  21859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21860. /**
  21861. * Specifies that the submesh is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param subMesh defines which submesh to check
  21864. * @param useInstances specifies that instances should be used
  21865. * @returns a boolean indicating that the submesh is ready or not
  21866. */
  21867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21868. /**
  21869. * Returns the material effect
  21870. * @returns the effect associated with the material
  21871. */
  21872. getEffect(): Nullable<Effect>;
  21873. /**
  21874. * Returns the current scene
  21875. * @returns a Scene
  21876. */
  21877. getScene(): Scene;
  21878. /**
  21879. * Specifies if the material will require alpha blending
  21880. * @returns a boolean specifying if alpha blending is needed
  21881. */
  21882. needAlphaBlending(): boolean;
  21883. /**
  21884. * Specifies if the mesh will require alpha blending
  21885. * @param mesh defines the mesh to check
  21886. * @returns a boolean specifying if alpha blending is needed for the mesh
  21887. */
  21888. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21889. /**
  21890. * Specifies if this material should be rendered in alpha test mode
  21891. * @returns a boolean specifying if an alpha test is needed.
  21892. */
  21893. needAlphaTesting(): boolean;
  21894. /**
  21895. * Gets the texture used for the alpha test
  21896. * @returns the texture to use for alpha testing
  21897. */
  21898. getAlphaTestTexture(): Nullable<BaseTexture>;
  21899. /**
  21900. * Marks the material to indicate that it needs to be re-calculated
  21901. */
  21902. markDirty(): void;
  21903. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21904. /**
  21905. * Binds the material to the mesh
  21906. * @param world defines the world transformation matrix
  21907. * @param mesh defines the mesh to bind the material to
  21908. */
  21909. bind(world: Matrix, mesh?: Mesh): void;
  21910. /**
  21911. * Binds the submesh to the material
  21912. * @param world defines the world transformation matrix
  21913. * @param mesh defines the mesh containing the submesh
  21914. * @param subMesh defines the submesh to bind the material to
  21915. */
  21916. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21917. /**
  21918. * Binds the world matrix to the material
  21919. * @param world defines the world transformation matrix
  21920. */
  21921. bindOnlyWorldMatrix(world: Matrix): void;
  21922. /**
  21923. * Binds the scene's uniform buffer to the effect.
  21924. * @param effect defines the effect to bind to the scene uniform buffer
  21925. * @param sceneUbo defines the uniform buffer storing scene data
  21926. */
  21927. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21928. /**
  21929. * Binds the view matrix to the effect
  21930. * @param effect defines the effect to bind the view matrix to
  21931. */
  21932. bindView(effect: Effect): void;
  21933. /**
  21934. * Binds the view projection matrix to the effect
  21935. * @param effect defines the effect to bind the view projection matrix to
  21936. */
  21937. bindViewProjection(effect: Effect): void;
  21938. /**
  21939. * Specifies if material alpha testing should be turned on for the mesh
  21940. * @param mesh defines the mesh to check
  21941. */
  21942. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21943. /**
  21944. * Processes to execute after binding the material to a mesh
  21945. * @param mesh defines the rendered mesh
  21946. */
  21947. protected _afterBind(mesh?: Mesh): void;
  21948. /**
  21949. * Unbinds the material from the mesh
  21950. */
  21951. unbind(): void;
  21952. /**
  21953. * Gets the active textures from the material
  21954. * @returns an array of textures
  21955. */
  21956. getActiveTextures(): BaseTexture[];
  21957. /**
  21958. * Specifies if the material uses a texture
  21959. * @param texture defines the texture to check against the material
  21960. * @returns a boolean specifying if the material uses the texture
  21961. */
  21962. hasTexture(texture: BaseTexture): boolean;
  21963. /**
  21964. * Makes a duplicate of the material, and gives it a new name
  21965. * @param name defines the new name for the duplicated material
  21966. * @returns the cloned material
  21967. */
  21968. clone(name: string): Nullable<Material>;
  21969. /**
  21970. * Gets the meshes bound to the material
  21971. * @returns an array of meshes bound to the material
  21972. */
  21973. getBindedMeshes(): AbstractMesh[];
  21974. /**
  21975. * Force shader compilation
  21976. * @param mesh defines the mesh associated with this material
  21977. * @param onCompiled defines a function to execute once the material is compiled
  21978. * @param options defines the options to configure the compilation
  21979. */
  21980. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21981. clipPlane: boolean;
  21982. }>): void;
  21983. /**
  21984. * Force shader compilation
  21985. * @param mesh defines the mesh that will use this material
  21986. * @param options defines additional options for compiling the shaders
  21987. * @returns a promise that resolves when the compilation completes
  21988. */
  21989. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21990. clipPlane: boolean;
  21991. }>): Promise<void>;
  21992. private static readonly _ImageProcessingDirtyCallBack;
  21993. private static readonly _TextureDirtyCallBack;
  21994. private static readonly _FresnelDirtyCallBack;
  21995. private static readonly _MiscDirtyCallBack;
  21996. private static readonly _LightsDirtyCallBack;
  21997. private static readonly _AttributeDirtyCallBack;
  21998. private static _FresnelAndMiscDirtyCallBack;
  21999. private static _TextureAndMiscDirtyCallBack;
  22000. private static readonly _DirtyCallbackArray;
  22001. private static readonly _RunDirtyCallBacks;
  22002. /**
  22003. * Marks a define in the material to indicate that it needs to be re-computed
  22004. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22005. */
  22006. markAsDirty(flag: number): void;
  22007. /**
  22008. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22009. * @param func defines a function which checks material defines against the submeshes
  22010. */
  22011. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22012. /**
  22013. * Indicates that image processing needs to be re-calculated for all submeshes
  22014. */
  22015. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22016. /**
  22017. * Indicates that textures need to be re-calculated for all submeshes
  22018. */
  22019. protected _markAllSubMeshesAsTexturesDirty(): void;
  22020. /**
  22021. * Indicates that fresnel needs to be re-calculated for all submeshes
  22022. */
  22023. protected _markAllSubMeshesAsFresnelDirty(): void;
  22024. /**
  22025. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22026. */
  22027. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22028. /**
  22029. * Indicates that lights need to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsLightsDirty(): void;
  22032. /**
  22033. * Indicates that attributes need to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsAttributesDirty(): void;
  22036. /**
  22037. * Indicates that misc needs to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsMiscDirty(): void;
  22040. /**
  22041. * Indicates that textures and misc need to be re-calculated for all submeshes
  22042. */
  22043. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22044. /**
  22045. * Disposes the material
  22046. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22047. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22048. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22049. */
  22050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22051. /** @hidden */
  22052. private releaseVertexArrayObject;
  22053. /**
  22054. * Serializes this material
  22055. * @returns the serialized material object
  22056. */
  22057. serialize(): any;
  22058. /**
  22059. * Creates a material from parsed material data
  22060. * @param parsedMaterial defines parsed material data
  22061. * @param scene defines the hosting scene
  22062. * @param rootUrl defines the root URL to use to load textures
  22063. * @returns a new material
  22064. */
  22065. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22066. }
  22067. }
  22068. declare module BABYLON {
  22069. /**
  22070. * Base class for submeshes
  22071. */
  22072. export class BaseSubMesh {
  22073. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22074. /** @hidden */ materialEffect: Nullable<Effect>;
  22075. /**
  22076. * Gets associated effect
  22077. */
  22078. readonly effect: Nullable<Effect>;
  22079. /**
  22080. * Sets associated effect (effect used to render this submesh)
  22081. * @param effect defines the effect to associate with
  22082. * @param defines defines the set of defines used to compile this effect
  22083. */
  22084. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22085. }
  22086. /**
  22087. * Defines a subdivision inside a mesh
  22088. */
  22089. export class SubMesh extends BaseSubMesh implements ICullable {
  22090. /** the material index to use */
  22091. materialIndex: number;
  22092. /** vertex index start */
  22093. verticesStart: number;
  22094. /** vertices count */
  22095. verticesCount: number;
  22096. /** index start */
  22097. indexStart: number;
  22098. /** indices count */
  22099. indexCount: number;
  22100. /** @hidden */ linesIndexCount: number;
  22101. private _mesh;
  22102. private _renderingMesh;
  22103. private _boundingInfo;
  22104. private _linesIndexBuffer;
  22105. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22106. /** @hidden */ trianglePlanes: Plane[];
  22107. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22108. /** @hidden */ renderId: number;
  22109. /** @hidden */ alphaIndex: number;
  22110. /** @hidden */ distanceToCamera: number;
  22111. /** @hidden */ id: number;
  22112. private _currentMaterial;
  22113. /**
  22114. * Add a new submesh to a mesh
  22115. * @param materialIndex defines the material index to use
  22116. * @param verticesStart defines vertex index start
  22117. * @param verticesCount defines vertices count
  22118. * @param indexStart defines index start
  22119. * @param indexCount defines indices count
  22120. * @param mesh defines the parent mesh
  22121. * @param renderingMesh defines an optional rendering mesh
  22122. * @param createBoundingBox defines if bounding box should be created for this submesh
  22123. * @returns the new submesh
  22124. */
  22125. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22126. /**
  22127. * Creates a new submesh
  22128. * @param materialIndex defines the material index to use
  22129. * @param verticesStart defines vertex index start
  22130. * @param verticesCount defines vertices count
  22131. * @param indexStart defines index start
  22132. * @param indexCount defines indices count
  22133. * @param mesh defines the parent mesh
  22134. * @param renderingMesh defines an optional rendering mesh
  22135. * @param createBoundingBox defines if bounding box should be created for this submesh
  22136. */
  22137. constructor(
  22138. /** the material index to use */
  22139. materialIndex: number,
  22140. /** vertex index start */
  22141. verticesStart: number,
  22142. /** vertices count */
  22143. verticesCount: number,
  22144. /** index start */
  22145. indexStart: number,
  22146. /** indices count */
  22147. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22148. /**
  22149. * Returns true if this submesh covers the entire parent mesh
  22150. * @ignorenaming
  22151. */
  22152. readonly IsGlobal: boolean;
  22153. /**
  22154. * Returns the submesh BoudingInfo object
  22155. * @returns current bounding info (or mesh's one if the submesh is global)
  22156. */
  22157. getBoundingInfo(): BoundingInfo;
  22158. /**
  22159. * Sets the submesh BoundingInfo
  22160. * @param boundingInfo defines the new bounding info to use
  22161. * @returns the SubMesh
  22162. */
  22163. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22164. /**
  22165. * Returns the mesh of the current submesh
  22166. * @return the parent mesh
  22167. */
  22168. getMesh(): AbstractMesh;
  22169. /**
  22170. * Returns the rendering mesh of the submesh
  22171. * @returns the rendering mesh (could be different from parent mesh)
  22172. */
  22173. getRenderingMesh(): Mesh;
  22174. /**
  22175. * Returns the submesh material
  22176. * @returns null or the current material
  22177. */
  22178. getMaterial(): Nullable<Material>;
  22179. /**
  22180. * Sets a new updated BoundingInfo object to the submesh
  22181. * @param data defines an optional position array to use to determine the bounding info
  22182. * @returns the SubMesh
  22183. */
  22184. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22185. /** @hidden */ checkCollision(collider: Collider): boolean;
  22186. /**
  22187. * Updates the submesh BoundingInfo
  22188. * @param world defines the world matrix to use to update the bounding info
  22189. * @returns the submesh
  22190. */
  22191. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22192. /**
  22193. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22194. * @param frustumPlanes defines the frustum planes
  22195. * @returns true if the submesh is intersecting with the frustum
  22196. */
  22197. isInFrustum(frustumPlanes: Plane[]): boolean;
  22198. /**
  22199. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22200. * @param frustumPlanes defines the frustum planes
  22201. * @returns true if the submesh is inside the frustum
  22202. */
  22203. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22204. /**
  22205. * Renders the submesh
  22206. * @param enableAlphaMode defines if alpha needs to be used
  22207. * @returns the submesh
  22208. */
  22209. render(enableAlphaMode: boolean): SubMesh;
  22210. /**
  22211. * @hidden
  22212. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22213. /**
  22214. * Checks if the submesh intersects with a ray
  22215. * @param ray defines the ray to test
  22216. * @returns true is the passed ray intersects the submesh bounding box
  22217. */
  22218. canIntersects(ray: Ray): boolean;
  22219. /**
  22220. * Intersects current submesh with a ray
  22221. * @param ray defines the ray to test
  22222. * @param positions defines mesh's positions array
  22223. * @param indices defines mesh's indices array
  22224. * @param fastCheck defines if only bounding info should be used
  22225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22226. * @returns intersection info or null if no intersection
  22227. */
  22228. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22229. /** @hidden */
  22230. private _intersectLines;
  22231. /** @hidden */
  22232. private _intersectTriangles;
  22233. /** @hidden */ rebuild(): void;
  22234. /**
  22235. * Creates a new submesh from the passed mesh
  22236. * @param newMesh defines the new hosting mesh
  22237. * @param newRenderingMesh defines an optional rendering mesh
  22238. * @returns the new submesh
  22239. */
  22240. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22241. /**
  22242. * Release associated resources
  22243. */
  22244. dispose(): void;
  22245. /**
  22246. * Gets the class name
  22247. * @returns the string "SubMesh".
  22248. */
  22249. getClassName(): string;
  22250. /**
  22251. * Creates a new submesh from indices data
  22252. * @param materialIndex the index of the main mesh material
  22253. * @param startIndex the index where to start the copy in the mesh indices array
  22254. * @param indexCount the number of indices to copy then from the startIndex
  22255. * @param mesh the main mesh to create the submesh from
  22256. * @param renderingMesh the optional rendering mesh
  22257. * @returns a new submesh
  22258. */
  22259. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22260. }
  22261. }
  22262. declare module BABYLON {
  22263. /**
  22264. * Class used to store geometry data (vertex buffers + index buffer)
  22265. */
  22266. export class Geometry implements IGetSetVerticesData {
  22267. /**
  22268. * Gets or sets the ID of the geometry
  22269. */
  22270. id: string;
  22271. /**
  22272. * Gets or sets the unique ID of the geometry
  22273. */
  22274. uniqueId: number;
  22275. /**
  22276. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22277. */
  22278. delayLoadState: number;
  22279. /**
  22280. * Gets the file containing the data to load when running in delay load state
  22281. */
  22282. delayLoadingFile: Nullable<string>;
  22283. /**
  22284. * Callback called when the geometry is updated
  22285. */
  22286. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22287. private _scene;
  22288. private _engine;
  22289. private _meshes;
  22290. private _totalVertices;
  22291. /** @hidden */ indices: IndicesArray;
  22292. /** @hidden */ vertexBuffers: {
  22293. [key: string]: VertexBuffer;
  22294. };
  22295. private _isDisposed;
  22296. private _extend;
  22297. private _boundingBias;
  22298. /** @hidden */ delayInfo: Array<string>;
  22299. private _indexBuffer;
  22300. private _indexBufferIsUpdatable;
  22301. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22302. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22303. /** @hidden */ softwareSkinningFrameId: number;
  22304. private _vertexArrayObjects;
  22305. private _updatable;
  22306. /** @hidden */ positions: Nullable<Vector3[]>;
  22307. /**
  22308. * 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
  22309. */
  22310. /**
  22311. * 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
  22312. */
  22313. boundingBias: Vector2;
  22314. /**
  22315. * Static function used to attach a new empty geometry to a mesh
  22316. * @param mesh defines the mesh to attach the geometry to
  22317. * @returns the new Geometry
  22318. */
  22319. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22320. /**
  22321. * Creates a new geometry
  22322. * @param id defines the unique ID
  22323. * @param scene defines the hosting scene
  22324. * @param vertexData defines the VertexData used to get geometry data
  22325. * @param updatable defines if geometry must be updatable (false by default)
  22326. * @param mesh defines the mesh that will be associated with the geometry
  22327. */
  22328. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22329. /**
  22330. * Gets the current extend of the geometry
  22331. */
  22332. readonly extend: {
  22333. minimum: Vector3;
  22334. maximum: Vector3;
  22335. };
  22336. /**
  22337. * Gets the hosting scene
  22338. * @returns the hosting Scene
  22339. */
  22340. getScene(): Scene;
  22341. /**
  22342. * Gets the hosting engine
  22343. * @returns the hosting Engine
  22344. */
  22345. getEngine(): Engine;
  22346. /**
  22347. * Defines if the geometry is ready to use
  22348. * @returns true if the geometry is ready to be used
  22349. */
  22350. isReady(): boolean;
  22351. /**
  22352. * Gets a value indicating that the geometry should not be serialized
  22353. */
  22354. readonly doNotSerialize: boolean;
  22355. /** @hidden */ rebuild(): void;
  22356. /**
  22357. * Affects all geometry data in one call
  22358. * @param vertexData defines the geometry data
  22359. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22360. */
  22361. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22362. /**
  22363. * Set specific vertex data
  22364. * @param kind defines the data kind (Position, normal, etc...)
  22365. * @param data defines the vertex data to use
  22366. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22367. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22368. */
  22369. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22370. /**
  22371. * Removes a specific vertex data
  22372. * @param kind defines the data kind (Position, normal, etc...)
  22373. */
  22374. removeVerticesData(kind: string): void;
  22375. /**
  22376. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22377. * @param buffer defines the vertex buffer to use
  22378. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22379. */
  22380. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22381. /**
  22382. * Update a specific vertex buffer
  22383. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22384. * It will do nothing if the buffer is not updatable
  22385. * @param kind defines the data kind (Position, normal, etc...)
  22386. * @param data defines the data to use
  22387. * @param offset defines the offset in the target buffer where to store the data
  22388. * @param useBytes set to true if the offset is in bytes
  22389. */
  22390. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22391. /**
  22392. * Update a specific vertex buffer
  22393. * This function will create a new buffer if the current one is not updatable
  22394. * @param kind defines the data kind (Position, normal, etc...)
  22395. * @param data defines the data to use
  22396. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22397. */
  22398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22399. private _updateBoundingInfo;
  22400. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22401. /**
  22402. * Gets total number of vertices
  22403. * @returns the total number of vertices
  22404. */
  22405. getTotalVertices(): number;
  22406. /**
  22407. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22408. * @param kind defines the data kind (Position, normal, etc...)
  22409. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22410. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22411. * @returns a float array containing vertex data
  22412. */
  22413. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22414. /**
  22415. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. * @returns true if the vertex buffer with the specified kind is updatable
  22418. */
  22419. isVertexBufferUpdatable(kind: string): boolean;
  22420. /**
  22421. * Gets a specific vertex buffer
  22422. * @param kind defines the data kind (Position, normal, etc...)
  22423. * @returns a VertexBuffer
  22424. */
  22425. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22426. /**
  22427. * Returns all vertex buffers
  22428. * @return an object holding all vertex buffers indexed by kind
  22429. */
  22430. getVertexBuffers(): Nullable<{
  22431. [key: string]: VertexBuffer;
  22432. }>;
  22433. /**
  22434. * Gets a boolean indicating if specific vertex buffer is present
  22435. * @param kind defines the data kind (Position, normal, etc...)
  22436. * @returns true if data is present
  22437. */
  22438. isVerticesDataPresent(kind: string): boolean;
  22439. /**
  22440. * Gets a list of all attached data kinds (Position, normal, etc...)
  22441. * @returns a list of string containing all kinds
  22442. */
  22443. getVerticesDataKinds(): string[];
  22444. /**
  22445. * Update index buffer
  22446. * @param indices defines the indices to store in the index buffer
  22447. * @param offset defines the offset in the target buffer where to store the data
  22448. * @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)
  22449. */
  22450. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22451. /**
  22452. * Creates a new index buffer
  22453. * @param indices defines the indices to store in the index buffer
  22454. * @param totalVertices defines the total number of vertices (could be null)
  22455. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22456. */
  22457. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22458. /**
  22459. * Return the total number of indices
  22460. * @returns the total number of indices
  22461. */
  22462. getTotalIndices(): number;
  22463. /**
  22464. * Gets the index buffer array
  22465. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22466. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22467. * @returns the index buffer array
  22468. */
  22469. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22470. /**
  22471. * Gets the index buffer
  22472. * @return the index buffer
  22473. */
  22474. getIndexBuffer(): Nullable<DataBuffer>;
  22475. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22476. /**
  22477. * Release the associated resources for a specific mesh
  22478. * @param mesh defines the source mesh
  22479. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22480. */
  22481. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22482. /**
  22483. * Apply current geometry to a given mesh
  22484. * @param mesh defines the mesh to apply geometry to
  22485. */
  22486. applyToMesh(mesh: Mesh): void;
  22487. private _updateExtend;
  22488. private _applyToMesh;
  22489. private notifyUpdate;
  22490. /**
  22491. * Load the geometry if it was flagged as delay loaded
  22492. * @param scene defines the hosting scene
  22493. * @param onLoaded defines a callback called when the geometry is loaded
  22494. */
  22495. load(scene: Scene, onLoaded?: () => void): void;
  22496. private _queueLoad;
  22497. /**
  22498. * Invert the geometry to move from a right handed system to a left handed one.
  22499. */
  22500. toLeftHanded(): void;
  22501. /** @hidden */ resetPointsArrayCache(): void;
  22502. /** @hidden */ generatePointsArray(): boolean;
  22503. /**
  22504. * Gets a value indicating if the geometry is disposed
  22505. * @returns true if the geometry was disposed
  22506. */
  22507. isDisposed(): boolean;
  22508. private _disposeVertexArrayObjects;
  22509. /**
  22510. * Free all associated resources
  22511. */
  22512. dispose(): void;
  22513. /**
  22514. * Clone the current geometry into a new geometry
  22515. * @param id defines the unique ID of the new geometry
  22516. * @returns a new geometry object
  22517. */
  22518. copy(id: string): Geometry;
  22519. /**
  22520. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22521. * @return a JSON representation of the current geometry data (without the vertices data)
  22522. */
  22523. serialize(): any;
  22524. private toNumberArray;
  22525. /**
  22526. * Serialize all vertices data into a JSON oject
  22527. * @returns a JSON representation of the current geometry data
  22528. */
  22529. serializeVerticeData(): any;
  22530. /**
  22531. * Extracts a clone of a mesh geometry
  22532. * @param mesh defines the source mesh
  22533. * @param id defines the unique ID of the new geometry object
  22534. * @returns the new geometry object
  22535. */
  22536. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22537. /**
  22538. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22539. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22540. * Be aware Math.random() could cause collisions, but:
  22541. * "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"
  22542. * @returns a string containing a new GUID
  22543. */
  22544. static RandomId(): string;
  22545. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22546. private static _CleanMatricesWeights;
  22547. /**
  22548. * Create a new geometry from persisted data (Using .babylon file format)
  22549. * @param parsedVertexData defines the persisted data
  22550. * @param scene defines the hosting scene
  22551. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22552. * @returns the new geometry object
  22553. */
  22554. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22555. }
  22556. }
  22557. declare module BABYLON {
  22558. /**
  22559. * Define an interface for all classes that will get and set the data on vertices
  22560. */
  22561. export interface IGetSetVerticesData {
  22562. /**
  22563. * Gets a boolean indicating if specific vertex data is present
  22564. * @param kind defines the vertex data kind to use
  22565. * @returns true is data kind is present
  22566. */
  22567. isVerticesDataPresent(kind: string): boolean;
  22568. /**
  22569. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22570. * @param kind defines the data kind (Position, normal, etc...)
  22571. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22572. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22573. * @returns a float array containing vertex data
  22574. */
  22575. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22576. /**
  22577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22578. * @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.
  22579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22580. * @returns the indices array or an empty array if the mesh has no geometry
  22581. */
  22582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22583. /**
  22584. * Set specific vertex data
  22585. * @param kind defines the data kind (Position, normal, etc...)
  22586. * @param data defines the vertex data to use
  22587. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22588. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22589. */
  22590. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22591. /**
  22592. * Update a specific associated vertex buffer
  22593. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22594. * - VertexBuffer.PositionKind
  22595. * - VertexBuffer.UVKind
  22596. * - VertexBuffer.UV2Kind
  22597. * - VertexBuffer.UV3Kind
  22598. * - VertexBuffer.UV4Kind
  22599. * - VertexBuffer.UV5Kind
  22600. * - VertexBuffer.UV6Kind
  22601. * - VertexBuffer.ColorKind
  22602. * - VertexBuffer.MatricesIndicesKind
  22603. * - VertexBuffer.MatricesIndicesExtraKind
  22604. * - VertexBuffer.MatricesWeightsKind
  22605. * - VertexBuffer.MatricesWeightsExtraKind
  22606. * @param data defines the data source
  22607. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22608. * @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)
  22609. */
  22610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22611. /**
  22612. * Creates a new index buffer
  22613. * @param indices defines the indices to store in the index buffer
  22614. * @param totalVertices defines the total number of vertices (could be null)
  22615. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22616. */
  22617. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22618. }
  22619. /**
  22620. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22621. */
  22622. export class VertexData {
  22623. /**
  22624. * Mesh side orientation : usually the external or front surface
  22625. */
  22626. static readonly FRONTSIDE: number;
  22627. /**
  22628. * Mesh side orientation : usually the internal or back surface
  22629. */
  22630. static readonly BACKSIDE: number;
  22631. /**
  22632. * Mesh side orientation : both internal and external or front and back surfaces
  22633. */
  22634. static readonly DOUBLESIDE: number;
  22635. /**
  22636. * Mesh side orientation : by default, `FRONTSIDE`
  22637. */
  22638. static readonly DEFAULTSIDE: number;
  22639. /**
  22640. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22641. */
  22642. positions: Nullable<FloatArray>;
  22643. /**
  22644. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22645. */
  22646. normals: Nullable<FloatArray>;
  22647. /**
  22648. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22649. */
  22650. tangents: Nullable<FloatArray>;
  22651. /**
  22652. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22653. */
  22654. uvs: Nullable<FloatArray>;
  22655. /**
  22656. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22657. */
  22658. uvs2: Nullable<FloatArray>;
  22659. /**
  22660. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22661. */
  22662. uvs3: Nullable<FloatArray>;
  22663. /**
  22664. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22665. */
  22666. uvs4: Nullable<FloatArray>;
  22667. /**
  22668. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22669. */
  22670. uvs5: Nullable<FloatArray>;
  22671. /**
  22672. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22673. */
  22674. uvs6: Nullable<FloatArray>;
  22675. /**
  22676. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22677. */
  22678. colors: Nullable<FloatArray>;
  22679. /**
  22680. * 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).
  22681. */
  22682. matricesIndices: Nullable<FloatArray>;
  22683. /**
  22684. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22685. */
  22686. matricesWeights: Nullable<FloatArray>;
  22687. /**
  22688. * An array extending the number of possible indices
  22689. */
  22690. matricesIndicesExtra: Nullable<FloatArray>;
  22691. /**
  22692. * An array extending the number of possible weights when the number of indices is extended
  22693. */
  22694. matricesWeightsExtra: Nullable<FloatArray>;
  22695. /**
  22696. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22697. */
  22698. indices: Nullable<IndicesArray>;
  22699. /**
  22700. * Uses the passed data array to set the set the values for the specified kind of data
  22701. * @param data a linear array of floating numbers
  22702. * @param kind the type of data that is being set, eg positions, colors etc
  22703. */
  22704. set(data: FloatArray, kind: string): void;
  22705. /**
  22706. * Associates the vertexData to the passed Mesh.
  22707. * Sets it as updatable or not (default `false`)
  22708. * @param mesh the mesh the vertexData is applied to
  22709. * @param updatable when used and having the value true allows new data to update the vertexData
  22710. * @returns the VertexData
  22711. */
  22712. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22713. /**
  22714. * Associates the vertexData to the passed Geometry.
  22715. * Sets it as updatable or not (default `false`)
  22716. * @param geometry the geometry the vertexData is applied to
  22717. * @param updatable when used and having the value true allows new data to update the vertexData
  22718. * @returns VertexData
  22719. */
  22720. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22721. /**
  22722. * Updates the associated mesh
  22723. * @param mesh the mesh to be updated
  22724. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22725. * @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
  22726. * @returns VertexData
  22727. */
  22728. updateMesh(mesh: Mesh): VertexData;
  22729. /**
  22730. * Updates the associated geometry
  22731. * @param geometry the geometry to be updated
  22732. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22733. * @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
  22734. * @returns VertexData.
  22735. */
  22736. updateGeometry(geometry: Geometry): VertexData;
  22737. private _applyTo;
  22738. private _update;
  22739. /**
  22740. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22741. * @param matrix the transforming matrix
  22742. * @returns the VertexData
  22743. */
  22744. transform(matrix: Matrix): VertexData;
  22745. /**
  22746. * Merges the passed VertexData into the current one
  22747. * @param other the VertexData to be merged into the current one
  22748. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22749. * @returns the modified VertexData
  22750. */
  22751. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22752. private _mergeElement;
  22753. private _validate;
  22754. /**
  22755. * Serializes the VertexData
  22756. * @returns a serialized object
  22757. */
  22758. serialize(): any;
  22759. /**
  22760. * Extracts the vertexData from a mesh
  22761. * @param mesh the mesh from which to extract the VertexData
  22762. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22763. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22764. * @returns the object VertexData associated to the passed mesh
  22765. */
  22766. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22767. /**
  22768. * Extracts the vertexData from the geometry
  22769. * @param geometry the geometry from which to extract the VertexData
  22770. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22771. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22772. * @returns the object VertexData associated to the passed mesh
  22773. */
  22774. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22775. private static _ExtractFrom;
  22776. /**
  22777. * Creates the VertexData for a Ribbon
  22778. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22779. * * pathArray array of paths, each of which an array of successive Vector3
  22780. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22781. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22782. * * 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
  22783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22784. * * 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)
  22785. * * 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)
  22786. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22787. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22788. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22789. * @returns the VertexData of the ribbon
  22790. */
  22791. static CreateRibbon(options: {
  22792. pathArray: Vector3[][];
  22793. closeArray?: boolean;
  22794. closePath?: boolean;
  22795. offset?: number;
  22796. sideOrientation?: number;
  22797. frontUVs?: Vector4;
  22798. backUVs?: Vector4;
  22799. invertUV?: boolean;
  22800. uvs?: Vector2[];
  22801. colors?: Color4[];
  22802. }): VertexData;
  22803. /**
  22804. * Creates the VertexData for a box
  22805. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22806. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22807. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22808. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22809. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22810. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22811. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * @returns the VertexData of the box
  22816. */
  22817. static CreateBox(options: {
  22818. size?: number;
  22819. width?: number;
  22820. height?: number;
  22821. depth?: number;
  22822. faceUV?: Vector4[];
  22823. faceColors?: Color4[];
  22824. sideOrientation?: number;
  22825. frontUVs?: Vector4;
  22826. backUVs?: Vector4;
  22827. }): VertexData;
  22828. /**
  22829. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22830. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22831. * * segments sets the number of horizontal strips optional, default 32
  22832. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22833. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22834. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22835. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22836. * * 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
  22837. * * 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
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * @returns the VertexData of the ellipsoid
  22842. */
  22843. static CreateSphere(options: {
  22844. segments?: number;
  22845. diameter?: number;
  22846. diameterX?: number;
  22847. diameterY?: number;
  22848. diameterZ?: number;
  22849. arc?: number;
  22850. slice?: number;
  22851. sideOrientation?: number;
  22852. frontUVs?: Vector4;
  22853. backUVs?: Vector4;
  22854. }): VertexData;
  22855. /**
  22856. * Creates the VertexData for a cylinder, cone or prism
  22857. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22858. * * height sets the height (y direction) of the cylinder, optional, default 2
  22859. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22860. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22861. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22862. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22863. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22864. * * 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
  22865. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22866. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22867. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22868. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22870. * * 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)
  22871. * * 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)
  22872. * @returns the VertexData of the cylinder, cone or prism
  22873. */
  22874. static CreateCylinder(options: {
  22875. height?: number;
  22876. diameterTop?: number;
  22877. diameterBottom?: number;
  22878. diameter?: number;
  22879. tessellation?: number;
  22880. subdivisions?: number;
  22881. arc?: number;
  22882. faceColors?: Color4[];
  22883. faceUV?: Vector4[];
  22884. hasRings?: boolean;
  22885. enclose?: boolean;
  22886. sideOrientation?: number;
  22887. frontUVs?: Vector4;
  22888. backUVs?: Vector4;
  22889. }): VertexData;
  22890. /**
  22891. * Creates the VertexData for a torus
  22892. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22893. * * diameter the diameter of the torus, optional default 1
  22894. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22895. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22897. * * 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)
  22898. * * 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)
  22899. * @returns the VertexData of the torus
  22900. */
  22901. static CreateTorus(options: {
  22902. diameter?: number;
  22903. thickness?: number;
  22904. tessellation?: number;
  22905. sideOrientation?: number;
  22906. frontUVs?: Vector4;
  22907. backUVs?: Vector4;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData of the LineSystem
  22911. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22912. * - lines an array of lines, each line being an array of successive Vector3
  22913. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22914. * @returns the VertexData of the LineSystem
  22915. */
  22916. static CreateLineSystem(options: {
  22917. lines: Vector3[][];
  22918. colors?: Nullable<Color4[][]>;
  22919. }): VertexData;
  22920. /**
  22921. * Create the VertexData for a DashedLines
  22922. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22923. * - points an array successive Vector3
  22924. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22925. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22926. * - dashNb the intended total number of dashes, optional, default 200
  22927. * @returns the VertexData for the DashedLines
  22928. */
  22929. static CreateDashedLines(options: {
  22930. points: Vector3[];
  22931. dashSize?: number;
  22932. gapSize?: number;
  22933. dashNb?: number;
  22934. }): VertexData;
  22935. /**
  22936. * Creates the VertexData for a Ground
  22937. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22938. * - width the width (x direction) of the ground, optional, default 1
  22939. * - height the height (z direction) of the ground, optional, default 1
  22940. * - subdivisions the number of subdivisions per side, optional, default 1
  22941. * @returns the VertexData of the Ground
  22942. */
  22943. static CreateGround(options: {
  22944. width?: number;
  22945. height?: number;
  22946. subdivisions?: number;
  22947. subdivisionsX?: number;
  22948. subdivisionsY?: number;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22952. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22953. * * xmin the ground minimum X coordinate, optional, default -1
  22954. * * zmin the ground minimum Z coordinate, optional, default -1
  22955. * * xmax the ground maximum X coordinate, optional, default 1
  22956. * * zmax the ground maximum Z coordinate, optional, default 1
  22957. * * 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}
  22958. * * 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}
  22959. * @returns the VertexData of the TiledGround
  22960. */
  22961. static CreateTiledGround(options: {
  22962. xmin: number;
  22963. zmin: number;
  22964. xmax: number;
  22965. zmax: number;
  22966. subdivisions?: {
  22967. w: number;
  22968. h: number;
  22969. };
  22970. precision?: {
  22971. w: number;
  22972. h: number;
  22973. };
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData of the Ground designed from a heightmap
  22977. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22978. * * width the width (x direction) of the ground
  22979. * * height the height (z direction) of the ground
  22980. * * subdivisions the number of subdivisions per side
  22981. * * minHeight the minimum altitude on the ground, optional, default 0
  22982. * * maxHeight the maximum altitude on the ground, optional default 1
  22983. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22984. * * buffer the array holding the image color data
  22985. * * bufferWidth the width of image
  22986. * * bufferHeight the height of image
  22987. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22988. * @returns the VertexData of the Ground designed from a heightmap
  22989. */
  22990. static CreateGroundFromHeightMap(options: {
  22991. width: number;
  22992. height: number;
  22993. subdivisions: number;
  22994. minHeight: number;
  22995. maxHeight: number;
  22996. colorFilter: Color3;
  22997. buffer: Uint8Array;
  22998. bufferWidth: number;
  22999. bufferHeight: number;
  23000. alphaFilter: number;
  23001. }): VertexData;
  23002. /**
  23003. * Creates the VertexData for a Plane
  23004. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23005. * * size sets the width and height of the plane to the value of size, optional default 1
  23006. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23007. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23009. * * 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)
  23010. * * 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)
  23011. * @returns the VertexData of the box
  23012. */
  23013. static CreatePlane(options: {
  23014. size?: number;
  23015. width?: number;
  23016. height?: number;
  23017. sideOrientation?: number;
  23018. frontUVs?: Vector4;
  23019. backUVs?: Vector4;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData of the Disc or regular Polygon
  23023. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23024. * * radius the radius of the disc, optional default 0.5
  23025. * * tessellation the number of polygon sides, optional, default 64
  23026. * * 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
  23027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23028. * * 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)
  23029. * * 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)
  23030. * @returns the VertexData of the box
  23031. */
  23032. static CreateDisc(options: {
  23033. radius?: number;
  23034. tessellation?: number;
  23035. arc?: number;
  23036. sideOrientation?: number;
  23037. frontUVs?: Vector4;
  23038. backUVs?: Vector4;
  23039. }): VertexData;
  23040. /**
  23041. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23042. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23043. * @param polygon a mesh built from polygonTriangulation.build()
  23044. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23045. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23046. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23047. * @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)
  23048. * @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)
  23049. * @returns the VertexData of the Polygon
  23050. */
  23051. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23052. /**
  23053. * Creates the VertexData of the IcoSphere
  23054. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23055. * * radius the radius of the IcoSphere, optional default 1
  23056. * * radiusX allows stretching in the x direction, optional, default radius
  23057. * * radiusY allows stretching in the y direction, optional, default radius
  23058. * * radiusZ allows stretching in the z direction, optional, default radius
  23059. * * flat when true creates a flat shaded mesh, optional, default true
  23060. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23062. * * 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)
  23063. * * 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)
  23064. * @returns the VertexData of the IcoSphere
  23065. */
  23066. static CreateIcoSphere(options: {
  23067. radius?: number;
  23068. radiusX?: number;
  23069. radiusY?: number;
  23070. radiusZ?: number;
  23071. flat?: boolean;
  23072. subdivisions?: number;
  23073. sideOrientation?: number;
  23074. frontUVs?: Vector4;
  23075. backUVs?: Vector4;
  23076. }): VertexData;
  23077. /**
  23078. * Creates the VertexData for a Polyhedron
  23079. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23080. * * type provided types are:
  23081. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23082. * * 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)
  23083. * * size the size of the IcoSphere, optional default 1
  23084. * * sizeX allows stretching in the x direction, optional, default size
  23085. * * sizeY allows stretching in the y direction, optional, default size
  23086. * * sizeZ allows stretching in the z direction, optional, default size
  23087. * * 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
  23088. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23089. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23090. * * flat when true creates a flat shaded mesh, optional, default true
  23091. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23093. * * 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)
  23094. * * 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)
  23095. * @returns the VertexData of the Polyhedron
  23096. */
  23097. static CreatePolyhedron(options: {
  23098. type?: number;
  23099. size?: number;
  23100. sizeX?: number;
  23101. sizeY?: number;
  23102. sizeZ?: number;
  23103. custom?: any;
  23104. faceUV?: Vector4[];
  23105. faceColors?: Color4[];
  23106. flat?: boolean;
  23107. sideOrientation?: number;
  23108. frontUVs?: Vector4;
  23109. backUVs?: Vector4;
  23110. }): VertexData;
  23111. /**
  23112. * Creates the VertexData for a TorusKnot
  23113. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23114. * * radius the radius of the torus knot, optional, default 2
  23115. * * tube the thickness of the tube, optional, default 0.5
  23116. * * radialSegments the number of sides on each tube segments, optional, default 32
  23117. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23118. * * p the number of windings around the z axis, optional, default 2
  23119. * * q the number of windings around the x axis, optional, default 3
  23120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23121. * * 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)
  23122. * * 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)
  23123. * @returns the VertexData of the Torus Knot
  23124. */
  23125. static CreateTorusKnot(options: {
  23126. radius?: number;
  23127. tube?: number;
  23128. radialSegments?: number;
  23129. tubularSegments?: number;
  23130. p?: number;
  23131. q?: number;
  23132. sideOrientation?: number;
  23133. frontUVs?: Vector4;
  23134. backUVs?: Vector4;
  23135. }): VertexData;
  23136. /**
  23137. * Compute normals for given positions and indices
  23138. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23139. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23140. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23141. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23142. * * facetNormals : optional array of facet normals (vector3)
  23143. * * facetPositions : optional array of facet positions (vector3)
  23144. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23145. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23146. * * bInfo : optional bounding info, required for facetPartitioning computation
  23147. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23148. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23149. * * useRightHandedSystem: optional boolean to for right handed system computation
  23150. * * depthSort : optional boolean to enable the facet depth sort computation
  23151. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23152. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23153. */
  23154. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23155. facetNormals?: any;
  23156. facetPositions?: any;
  23157. facetPartitioning?: any;
  23158. ratio?: number;
  23159. bInfo?: any;
  23160. bbSize?: Vector3;
  23161. subDiv?: any;
  23162. useRightHandedSystem?: boolean;
  23163. depthSort?: boolean;
  23164. distanceTo?: Vector3;
  23165. depthSortedFacets?: any;
  23166. }): void;
  23167. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23168. /**
  23169. * Applies VertexData created from the imported parameters to the geometry
  23170. * @param parsedVertexData the parsed data from an imported file
  23171. * @param geometry the geometry to apply the VertexData to
  23172. */
  23173. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23174. }
  23175. }
  23176. declare module BABYLON {
  23177. /**
  23178. * Class containing static functions to help procedurally build meshes
  23179. */
  23180. export class DiscBuilder {
  23181. /**
  23182. * Creates a plane polygonal mesh. By default, this is a disc
  23183. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23184. * * 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
  23185. * * 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
  23186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23187. * * 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
  23188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23189. * @param name defines the name of the mesh
  23190. * @param options defines the options used to create the mesh
  23191. * @param scene defines the hosting scene
  23192. * @returns the plane polygonal mesh
  23193. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23194. */
  23195. static CreateDisc(name: string, options: {
  23196. radius?: number;
  23197. tessellation?: number;
  23198. arc?: number;
  23199. updatable?: boolean;
  23200. sideOrientation?: number;
  23201. frontUVs?: Vector4;
  23202. backUVs?: Vector4;
  23203. }, scene?: Nullable<Scene>): Mesh;
  23204. }
  23205. }
  23206. declare module BABYLON {
  23207. /**
  23208. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23209. *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.
  23210. * The SPS is also a particle system. It provides some methods to manage the particles.
  23211. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23212. *
  23213. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23214. */
  23215. export class SolidParticleSystem implements IDisposable {
  23216. /**
  23217. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23218. * Example : var p = SPS.particles[i];
  23219. */
  23220. particles: SolidParticle[];
  23221. /**
  23222. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23223. */
  23224. nbParticles: number;
  23225. /**
  23226. * If the particles must ever face the camera (default false). Useful for planar particles.
  23227. */
  23228. billboard: boolean;
  23229. /**
  23230. * Recompute normals when adding a shape
  23231. */
  23232. recomputeNormals: boolean;
  23233. /**
  23234. * This a counter ofr your own usage. It's not set by any SPS functions.
  23235. */
  23236. counter: number;
  23237. /**
  23238. * The SPS name. This name is also given to the underlying mesh.
  23239. */
  23240. name: string;
  23241. /**
  23242. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23243. */
  23244. mesh: Mesh;
  23245. /**
  23246. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23247. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23248. */
  23249. vars: any;
  23250. /**
  23251. * This array is populated when the SPS is set as 'pickable'.
  23252. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23253. * Each element of this array is an object `{idx: int, faceId: int}`.
  23254. * `idx` is the picked particle index in the `SPS.particles` array
  23255. * `faceId` is the picked face index counted within this particle.
  23256. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23257. */
  23258. pickedParticles: {
  23259. idx: number;
  23260. faceId: number;
  23261. }[];
  23262. /**
  23263. * This array is populated when `enableDepthSort` is set to true.
  23264. * Each element of this array is an instance of the class DepthSortedParticle.
  23265. */
  23266. depthSortedParticles: DepthSortedParticle[];
  23267. /**
  23268. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23269. * @hidden
  23270. */ bSphereOnly: boolean;
  23271. /**
  23272. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23273. * @hidden
  23274. */ bSphereRadiusFactor: number;
  23275. private _scene;
  23276. private _positions;
  23277. private _indices;
  23278. private _normals;
  23279. private _colors;
  23280. private _uvs;
  23281. private _indices32;
  23282. private _positions32;
  23283. private _normals32;
  23284. private _fixedNormal32;
  23285. private _colors32;
  23286. private _uvs32;
  23287. private _index;
  23288. private _updatable;
  23289. private _pickable;
  23290. private _isVisibilityBoxLocked;
  23291. private _alwaysVisible;
  23292. private _depthSort;
  23293. private _shapeCounter;
  23294. private _copy;
  23295. private _color;
  23296. private _computeParticleColor;
  23297. private _computeParticleTexture;
  23298. private _computeParticleRotation;
  23299. private _computeParticleVertex;
  23300. private _computeBoundingBox;
  23301. private _depthSortParticles;
  23302. private _camera;
  23303. private _mustUnrotateFixedNormals;
  23304. private _particlesIntersect;
  23305. private _needs32Bits;
  23306. /**
  23307. * Creates a SPS (Solid Particle System) object.
  23308. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23309. * @param scene (Scene) is the scene in which the SPS is added.
  23310. * @param options defines the options of the sps e.g.
  23311. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23312. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23313. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23314. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23315. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23316. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23317. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23318. */
  23319. constructor(name: string, scene: Scene, options?: {
  23320. updatable?: boolean;
  23321. isPickable?: boolean;
  23322. enableDepthSort?: boolean;
  23323. particleIntersection?: boolean;
  23324. boundingSphereOnly?: boolean;
  23325. bSphereRadiusFactor?: number;
  23326. });
  23327. /**
  23328. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23329. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23330. * @returns the created mesh
  23331. */
  23332. buildMesh(): Mesh;
  23333. /**
  23334. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23335. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23336. * Thus the particles generated from `digest()` have their property `position` set yet.
  23337. * @param mesh ( Mesh ) is the mesh to be digested
  23338. * @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
  23339. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23340. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23341. * @returns the current SPS
  23342. */
  23343. digest(mesh: Mesh, options?: {
  23344. facetNb?: number;
  23345. number?: number;
  23346. delta?: number;
  23347. }): SolidParticleSystem;
  23348. private _unrotateFixedNormals;
  23349. private _resetCopy;
  23350. private _meshBuilder;
  23351. private _posToShape;
  23352. private _uvsToShapeUV;
  23353. private _addParticle;
  23354. /**
  23355. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23356. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23357. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23358. * @param nb (positive integer) the number of particles to be created from this model
  23359. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23360. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23361. * @returns the number of shapes in the system
  23362. */
  23363. addShape(mesh: Mesh, nb: number, options?: {
  23364. positionFunction?: any;
  23365. vertexFunction?: any;
  23366. }): number;
  23367. private _rebuildParticle;
  23368. /**
  23369. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23370. * @returns the SPS.
  23371. */
  23372. rebuildMesh(): SolidParticleSystem;
  23373. /**
  23374. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23375. * This method calls `updateParticle()` for each particle of the SPS.
  23376. * For an animated SPS, it is usually called within the render loop.
  23377. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23378. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23379. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23380. * @returns the SPS.
  23381. */
  23382. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23383. /**
  23384. * Disposes the SPS.
  23385. */
  23386. dispose(): void;
  23387. /**
  23388. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23389. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23390. * @returns the SPS.
  23391. */
  23392. refreshVisibleSize(): SolidParticleSystem;
  23393. /**
  23394. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23395. * @param size the size (float) of the visibility box
  23396. * note : this doesn't lock the SPS mesh bounding box.
  23397. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23398. */
  23399. setVisibilityBox(size: number): void;
  23400. /**
  23401. * Gets whether the SPS as always visible or not
  23402. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23403. */
  23404. /**
  23405. * Sets the SPS as always visible or not
  23406. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23407. */
  23408. isAlwaysVisible: boolean;
  23409. /**
  23410. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23411. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23412. */
  23413. /**
  23414. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23415. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23416. */
  23417. isVisibilityBoxLocked: boolean;
  23418. /**
  23419. * Tells to `setParticles()` to compute the particle rotations or not.
  23420. * Default value : true. The SPS is faster when it's set to false.
  23421. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23422. */
  23423. /**
  23424. * Gets if `setParticles()` computes the particle rotations or not.
  23425. * Default value : true. The SPS is faster when it's set to false.
  23426. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23427. */
  23428. computeParticleRotation: boolean;
  23429. /**
  23430. * Tells to `setParticles()` to compute the particle colors or not.
  23431. * Default value : true. The SPS is faster when it's set to false.
  23432. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23433. */
  23434. /**
  23435. * Gets if `setParticles()` computes the particle colors or not.
  23436. * Default value : true. The SPS is faster when it's set to false.
  23437. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23438. */
  23439. computeParticleColor: boolean;
  23440. /**
  23441. * Gets if `setParticles()` computes the particle textures or not.
  23442. * Default value : true. The SPS is faster when it's set to false.
  23443. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23444. */
  23445. computeParticleTexture: boolean;
  23446. /**
  23447. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23448. * Default value : false. The SPS is faster when it's set to false.
  23449. * Note : the particle custom vertex positions aren't stored values.
  23450. */
  23451. /**
  23452. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23453. * Default value : false. The SPS is faster when it's set to false.
  23454. * Note : the particle custom vertex positions aren't stored values.
  23455. */
  23456. computeParticleVertex: boolean;
  23457. /**
  23458. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23459. */
  23460. /**
  23461. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23462. */
  23463. computeBoundingBox: boolean;
  23464. /**
  23465. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23466. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23467. * Default : `true`
  23468. */
  23469. /**
  23470. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23471. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23472. * Default : `true`
  23473. */
  23474. depthSortParticles: boolean;
  23475. /**
  23476. * This function does nothing. It may be overwritten to set all the particle first values.
  23477. * The SPS doesn't call this function, you may have to call it by your own.
  23478. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23479. */
  23480. initParticles(): void;
  23481. /**
  23482. * This function does nothing. It may be overwritten to recycle a particle.
  23483. * The SPS doesn't call this function, you may have to call it by your own.
  23484. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23485. * @param particle The particle to recycle
  23486. * @returns the recycled particle
  23487. */
  23488. recycleParticle(particle: SolidParticle): SolidParticle;
  23489. /**
  23490. * Updates a particle : this function should be overwritten by the user.
  23491. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23492. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23493. * @example : just set a particle position or velocity and recycle conditions
  23494. * @param particle The particle to update
  23495. * @returns the updated particle
  23496. */
  23497. updateParticle(particle: SolidParticle): SolidParticle;
  23498. /**
  23499. * Updates a vertex of a particle : it can be overwritten by the user.
  23500. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23501. * @param particle the current particle
  23502. * @param vertex the current index of the current particle
  23503. * @param pt the index of the current vertex in the particle shape
  23504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23505. * @example : just set a vertex particle position
  23506. * @returns the updated vertex
  23507. */
  23508. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23509. /**
  23510. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23511. * This does nothing and may be overwritten by the user.
  23512. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23513. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23514. * @param update the boolean update value actually passed to setParticles()
  23515. */
  23516. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23517. /**
  23518. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23519. * This will be passed three parameters.
  23520. * This does nothing and may be overwritten by the user.
  23521. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23522. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23523. * @param update the boolean update value actually passed to setParticles()
  23524. */
  23525. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23526. }
  23527. }
  23528. declare module BABYLON {
  23529. /**
  23530. * Represents one particle of a solid particle system.
  23531. */
  23532. export class SolidParticle {
  23533. /**
  23534. * particle global index
  23535. */
  23536. idx: number;
  23537. /**
  23538. * The color of the particle
  23539. */
  23540. color: Nullable<Color4>;
  23541. /**
  23542. * The world space position of the particle.
  23543. */
  23544. position: Vector3;
  23545. /**
  23546. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23547. */
  23548. rotation: Vector3;
  23549. /**
  23550. * The world space rotation quaternion of the particle.
  23551. */
  23552. rotationQuaternion: Nullable<Quaternion>;
  23553. /**
  23554. * The scaling of the particle.
  23555. */
  23556. scaling: Vector3;
  23557. /**
  23558. * The uvs of the particle.
  23559. */
  23560. uvs: Vector4;
  23561. /**
  23562. * The current speed of the particle.
  23563. */
  23564. velocity: Vector3;
  23565. /**
  23566. * The pivot point in the particle local space.
  23567. */
  23568. pivot: Vector3;
  23569. /**
  23570. * Must the particle be translated from its pivot point in its local space ?
  23571. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23572. * Default : false
  23573. */
  23574. translateFromPivot: boolean;
  23575. /**
  23576. * Is the particle active or not ?
  23577. */
  23578. alive: boolean;
  23579. /**
  23580. * Is the particle visible or not ?
  23581. */
  23582. isVisible: boolean;
  23583. /**
  23584. * Index of this particle in the global "positions" array (Internal use)
  23585. * @hidden
  23586. */ pos: number;
  23587. /**
  23588. * @hidden Index of this particle in the global "indices" array (Internal use)
  23589. */ ind: number;
  23590. /**
  23591. * @hidden ModelShape of this particle (Internal use)
  23592. */ model: ModelShape;
  23593. /**
  23594. * ModelShape id of this particle
  23595. */
  23596. shapeId: number;
  23597. /**
  23598. * Index of the particle in its shape id (Internal use)
  23599. */
  23600. idxInShape: number;
  23601. /**
  23602. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23603. */ modelBoundingInfo: BoundingInfo;
  23604. /**
  23605. * @hidden Particle BoundingInfo object (Internal use)
  23606. */ boundingInfo: BoundingInfo;
  23607. /**
  23608. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23609. */ sps: SolidParticleSystem;
  23610. /**
  23611. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23612. */ stillInvisible: boolean;
  23613. /**
  23614. * @hidden Last computed particle rotation matrix
  23615. */ rotationMatrix: number[];
  23616. /**
  23617. * Parent particle Id, if any.
  23618. * Default null.
  23619. */
  23620. parentId: Nullable<number>;
  23621. /**
  23622. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23623. * The possible values are :
  23624. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23625. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23626. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23627. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23628. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23629. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23630. * */
  23631. cullingStrategy: number;
  23632. /**
  23633. * @hidden Internal global position in the SPS.
  23634. */ globalPosition: Vector3;
  23635. /**
  23636. * Creates a Solid Particle object.
  23637. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23638. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23639. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23640. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23641. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23642. * @param shapeId (integer) is the model shape identifier in the SPS.
  23643. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23644. * @param sps defines the sps it is associated to
  23645. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23646. */
  23647. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23648. /**
  23649. * Legacy support, changed scale to scaling
  23650. */
  23651. /**
  23652. * Legacy support, changed scale to scaling
  23653. */
  23654. scale: Vector3;
  23655. /**
  23656. * Legacy support, changed quaternion to rotationQuaternion
  23657. */
  23658. /**
  23659. * Legacy support, changed quaternion to rotationQuaternion
  23660. */
  23661. quaternion: Nullable<Quaternion>;
  23662. /**
  23663. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23664. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23665. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23666. * @returns true if it intersects
  23667. */
  23668. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23669. /**
  23670. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23671. * A particle is in the frustum if its bounding box intersects the frustum
  23672. * @param frustumPlanes defines the frustum to test
  23673. * @returns true if the particle is in the frustum planes
  23674. */
  23675. isInFrustum(frustumPlanes: Plane[]): boolean;
  23676. /**
  23677. * get the rotation matrix of the particle
  23678. * @hidden
  23679. */
  23680. getRotationMatrix(m: Matrix): void;
  23681. }
  23682. /**
  23683. * Represents the shape of the model used by one particle of a solid particle system.
  23684. * SPS internal tool, don't use it manually.
  23685. */
  23686. export class ModelShape {
  23687. /**
  23688. * The shape id
  23689. * @hidden
  23690. */
  23691. shapeID: number;
  23692. /**
  23693. * flat array of model positions (internal use)
  23694. * @hidden
  23695. */ shape: Vector3[];
  23696. /**
  23697. * flat array of model UVs (internal use)
  23698. * @hidden
  23699. */ shapeUV: number[];
  23700. /**
  23701. * length of the shape in the model indices array (internal use)
  23702. * @hidden
  23703. */ indicesLength: number;
  23704. /**
  23705. * Custom position function (internal use)
  23706. * @hidden
  23707. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23708. /**
  23709. * Custom vertex function (internal use)
  23710. * @hidden
  23711. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23712. /**
  23713. * 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.
  23714. * SPS internal tool, don't use it manually.
  23715. * @hidden
  23716. */
  23717. 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>);
  23718. }
  23719. /**
  23720. * Represents a Depth Sorted Particle in the solid particle system.
  23721. */
  23722. export class DepthSortedParticle {
  23723. /**
  23724. * Index of the particle in the "indices" array
  23725. */
  23726. ind: number;
  23727. /**
  23728. * Length of the particle shape in the "indices" array
  23729. */
  23730. indicesLength: number;
  23731. /**
  23732. * Squared distance from the particle to the camera
  23733. */
  23734. sqDistance: number;
  23735. }
  23736. }
  23737. declare module BABYLON {
  23738. /**
  23739. * Class used to store all common mesh properties
  23740. */
  23741. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23742. /** No occlusion */
  23743. static OCCLUSION_TYPE_NONE: number;
  23744. /** Occlusion set to optimisitic */
  23745. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23746. /** Occlusion set to strict */
  23747. static OCCLUSION_TYPE_STRICT: number;
  23748. /** Use an accurante occlusion algorithm */
  23749. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23750. /** Use a conservative occlusion algorithm */
  23751. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23752. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23753. * Test order :
  23754. * Is the bounding sphere outside the frustum ?
  23755. * If not, are the bounding box vertices outside the frustum ?
  23756. * It not, then the cullable object is in the frustum.
  23757. */
  23758. static readonly CULLINGSTRATEGY_STANDARD: number;
  23759. /** Culling strategy : Bounding Sphere Only.
  23760. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23761. * It's also less accurate than the standard because some not visible objects can still be selected.
  23762. * Test : is the bounding sphere outside the frustum ?
  23763. * If not, then the cullable object is in the frustum.
  23764. */
  23765. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23766. /** Culling strategy : Optimistic Inclusion.
  23767. * This in an inclusion test first, then the standard exclusion test.
  23768. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23769. * 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.
  23770. * Anyway, it's as accurate as the standard strategy.
  23771. * Test :
  23772. * Is the cullable object bounding sphere center in the frustum ?
  23773. * If not, apply the default culling strategy.
  23774. */
  23775. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23776. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23777. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23778. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23779. * 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.
  23780. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23781. * Test :
  23782. * Is the cullable object bounding sphere center in the frustum ?
  23783. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23784. */
  23785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23786. /**
  23787. * No billboard
  23788. */
  23789. static readonly BILLBOARDMODE_NONE: number;
  23790. /** Billboard on X axis */
  23791. static readonly BILLBOARDMODE_X: number;
  23792. /** Billboard on Y axis */
  23793. static readonly BILLBOARDMODE_Y: number;
  23794. /** Billboard on Z axis */
  23795. static readonly BILLBOARDMODE_Z: number;
  23796. /** Billboard on all axes */
  23797. static readonly BILLBOARDMODE_ALL: number;
  23798. private _facetData;
  23799. /**
  23800. * The culling strategy to use to check whether the mesh must be rendered or not.
  23801. * This value can be changed at any time and will be used on the next render mesh selection.
  23802. * The possible values are :
  23803. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23804. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23805. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23806. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23807. * Please read each static variable documentation to get details about the culling process.
  23808. * */
  23809. cullingStrategy: number;
  23810. /**
  23811. * Gets the number of facets in the mesh
  23812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23813. */
  23814. readonly facetNb: number;
  23815. /**
  23816. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23818. */
  23819. partitioningSubdivisions: number;
  23820. /**
  23821. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23822. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23824. */
  23825. partitioningBBoxRatio: number;
  23826. /**
  23827. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23828. * Works only for updatable meshes.
  23829. * Doesn't work with multi-materials
  23830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23831. */
  23832. mustDepthSortFacets: boolean;
  23833. /**
  23834. * The location (Vector3) where the facet depth sort must be computed from.
  23835. * By default, the active camera position.
  23836. * Used only when facet depth sort is enabled
  23837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23838. */
  23839. facetDepthSortFrom: Vector3;
  23840. /**
  23841. * gets a boolean indicating if facetData is enabled
  23842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23843. */
  23844. readonly isFacetDataEnabled: boolean;
  23845. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23846. /**
  23847. * An event triggered when this mesh collides with another one
  23848. */
  23849. onCollideObservable: Observable<AbstractMesh>;
  23850. private _onCollideObserver;
  23851. /** Set a function to call when this mesh collides with another one */
  23852. onCollide: () => void;
  23853. /**
  23854. * An event triggered when the collision's position changes
  23855. */
  23856. onCollisionPositionChangeObservable: Observable<Vector3>;
  23857. private _onCollisionPositionChangeObserver;
  23858. /** Set a function to call when the collision's position changes */
  23859. onCollisionPositionChange: () => void;
  23860. /**
  23861. * An event triggered when material is changed
  23862. */
  23863. onMaterialChangedObservable: Observable<AbstractMesh>;
  23864. /**
  23865. * Gets or sets the orientation for POV movement & rotation
  23866. */
  23867. definedFacingForward: boolean;
  23868. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23869. private _visibility;
  23870. /** @hidden */ isActive: boolean;
  23871. /** @hidden */ onlyForInstances: boolean;
  23872. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23873. /**
  23874. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23875. */
  23876. /**
  23877. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23878. */
  23879. visibility: number;
  23880. /** Gets or sets the alpha index used to sort transparent meshes
  23881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23882. */
  23883. alphaIndex: number;
  23884. /**
  23885. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23886. */
  23887. isVisible: boolean;
  23888. /**
  23889. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23890. */
  23891. isPickable: boolean;
  23892. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23893. showSubMeshesBoundingBox: boolean;
  23894. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23895. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23896. */
  23897. isBlocker: boolean;
  23898. /**
  23899. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23900. */
  23901. enablePointerMoveEvents: boolean;
  23902. /**
  23903. * Specifies the rendering group id for this mesh (0 by default)
  23904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23905. */
  23906. renderingGroupId: number;
  23907. private _material;
  23908. /** Gets or sets current material */
  23909. material: Nullable<Material>;
  23910. private _receiveShadows;
  23911. /**
  23912. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23913. * @see http://doc.babylonjs.com/babylon101/shadows
  23914. */
  23915. receiveShadows: boolean;
  23916. /** Defines color to use when rendering outline */
  23917. outlineColor: Color3;
  23918. /** Define width to use when rendering outline */
  23919. outlineWidth: number;
  23920. /** Defines color to use when rendering overlay */
  23921. overlayColor: Color3;
  23922. /** Defines alpha to use when rendering overlay */
  23923. overlayAlpha: number;
  23924. private _hasVertexAlpha;
  23925. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23926. hasVertexAlpha: boolean;
  23927. private _useVertexColors;
  23928. /** 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) */
  23929. useVertexColors: boolean;
  23930. private _computeBonesUsingShaders;
  23931. /**
  23932. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23933. */
  23934. computeBonesUsingShaders: boolean;
  23935. private _numBoneInfluencers;
  23936. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23937. numBoneInfluencers: number;
  23938. private _applyFog;
  23939. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23940. applyFog: boolean;
  23941. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23942. useOctreeForRenderingSelection: boolean;
  23943. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23944. useOctreeForPicking: boolean;
  23945. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23946. useOctreeForCollisions: boolean;
  23947. private _layerMask;
  23948. /**
  23949. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23950. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23951. */
  23952. layerMask: number;
  23953. /**
  23954. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23955. */
  23956. alwaysSelectAsActiveMesh: boolean;
  23957. /**
  23958. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  23959. */
  23960. doNotSyncBoundingInfo: boolean;
  23961. /**
  23962. * Gets or sets the current action manager
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23964. */
  23965. actionManager: Nullable<AbstractActionManager>;
  23966. private _checkCollisions;
  23967. private _collisionMask;
  23968. private _collisionGroup;
  23969. /**
  23970. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23972. */
  23973. ellipsoid: Vector3;
  23974. /**
  23975. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23976. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23977. */
  23978. ellipsoidOffset: Vector3;
  23979. private _collider;
  23980. private _oldPositionForCollisions;
  23981. private _diffPositionForCollisions;
  23982. /**
  23983. * Gets or sets a collision mask used to mask collisions (default is -1).
  23984. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23985. */
  23986. collisionMask: number;
  23987. /**
  23988. * Gets or sets the current collision group mask (-1 by default).
  23989. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23990. */
  23991. collisionGroup: number;
  23992. /**
  23993. * Defines edge width used when edgesRenderer is enabled
  23994. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23995. */
  23996. edgesWidth: number;
  23997. /**
  23998. * Defines edge color used when edgesRenderer is enabled
  23999. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24000. */
  24001. edgesColor: Color4;
  24002. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24003. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24004. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24005. /** @hidden */ renderId: number;
  24006. /**
  24007. * Gets or sets the list of subMeshes
  24008. * @see http://doc.babylonjs.com/how_to/multi_materials
  24009. */
  24010. subMeshes: SubMesh[];
  24011. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24012. /** @hidden */ unIndexed: boolean;
  24013. /** @hidden */ lightSources: Light[];
  24014. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24015. /** @hidden */ waitingActions: Nullable<any>;
  24016. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  24017. private _skeleton;
  24018. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24019. /**
  24020. * Gets or sets a skeleton to apply skining transformations
  24021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24022. */
  24023. skeleton: Nullable<Skeleton>;
  24024. /**
  24025. * An event triggered when the mesh is rebuilt.
  24026. */
  24027. onRebuildObservable: Observable<AbstractMesh>;
  24028. /**
  24029. * Creates a new AbstractMesh
  24030. * @param name defines the name of the mesh
  24031. * @param scene defines the hosting scene
  24032. */
  24033. constructor(name: string, scene?: Nullable<Scene>);
  24034. /**
  24035. * Returns the string "AbstractMesh"
  24036. * @returns "AbstractMesh"
  24037. */
  24038. getClassName(): string;
  24039. /**
  24040. * Gets a string representation of the current mesh
  24041. * @param fullDetails defines a boolean indicating if full details must be included
  24042. * @returns a string representation of the current mesh
  24043. */
  24044. toString(fullDetails?: boolean): string;
  24045. /**
  24046. * @hidden
  24047. */
  24048. protected _getEffectiveParent(): Nullable<Node>;
  24049. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24050. /** @hidden */ rebuild(): void;
  24051. /** @hidden */ resyncLightSources(): void;
  24052. /** @hidden */ resyncLighSource(light: Light): void;
  24053. /** @hidden */ unBindEffect(): void;
  24054. /** @hidden */ removeLightSource(light: Light): void;
  24055. private _markSubMeshesAsDirty;
  24056. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24057. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24058. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24059. /**
  24060. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24061. */
  24062. scaling: Vector3;
  24063. /**
  24064. * Returns true if the mesh is blocked. Implemented by child classes
  24065. */
  24066. readonly isBlocked: boolean;
  24067. /**
  24068. * Returns the mesh itself by default. Implemented by child classes
  24069. * @param camera defines the camera to use to pick the right LOD level
  24070. * @returns the currentAbstractMesh
  24071. */
  24072. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24073. /**
  24074. * Returns 0 by default. Implemented by child classes
  24075. * @returns an integer
  24076. */
  24077. getTotalVertices(): number;
  24078. /**
  24079. * Returns a positive integer : the total number of indices in this mesh geometry.
  24080. * @returns the numner of indices or zero if the mesh has no geometry.
  24081. */
  24082. getTotalIndices(): number;
  24083. /**
  24084. * Returns null by default. Implemented by child classes
  24085. * @returns null
  24086. */
  24087. getIndices(): Nullable<IndicesArray>;
  24088. /**
  24089. * Returns the array of the requested vertex data kind. Implemented by child classes
  24090. * @param kind defines the vertex data kind to use
  24091. * @returns null
  24092. */
  24093. getVerticesData(kind: string): Nullable<FloatArray>;
  24094. /**
  24095. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24096. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24097. * Note that a new underlying VertexBuffer object is created each call.
  24098. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24099. * @param kind defines vertex data kind:
  24100. * * VertexBuffer.PositionKind
  24101. * * VertexBuffer.UVKind
  24102. * * VertexBuffer.UV2Kind
  24103. * * VertexBuffer.UV3Kind
  24104. * * VertexBuffer.UV4Kind
  24105. * * VertexBuffer.UV5Kind
  24106. * * VertexBuffer.UV6Kind
  24107. * * VertexBuffer.ColorKind
  24108. * * VertexBuffer.MatricesIndicesKind
  24109. * * VertexBuffer.MatricesIndicesExtraKind
  24110. * * VertexBuffer.MatricesWeightsKind
  24111. * * VertexBuffer.MatricesWeightsExtraKind
  24112. * @param data defines the data source
  24113. * @param updatable defines if the data must be flagged as updatable (or static)
  24114. * @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
  24115. * @returns the current mesh
  24116. */
  24117. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24118. /**
  24119. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24120. * If the mesh has no geometry, it is simply returned as it is.
  24121. * @param kind defines vertex data kind:
  24122. * * VertexBuffer.PositionKind
  24123. * * VertexBuffer.UVKind
  24124. * * VertexBuffer.UV2Kind
  24125. * * VertexBuffer.UV3Kind
  24126. * * VertexBuffer.UV4Kind
  24127. * * VertexBuffer.UV5Kind
  24128. * * VertexBuffer.UV6Kind
  24129. * * VertexBuffer.ColorKind
  24130. * * VertexBuffer.MatricesIndicesKind
  24131. * * VertexBuffer.MatricesIndicesExtraKind
  24132. * * VertexBuffer.MatricesWeightsKind
  24133. * * VertexBuffer.MatricesWeightsExtraKind
  24134. * @param data defines the data source
  24135. * @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
  24136. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24137. * @returns the current mesh
  24138. */
  24139. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24140. /**
  24141. * Sets the mesh indices,
  24142. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24143. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24144. * @param totalVertices Defines the total number of vertices
  24145. * @returns the current mesh
  24146. */
  24147. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24148. /**
  24149. * Gets a boolean indicating if specific vertex data is present
  24150. * @param kind defines the vertex data kind to use
  24151. * @returns true is data kind is present
  24152. */
  24153. isVerticesDataPresent(kind: string): boolean;
  24154. /**
  24155. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24156. * @returns a BoundingInfo
  24157. */
  24158. getBoundingInfo(): BoundingInfo;
  24159. /**
  24160. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24161. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24162. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24163. * @returns the current mesh
  24164. */
  24165. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24166. /**
  24167. * Overwrite the current bounding info
  24168. * @param boundingInfo defines the new bounding info
  24169. * @returns the current mesh
  24170. */
  24171. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24172. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24173. readonly useBones: boolean;
  24174. /** @hidden */ preActivate(): void;
  24175. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24176. /** @hidden */ activate(renderId: number): boolean;
  24177. /** @hidden */ freeze(): void;
  24178. /** @hidden */ unFreeze(): void;
  24179. /**
  24180. * Gets the current world matrix
  24181. * @returns a Matrix
  24182. */
  24183. getWorldMatrix(): Matrix;
  24184. /** @hidden */ getWorldMatrixDeterminant(): number;
  24185. /**
  24186. * Perform relative position change from the point of view of behind the front of the mesh.
  24187. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24188. * Supports definition of mesh facing forward or backward
  24189. * @param amountRight defines the distance on the right axis
  24190. * @param amountUp defines the distance on the up axis
  24191. * @param amountForward defines the distance on the forward axis
  24192. * @returns the current mesh
  24193. */
  24194. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24195. /**
  24196. * Calculate relative position change from the point of view of behind the front of the mesh.
  24197. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24198. * Supports definition of mesh facing forward or backward
  24199. * @param amountRight defines the distance on the right axis
  24200. * @param amountUp defines the distance on the up axis
  24201. * @param amountForward defines the distance on the forward axis
  24202. * @returns the new displacement vector
  24203. */
  24204. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24205. /**
  24206. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24207. * Supports definition of mesh facing forward or backward
  24208. * @param flipBack defines the flip
  24209. * @param twirlClockwise defines the twirl
  24210. * @param tiltRight defines the tilt
  24211. * @returns the current mesh
  24212. */
  24213. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24214. /**
  24215. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24216. * Supports definition of mesh facing forward or backward.
  24217. * @param flipBack defines the flip
  24218. * @param twirlClockwise defines the twirl
  24219. * @param tiltRight defines the tilt
  24220. * @returns the new rotation vector
  24221. */
  24222. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24223. /**
  24224. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24225. * This means the mesh underlying bounding box and sphere are recomputed.
  24226. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24227. * @returns the current mesh
  24228. */
  24229. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24230. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24231. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24232. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24233. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24234. /** @hidden */
  24235. protected _afterComputeWorldMatrix(): void;
  24236. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24237. /**
  24238. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24239. * A mesh is in the frustum if its bounding box intersects the frustum
  24240. * @param frustumPlanes defines the frustum to test
  24241. * @returns true if the mesh is in the frustum planes
  24242. */
  24243. isInFrustum(frustumPlanes: Plane[]): boolean;
  24244. /**
  24245. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24246. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24247. * @param frustumPlanes defines the frustum to test
  24248. * @returns true if the mesh is completely in the frustum planes
  24249. */
  24250. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24251. /**
  24252. * True if the mesh intersects another mesh or a SolidParticle object
  24253. * @param mesh defines a target mesh or SolidParticle to test
  24254. * @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)
  24255. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24256. * @returns true if there is an intersection
  24257. */
  24258. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24259. /**
  24260. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24261. * @param point defines the point to test
  24262. * @returns true if there is an intersection
  24263. */
  24264. intersectsPoint(point: Vector3): boolean;
  24265. /**
  24266. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24267. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24268. */
  24269. checkCollisions: boolean;
  24270. /**
  24271. * Gets Collider object used to compute collisions (not physics)
  24272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24273. */
  24274. readonly collider: Nullable<Collider>;
  24275. /**
  24276. * Move the mesh using collision engine
  24277. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24278. * @param displacement defines the requested displacement vector
  24279. * @returns the current mesh
  24280. */
  24281. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24282. private _onCollisionPositionChange;
  24283. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24284. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24285. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24286. /** @hidden */ generatePointsArray(): boolean;
  24287. /**
  24288. * Checks if the passed Ray intersects with the mesh
  24289. * @param ray defines the ray to use
  24290. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24291. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24292. * @returns the picking info
  24293. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24294. */
  24295. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24296. /**
  24297. * Clones the current mesh
  24298. * @param name defines the mesh name
  24299. * @param newParent defines the new mesh parent
  24300. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24301. * @returns the new mesh
  24302. */
  24303. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24304. /**
  24305. * Disposes all the submeshes of the current meshnp
  24306. * @returns the current mesh
  24307. */
  24308. releaseSubMeshes(): AbstractMesh;
  24309. /**
  24310. * Releases resources associated with this abstract mesh.
  24311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24313. */
  24314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24315. /**
  24316. * Adds the passed mesh as a child to the current mesh
  24317. * @param mesh defines the child mesh
  24318. * @returns the current mesh
  24319. */
  24320. addChild(mesh: AbstractMesh): AbstractMesh;
  24321. /**
  24322. * Removes the passed mesh from the current mesh children list
  24323. * @param mesh defines the child mesh
  24324. * @returns the current mesh
  24325. */
  24326. removeChild(mesh: AbstractMesh): AbstractMesh;
  24327. /** @hidden */
  24328. private _initFacetData;
  24329. /**
  24330. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24331. * This method can be called within the render loop.
  24332. * 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
  24333. * @returns the current mesh
  24334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24335. */
  24336. updateFacetData(): AbstractMesh;
  24337. /**
  24338. * Returns the facetLocalNormals array.
  24339. * The normals are expressed in the mesh local spac
  24340. * @returns an array of Vector3
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24342. */
  24343. getFacetLocalNormals(): Vector3[];
  24344. /**
  24345. * Returns the facetLocalPositions array.
  24346. * The facet positions are expressed in the mesh local space
  24347. * @returns an array of Vector3
  24348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24349. */
  24350. getFacetLocalPositions(): Vector3[];
  24351. /**
  24352. * Returns the facetLocalPartioning array
  24353. * @returns an array of array of numbers
  24354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24355. */
  24356. getFacetLocalPartitioning(): number[][];
  24357. /**
  24358. * Returns the i-th facet position in the world system.
  24359. * This method allocates a new Vector3 per call
  24360. * @param i defines the facet index
  24361. * @returns a new Vector3
  24362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24363. */
  24364. getFacetPosition(i: number): Vector3;
  24365. /**
  24366. * Sets the reference Vector3 with the i-th facet position in the world system
  24367. * @param i defines the facet index
  24368. * @param ref defines the target vector
  24369. * @returns the current mesh
  24370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24371. */
  24372. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24373. /**
  24374. * Returns the i-th facet normal in the world system.
  24375. * This method allocates a new Vector3 per call
  24376. * @param i defines the facet index
  24377. * @returns a new Vector3
  24378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24379. */
  24380. getFacetNormal(i: number): Vector3;
  24381. /**
  24382. * Sets the reference Vector3 with the i-th facet normal in the world system
  24383. * @param i defines the facet index
  24384. * @param ref defines the target vector
  24385. * @returns the current mesh
  24386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24387. */
  24388. getFacetNormalToRef(i: number, ref: Vector3): this;
  24389. /**
  24390. * 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)
  24391. * @param x defines x coordinate
  24392. * @param y defines y coordinate
  24393. * @param z defines z coordinate
  24394. * @returns the array of facet indexes
  24395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24396. */
  24397. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24398. /**
  24399. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24400. * @param projected sets as the (x,y,z) world projection on the facet
  24401. * @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
  24402. * @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
  24403. * @param x defines x coordinate
  24404. * @param y defines y coordinate
  24405. * @param z defines z coordinate
  24406. * @returns the face index if found (or null instead)
  24407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24408. */
  24409. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24410. /**
  24411. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24412. * @param projected sets as the (x,y,z) local projection on the facet
  24413. * @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
  24414. * @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
  24415. * @param x defines x coordinate
  24416. * @param y defines y coordinate
  24417. * @param z defines z coordinate
  24418. * @returns the face index if found (or null instead)
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24420. */
  24421. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24422. /**
  24423. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24424. * @returns the parameters
  24425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24426. */
  24427. getFacetDataParameters(): any;
  24428. /**
  24429. * Disables the feature FacetData and frees the related memory
  24430. * @returns the current mesh
  24431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24432. */
  24433. disableFacetData(): AbstractMesh;
  24434. /**
  24435. * Updates the AbstractMesh indices array
  24436. * @param indices defines the data source
  24437. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24438. * @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)
  24439. * @returns the current mesh
  24440. */
  24441. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24442. /**
  24443. * Creates new normals data for the mesh
  24444. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24445. * @returns the current mesh
  24446. */
  24447. createNormals(updatable: boolean): AbstractMesh;
  24448. /**
  24449. * Align the mesh with a normal
  24450. * @param normal defines the normal to use
  24451. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24452. * @returns the current mesh
  24453. */
  24454. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24455. /** @hidden */ checkOcclusionQuery(): boolean;
  24456. }
  24457. }
  24458. declare module BABYLON {
  24459. /**
  24460. * Interface used to define ActionEvent
  24461. */
  24462. export interface IActionEvent {
  24463. /** The mesh or sprite that triggered the action */
  24464. source: any;
  24465. /** The X mouse cursor position at the time of the event */
  24466. pointerX: number;
  24467. /** The Y mouse cursor position at the time of the event */
  24468. pointerY: number;
  24469. /** The mesh that is currently pointed at (can be null) */
  24470. meshUnderPointer: Nullable<AbstractMesh>;
  24471. /** the original (browser) event that triggered the ActionEvent */
  24472. sourceEvent?: any;
  24473. /** additional data for the event */
  24474. additionalData?: any;
  24475. }
  24476. /**
  24477. * ActionEvent is the event being sent when an action is triggered.
  24478. */
  24479. export class ActionEvent implements IActionEvent {
  24480. /** The mesh or sprite that triggered the action */
  24481. source: any;
  24482. /** The X mouse cursor position at the time of the event */
  24483. pointerX: number;
  24484. /** The Y mouse cursor position at the time of the event */
  24485. pointerY: number;
  24486. /** The mesh that is currently pointed at (can be null) */
  24487. meshUnderPointer: Nullable<AbstractMesh>;
  24488. /** the original (browser) event that triggered the ActionEvent */
  24489. sourceEvent?: any;
  24490. /** additional data for the event */
  24491. additionalData?: any;
  24492. /**
  24493. * Creates a new ActionEvent
  24494. * @param source The mesh or sprite that triggered the action
  24495. * @param pointerX The X mouse cursor position at the time of the event
  24496. * @param pointerY The Y mouse cursor position at the time of the event
  24497. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24498. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24499. * @param additionalData additional data for the event
  24500. */
  24501. constructor(
  24502. /** The mesh or sprite that triggered the action */
  24503. source: any,
  24504. /** The X mouse cursor position at the time of the event */
  24505. pointerX: number,
  24506. /** The Y mouse cursor position at the time of the event */
  24507. pointerY: number,
  24508. /** The mesh that is currently pointed at (can be null) */
  24509. meshUnderPointer: Nullable<AbstractMesh>,
  24510. /** the original (browser) event that triggered the ActionEvent */
  24511. sourceEvent?: any,
  24512. /** additional data for the event */
  24513. additionalData?: any);
  24514. /**
  24515. * Helper function to auto-create an ActionEvent from a source mesh.
  24516. * @param source The source mesh that triggered the event
  24517. * @param evt The original (browser) event
  24518. * @param additionalData additional data for the event
  24519. * @returns the new ActionEvent
  24520. */
  24521. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24522. /**
  24523. * Helper function to auto-create an ActionEvent from a source sprite
  24524. * @param source The source sprite that triggered the event
  24525. * @param scene Scene associated with the sprite
  24526. * @param evt The original (browser) event
  24527. * @param additionalData additional data for the event
  24528. * @returns the new ActionEvent
  24529. */
  24530. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24531. /**
  24532. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24533. * @param scene the scene where the event occurred
  24534. * @param evt The original (browser) event
  24535. * @returns the new ActionEvent
  24536. */
  24537. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24538. /**
  24539. * Helper function to auto-create an ActionEvent from a primitive
  24540. * @param prim defines the target primitive
  24541. * @param pointerPos defines the pointer position
  24542. * @param evt The original (browser) event
  24543. * @param additionalData additional data for the event
  24544. * @returns the new ActionEvent
  24545. */
  24546. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24547. }
  24548. }
  24549. declare module BABYLON {
  24550. /**
  24551. * Abstract class used to decouple action Manager from scene and meshes.
  24552. * Do not instantiate.
  24553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24554. */
  24555. export abstract class AbstractActionManager implements IDisposable {
  24556. /** Gets the list of active triggers */
  24557. static Triggers: {
  24558. [key: string]: number;
  24559. };
  24560. /** Gets the cursor to use when hovering items */
  24561. hoverCursor: string;
  24562. /** Gets the list of actions */
  24563. actions: IAction[];
  24564. /**
  24565. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24566. */
  24567. isRecursive: boolean;
  24568. /**
  24569. * Releases all associated resources
  24570. */
  24571. abstract dispose(): void;
  24572. /**
  24573. * Does this action manager has pointer triggers
  24574. */
  24575. abstract readonly hasPointerTriggers: boolean;
  24576. /**
  24577. * Does this action manager has pick triggers
  24578. */
  24579. abstract readonly hasPickTriggers: boolean;
  24580. /**
  24581. * Process a specific trigger
  24582. * @param trigger defines the trigger to process
  24583. * @param evt defines the event details to be processed
  24584. */
  24585. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24586. /**
  24587. * Does this action manager handles actions of any of the given triggers
  24588. * @param triggers defines the triggers to be tested
  24589. * @return a boolean indicating whether one (or more) of the triggers is handled
  24590. */
  24591. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24592. /**
  24593. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24594. * speed.
  24595. * @param triggerA defines the trigger to be tested
  24596. * @param triggerB defines the trigger to be tested
  24597. * @return a boolean indicating whether one (or more) of the triggers is handled
  24598. */
  24599. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24600. /**
  24601. * Does this action manager handles actions of a given trigger
  24602. * @param trigger defines the trigger to be tested
  24603. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24604. * @return whether the trigger is handled
  24605. */
  24606. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24607. /**
  24608. * Serialize this manager to a JSON object
  24609. * @param name defines the property name to store this manager
  24610. * @returns a JSON representation of this manager
  24611. */
  24612. abstract serialize(name: string): any;
  24613. /**
  24614. * Registers an action to this action manager
  24615. * @param action defines the action to be registered
  24616. * @return the action amended (prepared) after registration
  24617. */
  24618. abstract registerAction(action: IAction): Nullable<IAction>;
  24619. /**
  24620. * Unregisters an action to this action manager
  24621. * @param action defines the action to be unregistered
  24622. * @return a boolean indicating whether the action has been unregistered
  24623. */
  24624. abstract unregisterAction(action: IAction): Boolean;
  24625. /**
  24626. * Does exist one action manager with at least one trigger
  24627. **/
  24628. static readonly HasTriggers: boolean;
  24629. /**
  24630. * Does exist one action manager with at least one pick trigger
  24631. **/
  24632. static readonly HasPickTriggers: boolean;
  24633. /**
  24634. * Does exist one action manager that handles actions of a given trigger
  24635. * @param trigger defines the trigger to be tested
  24636. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24637. **/
  24638. static HasSpecificTrigger(trigger: number): boolean;
  24639. }
  24640. }
  24641. declare module BABYLON {
  24642. /**
  24643. * Defines how a node can be built from a string name.
  24644. */
  24645. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24646. /**
  24647. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24648. */
  24649. export class Node implements IBehaviorAware<Node> {
  24650. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24651. private static _NodeConstructors;
  24652. /**
  24653. * Add a new node constructor
  24654. * @param type defines the type name of the node to construct
  24655. * @param constructorFunc defines the constructor function
  24656. */
  24657. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24658. /**
  24659. * Returns a node constructor based on type name
  24660. * @param type defines the type name
  24661. * @param name defines the new node name
  24662. * @param scene defines the hosting scene
  24663. * @param options defines optional options to transmit to constructors
  24664. * @returns the new constructor or null
  24665. */
  24666. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24667. /**
  24668. * Gets or sets the name of the node
  24669. */
  24670. name: string;
  24671. /**
  24672. * Gets or sets the id of the node
  24673. */
  24674. id: string;
  24675. /**
  24676. * Gets or sets the unique id of the node
  24677. */
  24678. uniqueId: number;
  24679. /**
  24680. * Gets or sets a string used to store user defined state for the node
  24681. */
  24682. state: string;
  24683. /**
  24684. * Gets or sets an object used to store user defined information for the node
  24685. */
  24686. metadata: any;
  24687. /**
  24688. * For internal use only. Please do not use.
  24689. */
  24690. reservedDataStore: any;
  24691. /**
  24692. * List of inspectable custom properties (used by the Inspector)
  24693. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24694. */
  24695. inspectableCustomProperties: IInspectable[];
  24696. /**
  24697. * Gets or sets a boolean used to define if the node must be serialized
  24698. */
  24699. doNotSerialize: boolean;
  24700. /** @hidden */ isDisposed: boolean;
  24701. /**
  24702. * Gets a list of Animations associated with the node
  24703. */
  24704. animations: Animation[];
  24705. protected _ranges: {
  24706. [name: string]: Nullable<AnimationRange>;
  24707. };
  24708. /**
  24709. * Callback raised when the node is ready to be used
  24710. */
  24711. onReady: Nullable<(node: Node) => void>;
  24712. private _isEnabled;
  24713. private _isParentEnabled;
  24714. private _isReady;
  24715. /** @hidden */ currentRenderId: number;
  24716. private _parentUpdateId;
  24717. /** @hidden */ childUpdateId: number;
  24718. /** @hidden */ waitingParentId: Nullable<string>;
  24719. /** @hidden */ scene: Scene;
  24720. /** @hidden */ cache: any;
  24721. private _parentNode;
  24722. private _children;
  24723. /** @hidden */ worldMatrix: Matrix;
  24724. /** @hidden */ worldMatrixDeterminant: number;
  24725. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24726. /** @hidden */
  24727. private _sceneRootNodesIndex;
  24728. /**
  24729. * Gets a boolean indicating if the node has been disposed
  24730. * @returns true if the node was disposed
  24731. */
  24732. isDisposed(): boolean;
  24733. /**
  24734. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24735. * @see https://doc.babylonjs.com/how_to/parenting
  24736. */
  24737. parent: Nullable<Node>;
  24738. private addToSceneRootNodes;
  24739. private removeFromSceneRootNodes;
  24740. private _animationPropertiesOverride;
  24741. /**
  24742. * Gets or sets the animation properties override
  24743. */
  24744. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24745. /**
  24746. * Gets a string idenfifying the name of the class
  24747. * @returns "Node" string
  24748. */
  24749. getClassName(): string;
  24750. /** @hidden */ protected readonly _isNode: boolean;
  24751. /**
  24752. * An event triggered when the mesh is disposed
  24753. */
  24754. onDisposeObservable: Observable<Node>;
  24755. private _onDisposeObserver;
  24756. /**
  24757. * Sets a callback that will be raised when the node will be disposed
  24758. */
  24759. onDispose: () => void;
  24760. /**
  24761. * Creates a new Node
  24762. * @param name the name and id to be given to this node
  24763. * @param scene the scene this node will be added to
  24764. * @param addToRootNodes the node will be added to scene.rootNodes
  24765. */
  24766. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24767. /**
  24768. * Gets the scene of the node
  24769. * @returns a scene
  24770. */
  24771. getScene(): Scene;
  24772. /**
  24773. * Gets the engine of the node
  24774. * @returns a Engine
  24775. */
  24776. getEngine(): Engine;
  24777. private _behaviors;
  24778. /**
  24779. * Attach a behavior to the node
  24780. * @see http://doc.babylonjs.com/features/behaviour
  24781. * @param behavior defines the behavior to attach
  24782. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24783. * @returns the current Node
  24784. */
  24785. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24786. /**
  24787. * Remove an attached behavior
  24788. * @see http://doc.babylonjs.com/features/behaviour
  24789. * @param behavior defines the behavior to attach
  24790. * @returns the current Node
  24791. */
  24792. removeBehavior(behavior: Behavior<Node>): Node;
  24793. /**
  24794. * Gets the list of attached behaviors
  24795. * @see http://doc.babylonjs.com/features/behaviour
  24796. */
  24797. readonly behaviors: Behavior<Node>[];
  24798. /**
  24799. * Gets an attached behavior by name
  24800. * @param name defines the name of the behavior to look for
  24801. * @see http://doc.babylonjs.com/features/behaviour
  24802. * @returns null if behavior was not found else the requested behavior
  24803. */
  24804. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24805. /**
  24806. * Returns the latest update of the World matrix
  24807. * @returns a Matrix
  24808. */
  24809. getWorldMatrix(): Matrix;
  24810. /** @hidden */ getWorldMatrixDeterminant(): number;
  24811. /**
  24812. * Returns directly the latest state of the mesh World matrix.
  24813. * A Matrix is returned.
  24814. */
  24815. readonly worldMatrixFromCache: Matrix;
  24816. /** @hidden */ initCache(): void;
  24817. /** @hidden */
  24818. updateCache(force?: boolean): void;
  24819. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24820. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24821. /** @hidden */ isSynchronized(): boolean;
  24822. /** @hidden */ markSyncedWithParent(): void;
  24823. /** @hidden */
  24824. isSynchronizedWithParent(): boolean;
  24825. /** @hidden */
  24826. isSynchronized(): boolean;
  24827. /**
  24828. * Is this node ready to be used/rendered
  24829. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24830. * @return true if the node is ready
  24831. */
  24832. isReady(completeCheck?: boolean): boolean;
  24833. /**
  24834. * Is this node enabled?
  24835. * 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
  24836. * @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
  24837. * @return whether this node (and its parent) is enabled
  24838. */
  24839. isEnabled(checkAncestors?: boolean): boolean;
  24840. /** @hidden */
  24841. protected _syncParentEnabledState(): void;
  24842. /**
  24843. * Set the enabled state of this node
  24844. * @param value defines the new enabled state
  24845. */
  24846. setEnabled(value: boolean): void;
  24847. /**
  24848. * Is this node a descendant of the given node?
  24849. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24850. * @param ancestor defines the parent node to inspect
  24851. * @returns a boolean indicating if this node is a descendant of the given node
  24852. */
  24853. isDescendantOf(ancestor: Node): boolean;
  24854. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24855. /**
  24856. * Will return all nodes that have this node as ascendant
  24857. * @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
  24858. * @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
  24859. * @return all children nodes of all types
  24860. */
  24861. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24862. /**
  24863. * Get all child-meshes of this node
  24864. * @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)
  24865. * @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
  24866. * @returns an array of AbstractMesh
  24867. */
  24868. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24869. /**
  24870. * Get all direct children of this node
  24871. * @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
  24872. * @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)
  24873. * @returns an array of Node
  24874. */
  24875. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24876. /** @hidden */ setReady(state: boolean): void;
  24877. /**
  24878. * Get an animation by name
  24879. * @param name defines the name of the animation to look for
  24880. * @returns null if not found else the requested animation
  24881. */
  24882. getAnimationByName(name: string): Nullable<Animation>;
  24883. /**
  24884. * Creates an animation range for this node
  24885. * @param name defines the name of the range
  24886. * @param from defines the starting key
  24887. * @param to defines the end key
  24888. */
  24889. createAnimationRange(name: string, from: number, to: number): void;
  24890. /**
  24891. * Delete a specific animation range
  24892. * @param name defines the name of the range to delete
  24893. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24894. */
  24895. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24896. /**
  24897. * Get an animation range by name
  24898. * @param name defines the name of the animation range to look for
  24899. * @returns null if not found else the requested animation range
  24900. */
  24901. getAnimationRange(name: string): Nullable<AnimationRange>;
  24902. /**
  24903. * Gets the list of all animation ranges defined on this node
  24904. * @returns an array
  24905. */
  24906. getAnimationRanges(): Nullable<AnimationRange>[];
  24907. /**
  24908. * Will start the animation sequence
  24909. * @param name defines the range frames for animation sequence
  24910. * @param loop defines if the animation should loop (false by default)
  24911. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24912. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24913. * @returns the object created for this animation. If range does not exist, it will return null
  24914. */
  24915. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24916. /**
  24917. * Serialize animation ranges into a JSON compatible object
  24918. * @returns serialization object
  24919. */
  24920. serializeAnimationRanges(): any;
  24921. /**
  24922. * Computes the world matrix of the node
  24923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24924. * @returns the world matrix
  24925. */
  24926. computeWorldMatrix(force?: boolean): Matrix;
  24927. /**
  24928. * Releases resources associated with this node.
  24929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24931. */
  24932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24933. /**
  24934. * Parse animation range data from a serialization object and store them into a given node
  24935. * @param node defines where to store the animation ranges
  24936. * @param parsedNode defines the serialization object to read data from
  24937. * @param scene defines the hosting scene
  24938. */
  24939. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24940. /**
  24941. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  24942. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24943. * @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
  24944. * @returns the new bounding vectors
  24945. */
  24946. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24947. min: Vector3;
  24948. max: Vector3;
  24949. };
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * @hidden
  24955. */
  24956. export class _IAnimationState {
  24957. key: number;
  24958. repeatCount: number;
  24959. workValue?: any;
  24960. loopMode?: number;
  24961. offsetValue?: any;
  24962. highLimitValue?: any;
  24963. }
  24964. /**
  24965. * Class used to store any kind of animation
  24966. */
  24967. export class Animation {
  24968. /**Name of the animation */
  24969. name: string;
  24970. /**Property to animate */
  24971. targetProperty: string;
  24972. /**The frames per second of the animation */
  24973. framePerSecond: number;
  24974. /**The data type of the animation */
  24975. dataType: number;
  24976. /**The loop mode of the animation */
  24977. loopMode?: number | undefined;
  24978. /**Specifies if blending should be enabled */
  24979. enableBlending?: boolean | undefined;
  24980. /**
  24981. * Use matrix interpolation instead of using direct key value when animating matrices
  24982. */
  24983. static AllowMatricesInterpolation: boolean;
  24984. /**
  24985. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24986. */
  24987. static AllowMatrixDecomposeForInterpolation: boolean;
  24988. /**
  24989. * Stores the key frames of the animation
  24990. */
  24991. private _keys;
  24992. /**
  24993. * Stores the easing function of the animation
  24994. */
  24995. private _easingFunction;
  24996. /**
  24997. * @hidden Internal use only
  24998. */ runtimeAnimations: RuntimeAnimation[];
  24999. /**
  25000. * The set of event that will be linked to this animation
  25001. */
  25002. private _events;
  25003. /**
  25004. * Stores an array of target property paths
  25005. */
  25006. targetPropertyPath: string[];
  25007. /**
  25008. * Stores the blending speed of the animation
  25009. */
  25010. blendingSpeed: number;
  25011. /**
  25012. * Stores the animation ranges for the animation
  25013. */
  25014. private _ranges;
  25015. /**
  25016. * @hidden Internal use
  25017. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25018. /**
  25019. * Sets up an animation
  25020. * @param property The property to animate
  25021. * @param animationType The animation type to apply
  25022. * @param framePerSecond The frames per second of the animation
  25023. * @param easingFunction The easing function used in the animation
  25024. * @returns The created animation
  25025. */
  25026. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25027. /**
  25028. * Create and start an animation on a node
  25029. * @param name defines the name of the global animation that will be run on all nodes
  25030. * @param node defines the root node where the animation will take place
  25031. * @param targetProperty defines property to animate
  25032. * @param framePerSecond defines the number of frame per second yo use
  25033. * @param totalFrame defines the number of frames in total
  25034. * @param from defines the initial value
  25035. * @param to defines the final value
  25036. * @param loopMode defines which loop mode you want to use (off by default)
  25037. * @param easingFunction defines the easing function to use (linear by default)
  25038. * @param onAnimationEnd defines the callback to call when animation end
  25039. * @returns the animatable created for this animation
  25040. */
  25041. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25042. /**
  25043. * Create and start an animation on a node and its descendants
  25044. * @param name defines the name of the global animation that will be run on all nodes
  25045. * @param node defines the root node where the animation will take place
  25046. * @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
  25047. * @param targetProperty defines property to animate
  25048. * @param framePerSecond defines the number of frame per second to use
  25049. * @param totalFrame defines the number of frames in total
  25050. * @param from defines the initial value
  25051. * @param to defines the final value
  25052. * @param loopMode defines which loop mode you want to use (off by default)
  25053. * @param easingFunction defines the easing function to use (linear by default)
  25054. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25055. * @returns the list of animatables created for all nodes
  25056. * @example https://www.babylonjs-playground.com/#MH0VLI
  25057. */
  25058. 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[]>;
  25059. /**
  25060. * Creates a new animation, merges it with the existing animations and starts it
  25061. * @param name Name of the animation
  25062. * @param node Node which contains the scene that begins the animations
  25063. * @param targetProperty Specifies which property to animate
  25064. * @param framePerSecond The frames per second of the animation
  25065. * @param totalFrame The total number of frames
  25066. * @param from The frame at the beginning of the animation
  25067. * @param to The frame at the end of the animation
  25068. * @param loopMode Specifies the loop mode of the animation
  25069. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25070. * @param onAnimationEnd Callback to run once the animation is complete
  25071. * @returns Nullable animation
  25072. */
  25073. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25074. /**
  25075. * Transition property of an host to the target Value
  25076. * @param property The property to transition
  25077. * @param targetValue The target Value of the property
  25078. * @param host The object where the property to animate belongs
  25079. * @param scene Scene used to run the animation
  25080. * @param frameRate Framerate (in frame/s) to use
  25081. * @param transition The transition type we want to use
  25082. * @param duration The duration of the animation, in milliseconds
  25083. * @param onAnimationEnd Callback trigger at the end of the animation
  25084. * @returns Nullable animation
  25085. */
  25086. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25087. /**
  25088. * Return the array of runtime animations currently using this animation
  25089. */
  25090. readonly runtimeAnimations: RuntimeAnimation[];
  25091. /**
  25092. * Specifies if any of the runtime animations are currently running
  25093. */
  25094. readonly hasRunningRuntimeAnimations: boolean;
  25095. /**
  25096. * Initializes the animation
  25097. * @param name Name of the animation
  25098. * @param targetProperty Property to animate
  25099. * @param framePerSecond The frames per second of the animation
  25100. * @param dataType The data type of the animation
  25101. * @param loopMode The loop mode of the animation
  25102. * @param enableBlending Specifies if blending should be enabled
  25103. */
  25104. constructor(
  25105. /**Name of the animation */
  25106. name: string,
  25107. /**Property to animate */
  25108. targetProperty: string,
  25109. /**The frames per second of the animation */
  25110. framePerSecond: number,
  25111. /**The data type of the animation */
  25112. dataType: number,
  25113. /**The loop mode of the animation */
  25114. loopMode?: number | undefined,
  25115. /**Specifies if blending should be enabled */
  25116. enableBlending?: boolean | undefined);
  25117. /**
  25118. * Converts the animation to a string
  25119. * @param fullDetails support for multiple levels of logging within scene loading
  25120. * @returns String form of the animation
  25121. */
  25122. toString(fullDetails?: boolean): string;
  25123. /**
  25124. * Add an event to this animation
  25125. * @param event Event to add
  25126. */
  25127. addEvent(event: AnimationEvent): void;
  25128. /**
  25129. * Remove all events found at the given frame
  25130. * @param frame The frame to remove events from
  25131. */
  25132. removeEvents(frame: number): void;
  25133. /**
  25134. * Retrieves all the events from the animation
  25135. * @returns Events from the animation
  25136. */
  25137. getEvents(): AnimationEvent[];
  25138. /**
  25139. * Creates an animation range
  25140. * @param name Name of the animation range
  25141. * @param from Starting frame of the animation range
  25142. * @param to Ending frame of the animation
  25143. */
  25144. createRange(name: string, from: number, to: number): void;
  25145. /**
  25146. * Deletes an animation range by name
  25147. * @param name Name of the animation range to delete
  25148. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25149. */
  25150. deleteRange(name: string, deleteFrames?: boolean): void;
  25151. /**
  25152. * Gets the animation range by name, or null if not defined
  25153. * @param name Name of the animation range
  25154. * @returns Nullable animation range
  25155. */
  25156. getRange(name: string): Nullable<AnimationRange>;
  25157. /**
  25158. * Gets the key frames from the animation
  25159. * @returns The key frames of the animation
  25160. */
  25161. getKeys(): Array<IAnimationKey>;
  25162. /**
  25163. * Gets the highest frame rate of the animation
  25164. * @returns Highest frame rate of the animation
  25165. */
  25166. getHighestFrame(): number;
  25167. /**
  25168. * Gets the easing function of the animation
  25169. * @returns Easing function of the animation
  25170. */
  25171. getEasingFunction(): IEasingFunction;
  25172. /**
  25173. * Sets the easing function of the animation
  25174. * @param easingFunction A custom mathematical formula for animation
  25175. */
  25176. setEasingFunction(easingFunction: EasingFunction): void;
  25177. /**
  25178. * Interpolates a scalar linearly
  25179. * @param startValue Start value of the animation curve
  25180. * @param endValue End value of the animation curve
  25181. * @param gradient Scalar amount to interpolate
  25182. * @returns Interpolated scalar value
  25183. */
  25184. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25185. /**
  25186. * Interpolates a scalar cubically
  25187. * @param startValue Start value of the animation curve
  25188. * @param outTangent End tangent of the animation
  25189. * @param endValue End value of the animation curve
  25190. * @param inTangent Start tangent of the animation curve
  25191. * @param gradient Scalar amount to interpolate
  25192. * @returns Interpolated scalar value
  25193. */
  25194. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25195. /**
  25196. * Interpolates a quaternion using a spherical linear interpolation
  25197. * @param startValue Start value of the animation curve
  25198. * @param endValue End value of the animation curve
  25199. * @param gradient Scalar amount to interpolate
  25200. * @returns Interpolated quaternion value
  25201. */
  25202. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25203. /**
  25204. * Interpolates a quaternion cubically
  25205. * @param startValue Start value of the animation curve
  25206. * @param outTangent End tangent of the animation curve
  25207. * @param endValue End value of the animation curve
  25208. * @param inTangent Start tangent of the animation curve
  25209. * @param gradient Scalar amount to interpolate
  25210. * @returns Interpolated quaternion value
  25211. */
  25212. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25213. /**
  25214. * Interpolates a Vector3 linearl
  25215. * @param startValue Start value of the animation curve
  25216. * @param endValue End value of the animation curve
  25217. * @param gradient Scalar amount to interpolate
  25218. * @returns Interpolated scalar value
  25219. */
  25220. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25221. /**
  25222. * Interpolates a Vector3 cubically
  25223. * @param startValue Start value of the animation curve
  25224. * @param outTangent End tangent of the animation
  25225. * @param endValue End value of the animation curve
  25226. * @param inTangent Start tangent of the animation curve
  25227. * @param gradient Scalar amount to interpolate
  25228. * @returns InterpolatedVector3 value
  25229. */
  25230. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25231. /**
  25232. * Interpolates a Vector2 linearly
  25233. * @param startValue Start value of the animation curve
  25234. * @param endValue End value of the animation curve
  25235. * @param gradient Scalar amount to interpolate
  25236. * @returns Interpolated Vector2 value
  25237. */
  25238. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25239. /**
  25240. * Interpolates a Vector2 cubically
  25241. * @param startValue Start value of the animation curve
  25242. * @param outTangent End tangent of the animation
  25243. * @param endValue End value of the animation curve
  25244. * @param inTangent Start tangent of the animation curve
  25245. * @param gradient Scalar amount to interpolate
  25246. * @returns Interpolated Vector2 value
  25247. */
  25248. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25249. /**
  25250. * Interpolates a size linearly
  25251. * @param startValue Start value of the animation curve
  25252. * @param endValue End value of the animation curve
  25253. * @param gradient Scalar amount to interpolate
  25254. * @returns Interpolated Size value
  25255. */
  25256. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25257. /**
  25258. * Interpolates a Color3 linearly
  25259. * @param startValue Start value of the animation curve
  25260. * @param endValue End value of the animation curve
  25261. * @param gradient Scalar amount to interpolate
  25262. * @returns Interpolated Color3 value
  25263. */
  25264. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25265. /**
  25266. * @hidden Internal use only
  25267. */ getKeyValue(value: any): any;
  25268. /**
  25269. * @hidden Internal use only
  25270. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25271. /**
  25272. * Defines the function to use to interpolate matrices
  25273. * @param startValue defines the start matrix
  25274. * @param endValue defines the end matrix
  25275. * @param gradient defines the gradient between both matrices
  25276. * @param result defines an optional target matrix where to store the interpolation
  25277. * @returns the interpolated matrix
  25278. */
  25279. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25280. /**
  25281. * Makes a copy of the animation
  25282. * @returns Cloned animation
  25283. */
  25284. clone(): Animation;
  25285. /**
  25286. * Sets the key frames of the animation
  25287. * @param values The animation key frames to set
  25288. */
  25289. setKeys(values: Array<IAnimationKey>): void;
  25290. /**
  25291. * Serializes the animation to an object
  25292. * @returns Serialized object
  25293. */
  25294. serialize(): any;
  25295. /**
  25296. * Float animation type
  25297. */
  25298. private static _ANIMATIONTYPE_FLOAT;
  25299. /**
  25300. * Vector3 animation type
  25301. */
  25302. private static _ANIMATIONTYPE_VECTOR3;
  25303. /**
  25304. * Quaternion animation type
  25305. */
  25306. private static _ANIMATIONTYPE_QUATERNION;
  25307. /**
  25308. * Matrix animation type
  25309. */
  25310. private static _ANIMATIONTYPE_MATRIX;
  25311. /**
  25312. * Color3 animation type
  25313. */
  25314. private static _ANIMATIONTYPE_COLOR3;
  25315. /**
  25316. * Vector2 animation type
  25317. */
  25318. private static _ANIMATIONTYPE_VECTOR2;
  25319. /**
  25320. * Size animation type
  25321. */
  25322. private static _ANIMATIONTYPE_SIZE;
  25323. /**
  25324. * Relative Loop Mode
  25325. */
  25326. private static _ANIMATIONLOOPMODE_RELATIVE;
  25327. /**
  25328. * Cycle Loop Mode
  25329. */
  25330. private static _ANIMATIONLOOPMODE_CYCLE;
  25331. /**
  25332. * Constant Loop Mode
  25333. */
  25334. private static _ANIMATIONLOOPMODE_CONSTANT;
  25335. /**
  25336. * Get the float animation type
  25337. */
  25338. static readonly ANIMATIONTYPE_FLOAT: number;
  25339. /**
  25340. * Get the Vector3 animation type
  25341. */
  25342. static readonly ANIMATIONTYPE_VECTOR3: number;
  25343. /**
  25344. * Get the Vector2 animation type
  25345. */
  25346. static readonly ANIMATIONTYPE_VECTOR2: number;
  25347. /**
  25348. * Get the Size animation type
  25349. */
  25350. static readonly ANIMATIONTYPE_SIZE: number;
  25351. /**
  25352. * Get the Quaternion animation type
  25353. */
  25354. static readonly ANIMATIONTYPE_QUATERNION: number;
  25355. /**
  25356. * Get the Matrix animation type
  25357. */
  25358. static readonly ANIMATIONTYPE_MATRIX: number;
  25359. /**
  25360. * Get the Color3 animation type
  25361. */
  25362. static readonly ANIMATIONTYPE_COLOR3: number;
  25363. /**
  25364. * Get the Relative Loop Mode
  25365. */
  25366. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25367. /**
  25368. * Get the Cycle Loop Mode
  25369. */
  25370. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25371. /**
  25372. * Get the Constant Loop Mode
  25373. */
  25374. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25375. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25376. /**
  25377. * Parses an animation object and creates an animation
  25378. * @param parsedAnimation Parsed animation object
  25379. * @returns Animation object
  25380. */
  25381. static Parse(parsedAnimation: any): Animation;
  25382. /**
  25383. * Appends the serialized animations from the source animations
  25384. * @param source Source containing the animations
  25385. * @param destination Target to store the animations
  25386. */
  25387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25388. }
  25389. }
  25390. declare module BABYLON {
  25391. /**
  25392. * Base class of all the textures in babylon.
  25393. * It groups all the common properties the materials, post process, lights... might need
  25394. * in order to make a correct use of the texture.
  25395. */
  25396. export class BaseTexture implements IAnimatable {
  25397. /**
  25398. * Default anisotropic filtering level for the application.
  25399. * It is set to 4 as a good tradeoff between perf and quality.
  25400. */
  25401. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25402. /**
  25403. * Gets or sets the unique id of the texture
  25404. */
  25405. uniqueId: number;
  25406. /**
  25407. * Define the name of the texture.
  25408. */
  25409. name: string;
  25410. /**
  25411. * Gets or sets an object used to store user defined information.
  25412. */
  25413. metadata: any;
  25414. /**
  25415. * For internal use only. Please do not use.
  25416. */
  25417. reservedDataStore: any;
  25418. private _hasAlpha;
  25419. /**
  25420. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25421. */
  25422. hasAlpha: boolean;
  25423. /**
  25424. * Defines if the alpha value should be determined via the rgb values.
  25425. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25426. */
  25427. getAlphaFromRGB: boolean;
  25428. /**
  25429. * Intensity or strength of the texture.
  25430. * It is commonly used by materials to fine tune the intensity of the texture
  25431. */
  25432. level: number;
  25433. /**
  25434. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25435. * This is part of the texture as textures usually maps to one uv set.
  25436. */
  25437. coordinatesIndex: number;
  25438. private _coordinatesMode;
  25439. /**
  25440. * How a texture is mapped.
  25441. *
  25442. * | Value | Type | Description |
  25443. * | ----- | ----------------------------------- | ----------- |
  25444. * | 0 | EXPLICIT_MODE | |
  25445. * | 1 | SPHERICAL_MODE | |
  25446. * | 2 | PLANAR_MODE | |
  25447. * | 3 | CUBIC_MODE | |
  25448. * | 4 | PROJECTION_MODE | |
  25449. * | 5 | SKYBOX_MODE | |
  25450. * | 6 | INVCUBIC_MODE | |
  25451. * | 7 | EQUIRECTANGULAR_MODE | |
  25452. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25453. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25454. */
  25455. coordinatesMode: number;
  25456. /**
  25457. * | Value | Type | Description |
  25458. * | ----- | ------------------ | ----------- |
  25459. * | 0 | CLAMP_ADDRESSMODE | |
  25460. * | 1 | WRAP_ADDRESSMODE | |
  25461. * | 2 | MIRROR_ADDRESSMODE | |
  25462. */
  25463. wrapU: number;
  25464. /**
  25465. * | Value | Type | Description |
  25466. * | ----- | ------------------ | ----------- |
  25467. * | 0 | CLAMP_ADDRESSMODE | |
  25468. * | 1 | WRAP_ADDRESSMODE | |
  25469. * | 2 | MIRROR_ADDRESSMODE | |
  25470. */
  25471. wrapV: number;
  25472. /**
  25473. * | Value | Type | Description |
  25474. * | ----- | ------------------ | ----------- |
  25475. * | 0 | CLAMP_ADDRESSMODE | |
  25476. * | 1 | WRAP_ADDRESSMODE | |
  25477. * | 2 | MIRROR_ADDRESSMODE | |
  25478. */
  25479. wrapR: number;
  25480. /**
  25481. * With compliant hardware and browser (supporting anisotropic filtering)
  25482. * this defines the level of anisotropic filtering in the texture.
  25483. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25484. */
  25485. anisotropicFilteringLevel: number;
  25486. /**
  25487. * Define if the texture is a cube texture or if false a 2d texture.
  25488. */
  25489. isCube: boolean;
  25490. /**
  25491. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25492. */
  25493. is3D: boolean;
  25494. /**
  25495. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25496. * HDR texture are usually stored in linear space.
  25497. * This only impacts the PBR and Background materials
  25498. */
  25499. gammaSpace: boolean;
  25500. /**
  25501. * Gets whether or not the texture contains RGBD data.
  25502. */
  25503. readonly isRGBD: boolean;
  25504. /**
  25505. * Is Z inverted in the texture (useful in a cube texture).
  25506. */
  25507. invertZ: boolean;
  25508. /**
  25509. * Are mip maps generated for this texture or not.
  25510. */
  25511. readonly noMipmap: boolean;
  25512. /**
  25513. * @hidden
  25514. */
  25515. lodLevelInAlpha: boolean;
  25516. /**
  25517. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25518. */
  25519. lodGenerationOffset: number;
  25520. /**
  25521. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25522. */
  25523. lodGenerationScale: number;
  25524. /**
  25525. * Define if the texture is a render target.
  25526. */
  25527. isRenderTarget: boolean;
  25528. /**
  25529. * Define the unique id of the texture in the scene.
  25530. */
  25531. readonly uid: string;
  25532. /**
  25533. * Return a string representation of the texture.
  25534. * @returns the texture as a string
  25535. */
  25536. toString(): string;
  25537. /**
  25538. * Get the class name of the texture.
  25539. * @returns "BaseTexture"
  25540. */
  25541. getClassName(): string;
  25542. /**
  25543. * Define the list of animation attached to the texture.
  25544. */
  25545. animations: Animation[];
  25546. /**
  25547. * An event triggered when the texture is disposed.
  25548. */
  25549. onDisposeObservable: Observable<BaseTexture>;
  25550. private _onDisposeObserver;
  25551. /**
  25552. * Callback triggered when the texture has been disposed.
  25553. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25554. */
  25555. onDispose: () => void;
  25556. /**
  25557. * Define the current state of the loading sequence when in delayed load mode.
  25558. */
  25559. delayLoadState: number;
  25560. private _scene;
  25561. /** @hidden */ texture: Nullable<InternalTexture>;
  25562. private _uid;
  25563. /**
  25564. * Define if the texture is preventinga material to render or not.
  25565. * If not and the texture is not ready, the engine will use a default black texture instead.
  25566. */
  25567. readonly isBlocking: boolean;
  25568. /**
  25569. * Instantiates a new BaseTexture.
  25570. * Base class of all the textures in babylon.
  25571. * It groups all the common properties the materials, post process, lights... might need
  25572. * in order to make a correct use of the texture.
  25573. * @param scene Define the scene the texture blongs to
  25574. */
  25575. constructor(scene: Nullable<Scene>);
  25576. /**
  25577. * Get the scene the texture belongs to.
  25578. * @returns the scene or null if undefined
  25579. */
  25580. getScene(): Nullable<Scene>;
  25581. /**
  25582. * Get the texture transform matrix used to offset tile the texture for istance.
  25583. * @returns the transformation matrix
  25584. */
  25585. getTextureMatrix(): Matrix;
  25586. /**
  25587. * Get the texture reflection matrix used to rotate/transform the reflection.
  25588. * @returns the reflection matrix
  25589. */
  25590. getReflectionTextureMatrix(): Matrix;
  25591. /**
  25592. * Get the underlying lower level texture from Babylon.
  25593. * @returns the insternal texture
  25594. */
  25595. getInternalTexture(): Nullable<InternalTexture>;
  25596. /**
  25597. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25598. * @returns true if ready or not blocking
  25599. */
  25600. isReadyOrNotBlocking(): boolean;
  25601. /**
  25602. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25603. * @returns true if fully ready
  25604. */
  25605. isReady(): boolean;
  25606. private _cachedSize;
  25607. /**
  25608. * Get the size of the texture.
  25609. * @returns the texture size.
  25610. */
  25611. getSize(): ISize;
  25612. /**
  25613. * Get the base size of the texture.
  25614. * It can be different from the size if the texture has been resized for POT for instance
  25615. * @returns the base size
  25616. */
  25617. getBaseSize(): ISize;
  25618. /**
  25619. * Update the sampling mode of the texture.
  25620. * Default is Trilinear mode.
  25621. *
  25622. * | Value | Type | Description |
  25623. * | ----- | ------------------ | ----------- |
  25624. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25625. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25626. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25627. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25628. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25629. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25630. * | 7 | NEAREST_LINEAR | |
  25631. * | 8 | NEAREST_NEAREST | |
  25632. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25633. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25634. * | 11 | LINEAR_LINEAR | |
  25635. * | 12 | LINEAR_NEAREST | |
  25636. *
  25637. * > _mag_: magnification filter (close to the viewer)
  25638. * > _min_: minification filter (far from the viewer)
  25639. * > _mip_: filter used between mip map levels
  25640. *@param samplingMode Define the new sampling mode of the texture
  25641. */
  25642. updateSamplingMode(samplingMode: number): void;
  25643. /**
  25644. * Scales the texture if is `canRescale()`
  25645. * @param ratio the resize factor we want to use to rescale
  25646. */
  25647. scale(ratio: number): void;
  25648. /**
  25649. * Get if the texture can rescale.
  25650. */
  25651. readonly canRescale: boolean;
  25652. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25653. /** @hidden */ rebuild(): void;
  25654. /**
  25655. * Triggers the load sequence in delayed load mode.
  25656. */
  25657. delayLoad(): void;
  25658. /**
  25659. * Clones the texture.
  25660. * @returns the cloned texture
  25661. */
  25662. clone(): Nullable<BaseTexture>;
  25663. /**
  25664. * Get the texture underlying type (INT, FLOAT...)
  25665. */
  25666. readonly textureType: number;
  25667. /**
  25668. * Get the texture underlying format (RGB, RGBA...)
  25669. */
  25670. readonly textureFormat: number;
  25671. /**
  25672. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25673. * This will returns an RGBA array buffer containing either in values (0-255) or
  25674. * float values (0-1) depending of the underlying buffer type.
  25675. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25676. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25677. * @param buffer defines a user defined buffer to fill with data (can be null)
  25678. * @returns The Array buffer containing the pixels data.
  25679. */
  25680. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25681. /**
  25682. * Release and destroy the underlying lower level texture aka internalTexture.
  25683. */
  25684. releaseInternalTexture(): void;
  25685. /**
  25686. * Get the polynomial representation of the texture data.
  25687. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25688. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25689. */
  25690. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25691. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25692. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25693. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25694. /**
  25695. * Dispose the texture and release its associated resources.
  25696. */
  25697. dispose(): void;
  25698. /**
  25699. * Serialize the texture into a JSON representation that can be parsed later on.
  25700. * @returns the JSON representation of the texture
  25701. */
  25702. serialize(): any;
  25703. /**
  25704. * Helper function to be called back once a list of texture contains only ready textures.
  25705. * @param textures Define the list of textures to wait for
  25706. * @param callback Define the callback triggered once the entire list will be ready
  25707. */
  25708. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25709. }
  25710. }
  25711. declare module BABYLON {
  25712. /**
  25713. * Uniform buffer objects.
  25714. *
  25715. * Handles blocks of uniform on the GPU.
  25716. *
  25717. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25718. *
  25719. * For more information, please refer to :
  25720. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25721. */
  25722. export class UniformBuffer {
  25723. private _engine;
  25724. private _buffer;
  25725. private _data;
  25726. private _bufferData;
  25727. private _dynamic?;
  25728. private _uniformLocations;
  25729. private _uniformSizes;
  25730. private _uniformLocationPointer;
  25731. private _needSync;
  25732. private _noUBO;
  25733. private _currentEffect;
  25734. private static _MAX_UNIFORM_SIZE;
  25735. private static _tempBuffer;
  25736. /**
  25737. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25738. * This is dynamic to allow compat with webgl 1 and 2.
  25739. * You will need to pass the name of the uniform as well as the value.
  25740. */
  25741. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25742. /**
  25743. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25744. * This is dynamic to allow compat with webgl 1 and 2.
  25745. * You will need to pass the name of the uniform as well as the value.
  25746. */
  25747. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25748. /**
  25749. * Lambda to Update a single float in a uniform buffer.
  25750. * This is dynamic to allow compat with webgl 1 and 2.
  25751. * You will need to pass the name of the uniform as well as the value.
  25752. */
  25753. updateFloat: (name: string, x: number) => void;
  25754. /**
  25755. * Lambda to Update a vec2 of float in a uniform buffer.
  25756. * This is dynamic to allow compat with webgl 1 and 2.
  25757. * You will need to pass the name of the uniform as well as the value.
  25758. */
  25759. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25760. /**
  25761. * Lambda to Update a vec3 of float in a uniform buffer.
  25762. * This is dynamic to allow compat with webgl 1 and 2.
  25763. * You will need to pass the name of the uniform as well as the value.
  25764. */
  25765. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25766. /**
  25767. * Lambda to Update a vec4 of float in a uniform buffer.
  25768. * This is dynamic to allow compat with webgl 1 and 2.
  25769. * You will need to pass the name of the uniform as well as the value.
  25770. */
  25771. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25772. /**
  25773. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25774. * This is dynamic to allow compat with webgl 1 and 2.
  25775. * You will need to pass the name of the uniform as well as the value.
  25776. */
  25777. updateMatrix: (name: string, mat: Matrix) => void;
  25778. /**
  25779. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25780. * This is dynamic to allow compat with webgl 1 and 2.
  25781. * You will need to pass the name of the uniform as well as the value.
  25782. */
  25783. updateVector3: (name: string, vector: Vector3) => void;
  25784. /**
  25785. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25786. * This is dynamic to allow compat with webgl 1 and 2.
  25787. * You will need to pass the name of the uniform as well as the value.
  25788. */
  25789. updateVector4: (name: string, vector: Vector4) => void;
  25790. /**
  25791. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25792. * This is dynamic to allow compat with webgl 1 and 2.
  25793. * You will need to pass the name of the uniform as well as the value.
  25794. */
  25795. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25796. /**
  25797. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25798. * This is dynamic to allow compat with webgl 1 and 2.
  25799. * You will need to pass the name of the uniform as well as the value.
  25800. */
  25801. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25802. /**
  25803. * Instantiates a new Uniform buffer objects.
  25804. *
  25805. * Handles blocks of uniform on the GPU.
  25806. *
  25807. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25808. *
  25809. * For more information, please refer to :
  25810. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25811. * @param engine Define the engine the buffer is associated with
  25812. * @param data Define the data contained in the buffer
  25813. * @param dynamic Define if the buffer is updatable
  25814. */
  25815. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25816. /**
  25817. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25818. * or just falling back on setUniformXXX calls.
  25819. */
  25820. readonly useUbo: boolean;
  25821. /**
  25822. * Indicates if the WebGL underlying uniform buffer is in sync
  25823. * with the javascript cache data.
  25824. */
  25825. readonly isSync: boolean;
  25826. /**
  25827. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25828. * Also, a dynamic UniformBuffer will disable cache verification and always
  25829. * update the underlying WebGL uniform buffer to the GPU.
  25830. * @returns if Dynamic, otherwise false
  25831. */
  25832. isDynamic(): boolean;
  25833. /**
  25834. * The data cache on JS side.
  25835. * @returns the underlying data as a float array
  25836. */
  25837. getData(): Float32Array;
  25838. /**
  25839. * The underlying WebGL Uniform buffer.
  25840. * @returns the webgl buffer
  25841. */
  25842. getBuffer(): Nullable<DataBuffer>;
  25843. /**
  25844. * std140 layout specifies how to align data within an UBO structure.
  25845. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25846. * for specs.
  25847. */
  25848. private _fillAlignment;
  25849. /**
  25850. * Adds an uniform in the buffer.
  25851. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25852. * for the layout to be correct !
  25853. * @param name Name of the uniform, as used in the uniform block in the shader.
  25854. * @param size Data size, or data directly.
  25855. */
  25856. addUniform(name: string, size: number | number[]): void;
  25857. /**
  25858. * Adds a Matrix 4x4 to the uniform buffer.
  25859. * @param name Name of the uniform, as used in the uniform block in the shader.
  25860. * @param mat A 4x4 matrix.
  25861. */
  25862. addMatrix(name: string, mat: Matrix): void;
  25863. /**
  25864. * Adds a vec2 to the uniform buffer.
  25865. * @param name Name of the uniform, as used in the uniform block in the shader.
  25866. * @param x Define the x component value of the vec2
  25867. * @param y Define the y component value of the vec2
  25868. */
  25869. addFloat2(name: string, x: number, y: number): void;
  25870. /**
  25871. * Adds a vec3 to the uniform buffer.
  25872. * @param name Name of the uniform, as used in the uniform block in the shader.
  25873. * @param x Define the x component value of the vec3
  25874. * @param y Define the y component value of the vec3
  25875. * @param z Define the z component value of the vec3
  25876. */
  25877. addFloat3(name: string, x: number, y: number, z: number): void;
  25878. /**
  25879. * Adds a vec3 to the uniform buffer.
  25880. * @param name Name of the uniform, as used in the uniform block in the shader.
  25881. * @param color Define the vec3 from a Color
  25882. */
  25883. addColor3(name: string, color: Color3): void;
  25884. /**
  25885. * Adds a vec4 to the uniform buffer.
  25886. * @param name Name of the uniform, as used in the uniform block in the shader.
  25887. * @param color Define the rgb components from a Color
  25888. * @param alpha Define the a component of the vec4
  25889. */
  25890. addColor4(name: string, color: Color3, alpha: number): void;
  25891. /**
  25892. * Adds a vec3 to the uniform buffer.
  25893. * @param name Name of the uniform, as used in the uniform block in the shader.
  25894. * @param vector Define the vec3 components from a Vector
  25895. */
  25896. addVector3(name: string, vector: Vector3): void;
  25897. /**
  25898. * Adds a Matrix 3x3 to the uniform buffer.
  25899. * @param name Name of the uniform, as used in the uniform block in the shader.
  25900. */
  25901. addMatrix3x3(name: string): void;
  25902. /**
  25903. * Adds a Matrix 2x2 to the uniform buffer.
  25904. * @param name Name of the uniform, as used in the uniform block in the shader.
  25905. */
  25906. addMatrix2x2(name: string): void;
  25907. /**
  25908. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25909. */
  25910. create(): void;
  25911. /** @hidden */ rebuild(): void;
  25912. /**
  25913. * Updates the WebGL Uniform Buffer on the GPU.
  25914. * If the `dynamic` flag is set to true, no cache comparison is done.
  25915. * Otherwise, the buffer will be updated only if the cache differs.
  25916. */
  25917. update(): void;
  25918. /**
  25919. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25920. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25921. * @param data Define the flattened data
  25922. * @param size Define the size of the data.
  25923. */
  25924. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25925. private _updateMatrix3x3ForUniform;
  25926. private _updateMatrix3x3ForEffect;
  25927. private _updateMatrix2x2ForEffect;
  25928. private _updateMatrix2x2ForUniform;
  25929. private _updateFloatForEffect;
  25930. private _updateFloatForUniform;
  25931. private _updateFloat2ForEffect;
  25932. private _updateFloat2ForUniform;
  25933. private _updateFloat3ForEffect;
  25934. private _updateFloat3ForUniform;
  25935. private _updateFloat4ForEffect;
  25936. private _updateFloat4ForUniform;
  25937. private _updateMatrixForEffect;
  25938. private _updateMatrixForUniform;
  25939. private _updateVector3ForEffect;
  25940. private _updateVector3ForUniform;
  25941. private _updateVector4ForEffect;
  25942. private _updateVector4ForUniform;
  25943. private _updateColor3ForEffect;
  25944. private _updateColor3ForUniform;
  25945. private _updateColor4ForEffect;
  25946. private _updateColor4ForUniform;
  25947. /**
  25948. * Sets a sampler uniform on the effect.
  25949. * @param name Define the name of the sampler.
  25950. * @param texture Define the texture to set in the sampler
  25951. */
  25952. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25953. /**
  25954. * Directly updates the value of the uniform in the cache AND on the GPU.
  25955. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25956. * @param data Define the flattened data
  25957. */
  25958. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25959. /**
  25960. * Binds this uniform buffer to an effect.
  25961. * @param effect Define the effect to bind the buffer to
  25962. * @param name Name of the uniform block in the shader.
  25963. */
  25964. bindToEffect(effect: Effect, name: string): void;
  25965. /**
  25966. * Disposes the uniform buffer.
  25967. */
  25968. dispose(): void;
  25969. }
  25970. }
  25971. declare module BABYLON {
  25972. /**
  25973. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25975. */
  25976. export class Analyser {
  25977. /**
  25978. * Gets or sets the smoothing
  25979. * @ignorenaming
  25980. */
  25981. SMOOTHING: number;
  25982. /**
  25983. * Gets or sets the FFT table size
  25984. * @ignorenaming
  25985. */
  25986. FFT_SIZE: number;
  25987. /**
  25988. * Gets or sets the bar graph amplitude
  25989. * @ignorenaming
  25990. */
  25991. BARGRAPHAMPLITUDE: number;
  25992. /**
  25993. * Gets or sets the position of the debug canvas
  25994. * @ignorenaming
  25995. */
  25996. DEBUGCANVASPOS: {
  25997. x: number;
  25998. y: number;
  25999. };
  26000. /**
  26001. * Gets or sets the debug canvas size
  26002. * @ignorenaming
  26003. */
  26004. DEBUGCANVASSIZE: {
  26005. width: number;
  26006. height: number;
  26007. };
  26008. private _byteFreqs;
  26009. private _byteTime;
  26010. private _floatFreqs;
  26011. private _webAudioAnalyser;
  26012. private _debugCanvas;
  26013. private _debugCanvasContext;
  26014. private _scene;
  26015. private _registerFunc;
  26016. private _audioEngine;
  26017. /**
  26018. * Creates a new analyser
  26019. * @param scene defines hosting scene
  26020. */
  26021. constructor(scene: Scene);
  26022. /**
  26023. * Get the number of data values you will have to play with for the visualization
  26024. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26025. * @returns a number
  26026. */
  26027. getFrequencyBinCount(): number;
  26028. /**
  26029. * Gets the current frequency data as a byte array
  26030. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26031. * @returns a Uint8Array
  26032. */
  26033. getByteFrequencyData(): Uint8Array;
  26034. /**
  26035. * Gets the current waveform as a byte array
  26036. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26037. * @returns a Uint8Array
  26038. */
  26039. getByteTimeDomainData(): Uint8Array;
  26040. /**
  26041. * Gets the current frequency data as a float array
  26042. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26043. * @returns a Float32Array
  26044. */
  26045. getFloatFrequencyData(): Float32Array;
  26046. /**
  26047. * Renders the debug canvas
  26048. */
  26049. drawDebugCanvas(): void;
  26050. /**
  26051. * Stops rendering the debug canvas and removes it
  26052. */
  26053. stopDebugCanvas(): void;
  26054. /**
  26055. * Connects two audio nodes
  26056. * @param inputAudioNode defines first node to connect
  26057. * @param outputAudioNode defines second node to connect
  26058. */
  26059. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26060. /**
  26061. * Releases all associated resources
  26062. */
  26063. dispose(): void;
  26064. }
  26065. }
  26066. declare module BABYLON {
  26067. /**
  26068. * This represents an audio engine and it is responsible
  26069. * to play, synchronize and analyse sounds throughout the application.
  26070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26071. */
  26072. export interface IAudioEngine extends IDisposable {
  26073. /**
  26074. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26075. */
  26076. readonly canUseWebAudio: boolean;
  26077. /**
  26078. * Gets the current AudioContext if available.
  26079. */
  26080. readonly audioContext: Nullable<AudioContext>;
  26081. /**
  26082. * The master gain node defines the global audio volume of your audio engine.
  26083. */
  26084. readonly masterGain: GainNode;
  26085. /**
  26086. * Gets whether or not mp3 are supported by your browser.
  26087. */
  26088. readonly isMP3supported: boolean;
  26089. /**
  26090. * Gets whether or not ogg are supported by your browser.
  26091. */
  26092. readonly isOGGsupported: boolean;
  26093. /**
  26094. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26095. * @ignoreNaming
  26096. */
  26097. WarnedWebAudioUnsupported: boolean;
  26098. /**
  26099. * Defines if the audio engine relies on a custom unlocked button.
  26100. * In this case, the embedded button will not be displayed.
  26101. */
  26102. useCustomUnlockedButton: boolean;
  26103. /**
  26104. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26105. */
  26106. readonly unlocked: boolean;
  26107. /**
  26108. * Event raised when audio has been unlocked on the browser.
  26109. */
  26110. onAudioUnlockedObservable: Observable<AudioEngine>;
  26111. /**
  26112. * Event raised when audio has been locked on the browser.
  26113. */
  26114. onAudioLockedObservable: Observable<AudioEngine>;
  26115. /**
  26116. * Flags the audio engine in Locked state.
  26117. * This happens due to new browser policies preventing audio to autoplay.
  26118. */
  26119. lock(): void;
  26120. /**
  26121. * Unlocks the audio engine once a user action has been done on the dom.
  26122. * This is helpful to resume play once browser policies have been satisfied.
  26123. */
  26124. unlock(): void;
  26125. }
  26126. /**
  26127. * This represents the default audio engine used in babylon.
  26128. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26130. */
  26131. export class AudioEngine implements IAudioEngine {
  26132. private _audioContext;
  26133. private _audioContextInitialized;
  26134. private _muteButton;
  26135. private _hostElement;
  26136. /**
  26137. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26138. */
  26139. canUseWebAudio: boolean;
  26140. /**
  26141. * The master gain node defines the global audio volume of your audio engine.
  26142. */
  26143. masterGain: GainNode;
  26144. /**
  26145. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26146. * @ignoreNaming
  26147. */
  26148. WarnedWebAudioUnsupported: boolean;
  26149. /**
  26150. * Gets whether or not mp3 are supported by your browser.
  26151. */
  26152. isMP3supported: boolean;
  26153. /**
  26154. * Gets whether or not ogg are supported by your browser.
  26155. */
  26156. isOGGsupported: boolean;
  26157. /**
  26158. * Gets whether audio has been unlocked on the device.
  26159. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26160. * a user interaction has happened.
  26161. */
  26162. unlocked: boolean;
  26163. /**
  26164. * Defines if the audio engine relies on a custom unlocked button.
  26165. * In this case, the embedded button will not be displayed.
  26166. */
  26167. useCustomUnlockedButton: boolean;
  26168. /**
  26169. * Event raised when audio has been unlocked on the browser.
  26170. */
  26171. onAudioUnlockedObservable: Observable<AudioEngine>;
  26172. /**
  26173. * Event raised when audio has been locked on the browser.
  26174. */
  26175. onAudioLockedObservable: Observable<AudioEngine>;
  26176. /**
  26177. * Gets the current AudioContext if available.
  26178. */
  26179. readonly audioContext: Nullable<AudioContext>;
  26180. private _connectedAnalyser;
  26181. /**
  26182. * Instantiates a new audio engine.
  26183. *
  26184. * There should be only one per page as some browsers restrict the number
  26185. * of audio contexts you can create.
  26186. * @param hostElement defines the host element where to display the mute icon if necessary
  26187. */
  26188. constructor(hostElement?: Nullable<HTMLElement>);
  26189. /**
  26190. * Flags the audio engine in Locked state.
  26191. * This happens due to new browser policies preventing audio to autoplay.
  26192. */
  26193. lock(): void;
  26194. /**
  26195. * Unlocks the audio engine once a user action has been done on the dom.
  26196. * This is helpful to resume play once browser policies have been satisfied.
  26197. */
  26198. unlock(): void;
  26199. private _resumeAudioContext;
  26200. private _initializeAudioContext;
  26201. private _tryToRun;
  26202. private _triggerRunningState;
  26203. private _triggerSuspendedState;
  26204. private _displayMuteButton;
  26205. private _moveButtonToTopLeft;
  26206. private _onResize;
  26207. private _hideMuteButton;
  26208. /**
  26209. * Destroy and release the resources associated with the audio ccontext.
  26210. */
  26211. dispose(): void;
  26212. /**
  26213. * Gets the global volume sets on the master gain.
  26214. * @returns the global volume if set or -1 otherwise
  26215. */
  26216. getGlobalVolume(): number;
  26217. /**
  26218. * Sets the global volume of your experience (sets on the master gain).
  26219. * @param newVolume Defines the new global volume of the application
  26220. */
  26221. setGlobalVolume(newVolume: number): void;
  26222. /**
  26223. * Connect the audio engine to an audio analyser allowing some amazing
  26224. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26226. * @param analyser The analyser to connect to the engine
  26227. */
  26228. connectToAnalyser(analyser: Analyser): void;
  26229. }
  26230. }
  26231. declare module BABYLON {
  26232. /**
  26233. * Interface used to present a loading screen while loading a scene
  26234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26235. */
  26236. export interface ILoadingScreen {
  26237. /**
  26238. * Function called to display the loading screen
  26239. */
  26240. displayLoadingUI: () => void;
  26241. /**
  26242. * Function called to hide the loading screen
  26243. */
  26244. hideLoadingUI: () => void;
  26245. /**
  26246. * Gets or sets the color to use for the background
  26247. */
  26248. loadingUIBackgroundColor: string;
  26249. /**
  26250. * Gets or sets the text to display while loading
  26251. */
  26252. loadingUIText: string;
  26253. }
  26254. /**
  26255. * Class used for the default loading screen
  26256. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26257. */
  26258. export class DefaultLoadingScreen implements ILoadingScreen {
  26259. private _renderingCanvas;
  26260. private _loadingText;
  26261. private _loadingDivBackgroundColor;
  26262. private _loadingDiv;
  26263. private _loadingTextDiv;
  26264. /**
  26265. * Creates a new default loading screen
  26266. * @param _renderingCanvas defines the canvas used to render the scene
  26267. * @param _loadingText defines the default text to display
  26268. * @param _loadingDivBackgroundColor defines the default background color
  26269. */
  26270. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26271. /**
  26272. * Function called to display the loading screen
  26273. */
  26274. displayLoadingUI(): void;
  26275. /**
  26276. * Function called to hide the loading screen
  26277. */
  26278. hideLoadingUI(): void;
  26279. /**
  26280. * Gets or sets the text to display while loading
  26281. */
  26282. loadingUIText: string;
  26283. /**
  26284. * Gets or sets the color to use for the background
  26285. */
  26286. loadingUIBackgroundColor: string;
  26287. private _resizeLoadingUI;
  26288. }
  26289. }
  26290. declare module BABYLON {
  26291. /** @hidden */
  26292. export class WebGLPipelineContext implements IPipelineContext {
  26293. engine: Engine;
  26294. program: Nullable<WebGLProgram>;
  26295. context?: WebGLRenderingContext;
  26296. vertexShader?: WebGLShader;
  26297. fragmentShader?: WebGLShader;
  26298. isParallelCompiled: boolean;
  26299. onCompiled?: () => void;
  26300. transformFeedback?: WebGLTransformFeedback | null;
  26301. readonly isAsync: boolean;
  26302. readonly isReady: boolean;
  26303. }
  26304. }
  26305. declare module BABYLON {
  26306. /** @hidden */
  26307. export class WebGLDataBuffer extends DataBuffer {
  26308. private _buffer;
  26309. constructor(resource: WebGLBuffer);
  26310. readonly underlyingResource: any;
  26311. }
  26312. }
  26313. declare module BABYLON {
  26314. /**
  26315. * Settings for finer control over video usage
  26316. */
  26317. export interface VideoTextureSettings {
  26318. /**
  26319. * Applies `autoplay` to video, if specified
  26320. */
  26321. autoPlay?: boolean;
  26322. /**
  26323. * Applies `loop` to video, if specified
  26324. */
  26325. loop?: boolean;
  26326. /**
  26327. * Automatically updates internal texture from video at every frame in the render loop
  26328. */
  26329. autoUpdateTexture: boolean;
  26330. /**
  26331. * Image src displayed during the video loading or until the user interacts with the video.
  26332. */
  26333. poster?: string;
  26334. }
  26335. /**
  26336. * If you want to display a video in your scene, this is the special texture for that.
  26337. * This special texture works similar to other textures, with the exception of a few parameters.
  26338. * @see https://doc.babylonjs.com/how_to/video_texture
  26339. */
  26340. export class VideoTexture extends Texture {
  26341. /**
  26342. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26343. */
  26344. readonly autoUpdateTexture: boolean;
  26345. /**
  26346. * The video instance used by the texture internally
  26347. */
  26348. readonly video: HTMLVideoElement;
  26349. private _onUserActionRequestedObservable;
  26350. /**
  26351. * Event triggerd when a dom action is required by the user to play the video.
  26352. * This happens due to recent changes in browser policies preventing video to auto start.
  26353. */
  26354. readonly onUserActionRequestedObservable: Observable<Texture>;
  26355. private _generateMipMaps;
  26356. private _engine;
  26357. private _stillImageCaptured;
  26358. private _displayingPosterTexture;
  26359. private _settings;
  26360. private _createInternalTextureOnEvent;
  26361. /**
  26362. * Creates a video texture.
  26363. * If you want to display a video in your scene, this is the special texture for that.
  26364. * This special texture works similar to other textures, with the exception of a few parameters.
  26365. * @see https://doc.babylonjs.com/how_to/video_texture
  26366. * @param name optional name, will detect from video source, if not defined
  26367. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26368. * @param scene is obviously the current scene.
  26369. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26370. * @param invertY is false by default but can be used to invert video on Y axis
  26371. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26372. * @param settings allows finer control over video usage
  26373. */
  26374. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26375. private _getName;
  26376. private _getVideo;
  26377. private _createInternalTexture;
  26378. private reset;
  26379. /**
  26380. * @hidden Internal method to initiate `update`.
  26381. */ rebuild(): void;
  26382. /**
  26383. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26384. */
  26385. update(): void;
  26386. /**
  26387. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26388. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26389. */
  26390. updateTexture(isVisible: boolean): void;
  26391. protected _updateInternalTexture: () => void;
  26392. /**
  26393. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26394. * @param url New url.
  26395. */
  26396. updateURL(url: string): void;
  26397. /**
  26398. * Dispose the texture and release its associated resources.
  26399. */
  26400. dispose(): void;
  26401. /**
  26402. * Creates a video texture straight from a stream.
  26403. * @param scene Define the scene the texture should be created in
  26404. * @param stream Define the stream the texture should be created from
  26405. * @returns The created video texture as a promise
  26406. */
  26407. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26408. /**
  26409. * Creates a video texture straight from your WebCam video feed.
  26410. * @param scene Define the scene the texture should be created in
  26411. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26412. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26413. * @returns The created video texture as a promise
  26414. */
  26415. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26416. minWidth: number;
  26417. maxWidth: number;
  26418. minHeight: number;
  26419. maxHeight: number;
  26420. deviceId: string;
  26421. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26422. /**
  26423. * Creates a video texture straight from your WebCam video feed.
  26424. * @param scene Define the scene the texture should be created in
  26425. * @param onReady Define a callback to triggered once the texture will be ready
  26426. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26427. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26428. */
  26429. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26430. minWidth: number;
  26431. maxWidth: number;
  26432. minHeight: number;
  26433. maxHeight: number;
  26434. deviceId: string;
  26435. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26436. }
  26437. }
  26438. declare module BABYLON {
  26439. /**
  26440. * Interface for attribute information associated with buffer instanciation
  26441. */
  26442. export class InstancingAttributeInfo {
  26443. /**
  26444. * Index/offset of the attribute in the vertex shader
  26445. */
  26446. index: number;
  26447. /**
  26448. * size of the attribute, 1, 2, 3 or 4
  26449. */
  26450. attributeSize: number;
  26451. /**
  26452. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26453. * default is FLOAT
  26454. */
  26455. attribyteType: number;
  26456. /**
  26457. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26458. */
  26459. normalized: boolean;
  26460. /**
  26461. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26462. */
  26463. offset: number;
  26464. /**
  26465. * Name of the GLSL attribute, for debugging purpose only
  26466. */
  26467. attributeName: string;
  26468. }
  26469. /**
  26470. * Define options used to create a depth texture
  26471. */
  26472. export class DepthTextureCreationOptions {
  26473. /** Specifies whether or not a stencil should be allocated in the texture */
  26474. generateStencil?: boolean;
  26475. /** Specifies whether or not bilinear filtering is enable on the texture */
  26476. bilinearFiltering?: boolean;
  26477. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26478. comparisonFunction?: number;
  26479. /** Specifies if the created texture is a cube texture */
  26480. isCube?: boolean;
  26481. }
  26482. /**
  26483. * Class used to describe the capabilities of the engine relatively to the current browser
  26484. */
  26485. export class EngineCapabilities {
  26486. /** Maximum textures units per fragment shader */
  26487. maxTexturesImageUnits: number;
  26488. /** Maximum texture units per vertex shader */
  26489. maxVertexTextureImageUnits: number;
  26490. /** Maximum textures units in the entire pipeline */
  26491. maxCombinedTexturesImageUnits: number;
  26492. /** Maximum texture size */
  26493. maxTextureSize: number;
  26494. /** Maximum cube texture size */
  26495. maxCubemapTextureSize: number;
  26496. /** Maximum render texture size */
  26497. maxRenderTextureSize: number;
  26498. /** Maximum number of vertex attributes */
  26499. maxVertexAttribs: number;
  26500. /** Maximum number of varyings */
  26501. maxVaryingVectors: number;
  26502. /** Maximum number of uniforms per vertex shader */
  26503. maxVertexUniformVectors: number;
  26504. /** Maximum number of uniforms per fragment shader */
  26505. maxFragmentUniformVectors: number;
  26506. /** Defines if standard derivates (dx/dy) are supported */
  26507. standardDerivatives: boolean;
  26508. /** Defines if s3tc texture compression is supported */
  26509. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26510. /** Defines if pvrtc texture compression is supported */
  26511. pvrtc: any;
  26512. /** Defines if etc1 texture compression is supported */
  26513. etc1: any;
  26514. /** Defines if etc2 texture compression is supported */
  26515. etc2: any;
  26516. /** Defines if astc texture compression is supported */
  26517. astc: any;
  26518. /** Defines if float textures are supported */
  26519. textureFloat: boolean;
  26520. /** Defines if vertex array objects are supported */
  26521. vertexArrayObject: boolean;
  26522. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26523. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26524. /** Gets the maximum level of anisotropy supported */
  26525. maxAnisotropy: number;
  26526. /** Defines if instancing is supported */
  26527. instancedArrays: boolean;
  26528. /** Defines if 32 bits indices are supported */
  26529. uintIndices: boolean;
  26530. /** Defines if high precision shaders are supported */
  26531. highPrecisionShaderSupported: boolean;
  26532. /** Defines if depth reading in the fragment shader is supported */
  26533. fragmentDepthSupported: boolean;
  26534. /** Defines if float texture linear filtering is supported*/
  26535. textureFloatLinearFiltering: boolean;
  26536. /** Defines if rendering to float textures is supported */
  26537. textureFloatRender: boolean;
  26538. /** Defines if half float textures are supported*/
  26539. textureHalfFloat: boolean;
  26540. /** Defines if half float texture linear filtering is supported*/
  26541. textureHalfFloatLinearFiltering: boolean;
  26542. /** Defines if rendering to half float textures is supported */
  26543. textureHalfFloatRender: boolean;
  26544. /** Defines if textureLOD shader command is supported */
  26545. textureLOD: boolean;
  26546. /** Defines if draw buffers extension is supported */
  26547. drawBuffersExtension: boolean;
  26548. /** Defines if depth textures are supported */
  26549. depthTextureExtension: boolean;
  26550. /** Defines if float color buffer are supported */
  26551. colorBufferFloat: boolean;
  26552. /** Gets disjoint timer query extension (null if not supported) */
  26553. timerQuery: EXT_disjoint_timer_query;
  26554. /** Defines if timestamp can be used with timer query */
  26555. canUseTimestampForTimerQuery: boolean;
  26556. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26557. multiview: any;
  26558. /** Function used to let the system compiles shaders in background */
  26559. parallelShaderCompile: {
  26560. COMPLETION_STATUS_KHR: number;
  26561. };
  26562. }
  26563. /** Interface defining initialization parameters for Engine class */
  26564. export interface EngineOptions extends WebGLContextAttributes {
  26565. /**
  26566. * Defines if the engine should no exceed a specified device ratio
  26567. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26568. */
  26569. limitDeviceRatio?: number;
  26570. /**
  26571. * Defines if webvr should be enabled automatically
  26572. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26573. */
  26574. autoEnableWebVR?: boolean;
  26575. /**
  26576. * Defines if webgl2 should be turned off even if supported
  26577. * @see http://doc.babylonjs.com/features/webgl2
  26578. */
  26579. disableWebGL2Support?: boolean;
  26580. /**
  26581. * Defines if webaudio should be initialized as well
  26582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26583. */
  26584. audioEngine?: boolean;
  26585. /**
  26586. * Defines if animations should run using a deterministic lock step
  26587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26588. */
  26589. deterministicLockstep?: boolean;
  26590. /** Defines the maximum steps to use with deterministic lock step mode */
  26591. lockstepMaxSteps?: number;
  26592. /**
  26593. * Defines that engine should ignore context lost events
  26594. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26595. */
  26596. doNotHandleContextLost?: boolean;
  26597. /**
  26598. * Defines that engine should ignore modifying touch action attribute and style
  26599. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26600. */
  26601. doNotHandleTouchAction?: boolean;
  26602. /**
  26603. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26604. */
  26605. useHighPrecisionFloats?: boolean;
  26606. }
  26607. /**
  26608. * Defines the interface used by display changed events
  26609. */
  26610. export interface IDisplayChangedEventArgs {
  26611. /** Gets the vrDisplay object (if any) */
  26612. vrDisplay: Nullable<any>;
  26613. /** Gets a boolean indicating if webVR is supported */
  26614. vrSupported: boolean;
  26615. }
  26616. /**
  26617. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26618. */
  26619. export class Engine {
  26620. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26621. static ExceptionList: ({
  26622. key: string;
  26623. capture: string;
  26624. captureConstraint: number;
  26625. targets: string[];
  26626. } | {
  26627. key: string;
  26628. capture: null;
  26629. captureConstraint: null;
  26630. targets: string[];
  26631. })[];
  26632. /** Gets the list of created engines */
  26633. static readonly Instances: Engine[];
  26634. /**
  26635. * Gets the latest created engine
  26636. */
  26637. static readonly LastCreatedEngine: Nullable<Engine>;
  26638. /**
  26639. * Gets the latest created scene
  26640. */
  26641. static readonly LastCreatedScene: Nullable<Scene>;
  26642. /**
  26643. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26644. * @param flag defines which part of the materials must be marked as dirty
  26645. * @param predicate defines a predicate used to filter which materials should be affected
  26646. */
  26647. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26648. /**
  26649. * Hidden
  26650. */ private static _TextureLoaders: IInternalTextureLoader[];
  26651. /** Defines that alpha blending is disabled */
  26652. static readonly ALPHA_DISABLE: number;
  26653. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26654. static readonly ALPHA_ADD: number;
  26655. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26656. static readonly ALPHA_COMBINE: number;
  26657. /** Defines that alpha blending to DEST - SRC * DEST */
  26658. static readonly ALPHA_SUBTRACT: number;
  26659. /** Defines that alpha blending to SRC * DEST */
  26660. static readonly ALPHA_MULTIPLY: number;
  26661. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26662. static readonly ALPHA_MAXIMIZED: number;
  26663. /** Defines that alpha blending to SRC + DEST */
  26664. static readonly ALPHA_ONEONE: number;
  26665. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26666. static readonly ALPHA_PREMULTIPLIED: number;
  26667. /**
  26668. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26669. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26670. */
  26671. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26672. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26673. static readonly ALPHA_INTERPOLATE: number;
  26674. /**
  26675. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26676. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26677. */
  26678. static readonly ALPHA_SCREENMODE: number;
  26679. /** Defines that the ressource is not delayed*/
  26680. static readonly DELAYLOADSTATE_NONE: number;
  26681. /** Defines that the ressource was successfully delay loaded */
  26682. static readonly DELAYLOADSTATE_LOADED: number;
  26683. /** Defines that the ressource is currently delay loading */
  26684. static readonly DELAYLOADSTATE_LOADING: number;
  26685. /** Defines that the ressource is delayed and has not started loading */
  26686. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26688. static readonly NEVER: number;
  26689. /** 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 */
  26690. static readonly ALWAYS: number;
  26691. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26692. static readonly LESS: number;
  26693. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26694. static readonly EQUAL: number;
  26695. /** 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 */
  26696. static readonly LEQUAL: number;
  26697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26698. static readonly GREATER: number;
  26699. /** 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 */
  26700. static readonly GEQUAL: number;
  26701. /** 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 */
  26702. static readonly NOTEQUAL: number;
  26703. /** Passed to stencilOperation to specify that stencil value must be kept */
  26704. static readonly KEEP: number;
  26705. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26706. static readonly REPLACE: number;
  26707. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26708. static readonly INCR: number;
  26709. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26710. static readonly DECR: number;
  26711. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26712. static readonly INVERT: number;
  26713. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26714. static readonly INCR_WRAP: number;
  26715. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26716. static readonly DECR_WRAP: number;
  26717. /** Texture is not repeating outside of 0..1 UVs */
  26718. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26719. /** Texture is repeating outside of 0..1 UVs */
  26720. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26721. /** Texture is repeating and mirrored */
  26722. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26723. /** ALPHA */
  26724. static readonly TEXTUREFORMAT_ALPHA: number;
  26725. /** LUMINANCE */
  26726. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26727. /** LUMINANCE_ALPHA */
  26728. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26729. /** RGB */
  26730. static readonly TEXTUREFORMAT_RGB: number;
  26731. /** RGBA */
  26732. static readonly TEXTUREFORMAT_RGBA: number;
  26733. /** RED */
  26734. static readonly TEXTUREFORMAT_RED: number;
  26735. /** RED (2nd reference) */
  26736. static readonly TEXTUREFORMAT_R: number;
  26737. /** RG */
  26738. static readonly TEXTUREFORMAT_RG: number;
  26739. /** RED_INTEGER */
  26740. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26741. /** RED_INTEGER (2nd reference) */
  26742. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26743. /** RG_INTEGER */
  26744. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26745. /** RGB_INTEGER */
  26746. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26747. /** RGBA_INTEGER */
  26748. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26749. /** UNSIGNED_BYTE */
  26750. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26751. /** UNSIGNED_BYTE (2nd reference) */
  26752. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26753. /** FLOAT */
  26754. static readonly TEXTURETYPE_FLOAT: number;
  26755. /** HALF_FLOAT */
  26756. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26757. /** BYTE */
  26758. static readonly TEXTURETYPE_BYTE: number;
  26759. /** SHORT */
  26760. static readonly TEXTURETYPE_SHORT: number;
  26761. /** UNSIGNED_SHORT */
  26762. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26763. /** INT */
  26764. static readonly TEXTURETYPE_INT: number;
  26765. /** UNSIGNED_INT */
  26766. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26767. /** UNSIGNED_SHORT_4_4_4_4 */
  26768. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26769. /** UNSIGNED_SHORT_5_5_5_1 */
  26770. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26771. /** UNSIGNED_SHORT_5_6_5 */
  26772. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26773. /** UNSIGNED_INT_2_10_10_10_REV */
  26774. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26775. /** UNSIGNED_INT_24_8 */
  26776. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26777. /** UNSIGNED_INT_10F_11F_11F_REV */
  26778. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26779. /** UNSIGNED_INT_5_9_9_9_REV */
  26780. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26781. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26782. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26783. /** nearest is mag = nearest and min = nearest and mip = linear */
  26784. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26785. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26786. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26787. /** Trilinear is mag = linear and min = linear and mip = linear */
  26788. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26789. /** nearest is mag = nearest and min = nearest and mip = linear */
  26790. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26791. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26792. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26793. /** Trilinear is mag = linear and min = linear and mip = linear */
  26794. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26795. /** mag = nearest and min = nearest and mip = nearest */
  26796. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26797. /** mag = nearest and min = linear and mip = nearest */
  26798. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26799. /** mag = nearest and min = linear and mip = linear */
  26800. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26801. /** mag = nearest and min = linear and mip = none */
  26802. static readonly TEXTURE_NEAREST_LINEAR: number;
  26803. /** mag = nearest and min = nearest and mip = none */
  26804. static readonly TEXTURE_NEAREST_NEAREST: number;
  26805. /** mag = linear and min = nearest and mip = nearest */
  26806. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26807. /** mag = linear and min = nearest and mip = linear */
  26808. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26809. /** mag = linear and min = linear and mip = none */
  26810. static readonly TEXTURE_LINEAR_LINEAR: number;
  26811. /** mag = linear and min = nearest and mip = none */
  26812. static readonly TEXTURE_LINEAR_NEAREST: number;
  26813. /** Explicit coordinates mode */
  26814. static readonly TEXTURE_EXPLICIT_MODE: number;
  26815. /** Spherical coordinates mode */
  26816. static readonly TEXTURE_SPHERICAL_MODE: number;
  26817. /** Planar coordinates mode */
  26818. static readonly TEXTURE_PLANAR_MODE: number;
  26819. /** Cubic coordinates mode */
  26820. static readonly TEXTURE_CUBIC_MODE: number;
  26821. /** Projection coordinates mode */
  26822. static readonly TEXTURE_PROJECTION_MODE: number;
  26823. /** Skybox coordinates mode */
  26824. static readonly TEXTURE_SKYBOX_MODE: number;
  26825. /** Inverse Cubic coordinates mode */
  26826. static readonly TEXTURE_INVCUBIC_MODE: number;
  26827. /** Equirectangular coordinates mode */
  26828. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26829. /** Equirectangular Fixed coordinates mode */
  26830. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26831. /** Equirectangular Fixed Mirrored coordinates mode */
  26832. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26833. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26834. static readonly SCALEMODE_FLOOR: number;
  26835. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26836. static readonly SCALEMODE_NEAREST: number;
  26837. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26838. static readonly SCALEMODE_CEILING: number;
  26839. /**
  26840. * Returns the current npm package of the sdk
  26841. */
  26842. static readonly NpmPackage: string;
  26843. /**
  26844. * Returns the current version of the framework
  26845. */
  26846. static readonly Version: string;
  26847. /**
  26848. * Returns a string describing the current engine
  26849. */
  26850. readonly description: string;
  26851. /**
  26852. * Gets or sets the epsilon value used by collision engine
  26853. */
  26854. static CollisionsEpsilon: number;
  26855. /**
  26856. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26857. */
  26858. static ShadersRepository: string;
  26859. /**
  26860. * Method called to create the default loading screen.
  26861. * This can be overriden in your own app.
  26862. * @param canvas The rendering canvas element
  26863. * @returns The loading screen
  26864. */
  26865. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26866. /**
  26867. * Method called to create the default rescale post process on each engine.
  26868. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26869. /**
  26870. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26871. */
  26872. forcePOTTextures: boolean;
  26873. /**
  26874. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26875. */
  26876. isFullscreen: boolean;
  26877. /**
  26878. * Gets a boolean indicating if the pointer is currently locked
  26879. */
  26880. isPointerLock: boolean;
  26881. /**
  26882. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26883. */
  26884. cullBackFaces: boolean;
  26885. /**
  26886. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26887. */
  26888. renderEvenInBackground: boolean;
  26889. /**
  26890. * Gets or sets a boolean indicating that cache can be kept between frames
  26891. */
  26892. preventCacheWipeBetweenFrames: boolean;
  26893. /**
  26894. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26895. **/
  26896. enableOfflineSupport: boolean;
  26897. /**
  26898. * 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)
  26899. **/
  26900. disableManifestCheck: boolean;
  26901. /**
  26902. * Gets the list of created scenes
  26903. */
  26904. scenes: Scene[];
  26905. /**
  26906. * Event raised when a new scene is created
  26907. */
  26908. onNewSceneAddedObservable: Observable<Scene>;
  26909. /**
  26910. * Gets the list of created postprocesses
  26911. */
  26912. postProcesses: PostProcess[];
  26913. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26914. validateShaderPrograms: boolean;
  26915. /**
  26916. * Observable event triggered each time the rendering canvas is resized
  26917. */
  26918. onResizeObservable: Observable<Engine>;
  26919. /**
  26920. * Observable event triggered each time the canvas loses focus
  26921. */
  26922. onCanvasBlurObservable: Observable<Engine>;
  26923. /**
  26924. * Observable event triggered each time the canvas gains focus
  26925. */
  26926. onCanvasFocusObservable: Observable<Engine>;
  26927. /**
  26928. * Observable event triggered each time the canvas receives pointerout event
  26929. */
  26930. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26931. /**
  26932. * Observable event triggered before each texture is initialized
  26933. */
  26934. onBeforeTextureInitObservable: Observable<Texture>;
  26935. private _vrDisplay;
  26936. private _vrSupported;
  26937. private _oldSize;
  26938. private _oldHardwareScaleFactor;
  26939. private _vrExclusivePointerMode;
  26940. private _webVRInitPromise;
  26941. /**
  26942. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26943. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26944. */
  26945. readonly isInVRExclusivePointerMode: boolean;
  26946. /**
  26947. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26948. */
  26949. disableUniformBuffers: boolean;
  26950. /** @hidden */ uniformBuffers: UniformBuffer[];
  26951. /**
  26952. * Gets a boolean indicating that the engine supports uniform buffers
  26953. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26954. */
  26955. readonly supportsUniformBuffers: boolean;
  26956. /**
  26957. * Observable raised when the engine begins a new frame
  26958. */
  26959. onBeginFrameObservable: Observable<Engine>;
  26960. /**
  26961. * If set, will be used to request the next animation frame for the render loop
  26962. */
  26963. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26964. /**
  26965. * Observable raised when the engine ends the current frame
  26966. */
  26967. onEndFrameObservable: Observable<Engine>;
  26968. /**
  26969. * Observable raised when the engine is about to compile a shader
  26970. */
  26971. onBeforeShaderCompilationObservable: Observable<Engine>;
  26972. /**
  26973. * Observable raised when the engine has jsut compiled a shader
  26974. */
  26975. onAfterShaderCompilationObservable: Observable<Engine>;
  26976. /** @hidden */ gl: WebGLRenderingContext;
  26977. private _renderingCanvas;
  26978. private _windowIsBackground;
  26979. private _webGLVersion;
  26980. protected _highPrecisionShadersAllowed: boolean;
  26981. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26982. /**
  26983. * Gets a boolean indicating that only power of 2 textures are supported
  26984. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26985. */
  26986. readonly needPOTTextures: boolean;
  26987. /** @hidden */ badOS: boolean;
  26988. /** @hidden */ badDesktopOS: boolean;
  26989. /**
  26990. * Gets the audio engine
  26991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26992. * @ignorenaming
  26993. */
  26994. static audioEngine: IAudioEngine;
  26995. /**
  26996. * Default AudioEngine factory responsible of creating the Audio Engine.
  26997. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26998. */
  26999. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27000. /**
  27001. * Default offline support factory responsible of creating a tool used to store data locally.
  27002. * By default, this will create a Database object if the workload has been embedded.
  27003. */
  27004. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27005. private _onFocus;
  27006. private _onBlur;
  27007. private _onCanvasPointerOut;
  27008. private _onCanvasBlur;
  27009. private _onCanvasFocus;
  27010. private _onFullscreenChange;
  27011. private _onPointerLockChange;
  27012. private _onVRDisplayPointerRestricted;
  27013. private _onVRDisplayPointerUnrestricted;
  27014. private _onVrDisplayConnect;
  27015. private _onVrDisplayDisconnect;
  27016. private _onVrDisplayPresentChange;
  27017. /**
  27018. * Observable signaled when VR display mode changes
  27019. */
  27020. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27021. /**
  27022. * Observable signaled when VR request present is complete
  27023. */
  27024. onVRRequestPresentComplete: Observable<boolean>;
  27025. /**
  27026. * Observable signaled when VR request present starts
  27027. */
  27028. onVRRequestPresentStart: Observable<Engine>;
  27029. private _hardwareScalingLevel;
  27030. /** @hidden */ caps: EngineCapabilities;
  27031. private _pointerLockRequested;
  27032. private _isStencilEnable;
  27033. private _colorWrite;
  27034. private _loadingScreen;
  27035. /** @hidden */ drawCalls: PerfCounter;
  27036. private _glVersion;
  27037. private _glRenderer;
  27038. private _glVendor;
  27039. private _videoTextureSupported;
  27040. private _renderingQueueLaunched;
  27041. private _activeRenderLoops;
  27042. private _deterministicLockstep;
  27043. private _lockstepMaxSteps;
  27044. /**
  27045. * Observable signaled when a context lost event is raised
  27046. */
  27047. onContextLostObservable: Observable<Engine>;
  27048. /**
  27049. * Observable signaled when a context restored event is raised
  27050. */
  27051. onContextRestoredObservable: Observable<Engine>;
  27052. private _onContextLost;
  27053. private _onContextRestored;
  27054. private _contextWasLost;
  27055. /** @hidden */ doNotHandleContextLost: boolean;
  27056. /**
  27057. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27059. */
  27060. doNotHandleContextLost: boolean;
  27061. private _performanceMonitor;
  27062. private _fps;
  27063. private _deltaTime;
  27064. /**
  27065. * Turn this value on if you want to pause FPS computation when in background
  27066. */
  27067. disablePerformanceMonitorInBackground: boolean;
  27068. /**
  27069. * Gets the performance monitor attached to this engine
  27070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27071. */
  27072. readonly performanceMonitor: PerformanceMonitor;
  27073. /**
  27074. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27075. */
  27076. disableVertexArrayObjects: boolean;
  27077. /** @hidden */
  27078. protected _depthCullingState: _DepthCullingState;
  27079. /** @hidden */
  27080. protected _stencilState: _StencilState;
  27081. /** @hidden */
  27082. protected _alphaState: _AlphaState;
  27083. /** @hidden */
  27084. protected _alphaMode: number;
  27085. /** @hidden */ internalTexturesCache: InternalTexture[];
  27086. /** @hidden */
  27087. protected _activeChannel: number;
  27088. private _currentTextureChannel;
  27089. /** @hidden */
  27090. protected _boundTexturesCache: {
  27091. [key: string]: Nullable<InternalTexture>;
  27092. };
  27093. /** @hidden */
  27094. protected _currentEffect: Nullable<Effect>;
  27095. /** @hidden */
  27096. protected _currentProgram: Nullable<WebGLProgram>;
  27097. private _compiledEffects;
  27098. private _vertexAttribArraysEnabled;
  27099. /** @hidden */
  27100. protected _cachedViewport: Nullable<Viewport>;
  27101. private _cachedVertexArrayObject;
  27102. /** @hidden */
  27103. protected _cachedVertexBuffers: any;
  27104. /** @hidden */
  27105. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27106. /** @hidden */
  27107. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27108. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27109. private _uintIndicesCurrentlySet;
  27110. private _currentBoundBuffer;
  27111. /** @hidden */
  27112. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27113. private _currentBufferPointers;
  27114. private _currentInstanceLocations;
  27115. private _currentInstanceBuffers;
  27116. private _textureUnits;
  27117. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27118. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27119. private _rescalePostProcess;
  27120. private _dummyFramebuffer;
  27121. private _externalData;
  27122. private _bindedRenderFunction;
  27123. private _vaoRecordInProgress;
  27124. private _mustWipeVertexAttributes;
  27125. private _emptyTexture;
  27126. private _emptyCubeTexture;
  27127. private _emptyTexture3D;
  27128. /** @hidden */ frameHandler: number;
  27129. private _nextFreeTextureSlots;
  27130. private _maxSimultaneousTextures;
  27131. private _activeRequests;
  27132. private _texturesSupported;
  27133. /** @hidden */ textureFormatInUse: Nullable<string>;
  27134. /**
  27135. * Gets the list of texture formats supported
  27136. */
  27137. readonly texturesSupported: Array<string>;
  27138. /**
  27139. * Gets the list of texture formats in use
  27140. */
  27141. readonly textureFormatInUse: Nullable<string>;
  27142. /**
  27143. * Gets the current viewport
  27144. */
  27145. readonly currentViewport: Nullable<Viewport>;
  27146. /**
  27147. * Gets the default empty texture
  27148. */
  27149. readonly emptyTexture: InternalTexture;
  27150. /**
  27151. * Gets the default empty 3D texture
  27152. */
  27153. readonly emptyTexture3D: InternalTexture;
  27154. /**
  27155. * Gets the default empty cube texture
  27156. */
  27157. readonly emptyCubeTexture: InternalTexture;
  27158. /**
  27159. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27160. */
  27161. readonly premultipliedAlpha: boolean;
  27162. /**
  27163. * Creates a new engine
  27164. * @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
  27165. * @param antialias defines enable antialiasing (default: false)
  27166. * @param options defines further options to be sent to the getContext() function
  27167. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27168. */
  27169. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27170. private _disableTouchAction;
  27171. private _rebuildInternalTextures;
  27172. private _rebuildEffects;
  27173. /**
  27174. * Gets a boolean indicating if all created effects are ready
  27175. * @returns true if all effects are ready
  27176. */
  27177. areAllEffectsReady(): boolean;
  27178. private _rebuildBuffers;
  27179. private _initGLContext;
  27180. /**
  27181. * Gets version of the current webGL context
  27182. */
  27183. readonly webGLVersion: number;
  27184. /**
  27185. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27186. */
  27187. readonly isStencilEnable: boolean;
  27188. /** @hidden */ prepareWorkingCanvas(): void;
  27189. /**
  27190. * Reset the texture cache to empty state
  27191. */
  27192. resetTextureCache(): void;
  27193. /**
  27194. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27195. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27196. * @returns true if engine is in deterministic lock step mode
  27197. */
  27198. isDeterministicLockStep(): boolean;
  27199. /**
  27200. * Gets the max steps when engine is running in deterministic lock step
  27201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27202. * @returns the max steps
  27203. */
  27204. getLockstepMaxSteps(): number;
  27205. /**
  27206. * Gets an object containing information about the current webGL context
  27207. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27208. */
  27209. getGlInfo(): {
  27210. vendor: string;
  27211. renderer: string;
  27212. version: string;
  27213. };
  27214. /**
  27215. * Gets current aspect ratio
  27216. * @param camera defines the camera to use to get the aspect ratio
  27217. * @param useScreen defines if screen size must be used (or the current render target if any)
  27218. * @returns a number defining the aspect ratio
  27219. */
  27220. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27221. /**
  27222. * Gets current screen aspect ratio
  27223. * @returns a number defining the aspect ratio
  27224. */
  27225. getScreenAspectRatio(): number;
  27226. /**
  27227. * Gets the current render width
  27228. * @param useScreen defines if screen size must be used (or the current render target if any)
  27229. * @returns a number defining the current render width
  27230. */
  27231. getRenderWidth(useScreen?: boolean): number;
  27232. /**
  27233. * Gets the current render height
  27234. * @param useScreen defines if screen size must be used (or the current render target if any)
  27235. * @returns a number defining the current render height
  27236. */
  27237. getRenderHeight(useScreen?: boolean): number;
  27238. /**
  27239. * Gets the HTML canvas attached with the current webGL context
  27240. * @returns a HTML canvas
  27241. */
  27242. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27243. /**
  27244. * Gets the client rect of the HTML canvas attached with the current webGL context
  27245. * @returns a client rectanglee
  27246. */
  27247. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27248. /**
  27249. * Defines the hardware scaling level.
  27250. * By default the hardware scaling level is computed from the window device ratio.
  27251. * 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.
  27252. * @param level defines the level to use
  27253. */
  27254. setHardwareScalingLevel(level: number): void;
  27255. /**
  27256. * Gets the current hardware scaling level.
  27257. * By default the hardware scaling level is computed from the window device ratio.
  27258. * 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.
  27259. * @returns a number indicating the current hardware scaling level
  27260. */
  27261. getHardwareScalingLevel(): number;
  27262. /**
  27263. * Gets the list of loaded textures
  27264. * @returns an array containing all loaded textures
  27265. */
  27266. getLoadedTexturesCache(): InternalTexture[];
  27267. /**
  27268. * Gets the object containing all engine capabilities
  27269. * @returns the EngineCapabilities object
  27270. */
  27271. getCaps(): EngineCapabilities;
  27272. /**
  27273. * Gets the current depth function
  27274. * @returns a number defining the depth function
  27275. */
  27276. getDepthFunction(): Nullable<number>;
  27277. /**
  27278. * Sets the current depth function
  27279. * @param depthFunc defines the function to use
  27280. */
  27281. setDepthFunction(depthFunc: number): void;
  27282. /**
  27283. * Sets the current depth function to GREATER
  27284. */
  27285. setDepthFunctionToGreater(): void;
  27286. /**
  27287. * Sets the current depth function to GEQUAL
  27288. */
  27289. setDepthFunctionToGreaterOrEqual(): void;
  27290. /**
  27291. * Sets the current depth function to LESS
  27292. */
  27293. setDepthFunctionToLess(): void;
  27294. private _cachedStencilBuffer;
  27295. private _cachedStencilFunction;
  27296. private _cachedStencilMask;
  27297. private _cachedStencilOperationPass;
  27298. private _cachedStencilOperationFail;
  27299. private _cachedStencilOperationDepthFail;
  27300. private _cachedStencilReference;
  27301. /**
  27302. * Caches the the state of the stencil buffer
  27303. */
  27304. cacheStencilState(): void;
  27305. /**
  27306. * Restores the state of the stencil buffer
  27307. */
  27308. restoreStencilState(): void;
  27309. /**
  27310. * Sets the current depth function to LEQUAL
  27311. */
  27312. setDepthFunctionToLessOrEqual(): void;
  27313. /**
  27314. * Gets a boolean indicating if stencil buffer is enabled
  27315. * @returns the current stencil buffer state
  27316. */
  27317. getStencilBuffer(): boolean;
  27318. /**
  27319. * Enable or disable the stencil buffer
  27320. * @param enable defines if the stencil buffer must be enabled or disabled
  27321. */
  27322. setStencilBuffer(enable: boolean): void;
  27323. /**
  27324. * Gets the current stencil mask
  27325. * @returns a number defining the new stencil mask to use
  27326. */
  27327. getStencilMask(): number;
  27328. /**
  27329. * Sets the current stencil mask
  27330. * @param mask defines the new stencil mask to use
  27331. */
  27332. setStencilMask(mask: number): void;
  27333. /**
  27334. * Gets the current stencil function
  27335. * @returns a number defining the stencil function to use
  27336. */
  27337. getStencilFunction(): number;
  27338. /**
  27339. * Gets the current stencil reference value
  27340. * @returns a number defining the stencil reference value to use
  27341. */
  27342. getStencilFunctionReference(): number;
  27343. /**
  27344. * Gets the current stencil mask
  27345. * @returns a number defining the stencil mask to use
  27346. */
  27347. getStencilFunctionMask(): number;
  27348. /**
  27349. * Sets the current stencil function
  27350. * @param stencilFunc defines the new stencil function to use
  27351. */
  27352. setStencilFunction(stencilFunc: number): void;
  27353. /**
  27354. * Sets the current stencil reference
  27355. * @param reference defines the new stencil reference to use
  27356. */
  27357. setStencilFunctionReference(reference: number): void;
  27358. /**
  27359. * Sets the current stencil mask
  27360. * @param mask defines the new stencil mask to use
  27361. */
  27362. setStencilFunctionMask(mask: number): void;
  27363. /**
  27364. * Gets the current stencil operation when stencil fails
  27365. * @returns a number defining stencil operation to use when stencil fails
  27366. */
  27367. getStencilOperationFail(): number;
  27368. /**
  27369. * Gets the current stencil operation when depth fails
  27370. * @returns a number defining stencil operation to use when depth fails
  27371. */
  27372. getStencilOperationDepthFail(): number;
  27373. /**
  27374. * Gets the current stencil operation when stencil passes
  27375. * @returns a number defining stencil operation to use when stencil passes
  27376. */
  27377. getStencilOperationPass(): number;
  27378. /**
  27379. * Sets the stencil operation to use when stencil fails
  27380. * @param operation defines the stencil operation to use when stencil fails
  27381. */
  27382. setStencilOperationFail(operation: number): void;
  27383. /**
  27384. * Sets the stencil operation to use when depth fails
  27385. * @param operation defines the stencil operation to use when depth fails
  27386. */
  27387. setStencilOperationDepthFail(operation: number): void;
  27388. /**
  27389. * Sets the stencil operation to use when stencil passes
  27390. * @param operation defines the stencil operation to use when stencil passes
  27391. */
  27392. setStencilOperationPass(operation: number): void;
  27393. /**
  27394. * Sets a boolean indicating if the dithering state is enabled or disabled
  27395. * @param value defines the dithering state
  27396. */
  27397. setDitheringState(value: boolean): void;
  27398. /**
  27399. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27400. * @param value defines the rasterizer state
  27401. */
  27402. setRasterizerState(value: boolean): void;
  27403. /**
  27404. * stop executing a render loop function and remove it from the execution array
  27405. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27406. */
  27407. stopRenderLoop(renderFunction?: () => void): void;
  27408. /** @hidden */ renderLoop(): void;
  27409. /**
  27410. * Register and execute a render loop. The engine can have more than one render function
  27411. * @param renderFunction defines the function to continuously execute
  27412. */
  27413. runRenderLoop(renderFunction: () => void): void;
  27414. /**
  27415. * Toggle full screen mode
  27416. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27417. */
  27418. switchFullscreen(requestPointerLock: boolean): void;
  27419. /**
  27420. * Enters full screen mode
  27421. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27422. */
  27423. enterFullscreen(requestPointerLock: boolean): void;
  27424. /**
  27425. * Exits full screen mode
  27426. */
  27427. exitFullscreen(): void;
  27428. /**
  27429. * Clear the current render buffer or the current render target (if any is set up)
  27430. * @param color defines the color to use
  27431. * @param backBuffer defines if the back buffer must be cleared
  27432. * @param depth defines if the depth buffer must be cleared
  27433. * @param stencil defines if the stencil buffer must be cleared
  27434. */
  27435. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27436. /**
  27437. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27439. * @param y defines the y-coordinate of the corner of the clear rectangle
  27440. * @param width defines the width of the clear rectangle
  27441. * @param height defines the height of the clear rectangle
  27442. * @param clearColor defines the clear color
  27443. */
  27444. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27445. /**
  27446. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27447. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27448. * @param y defines the y-coordinate of the corner of the clear rectangle
  27449. * @param width defines the width of the clear rectangle
  27450. * @param height defines the height of the clear rectangle
  27451. */
  27452. enableScissor(x: number, y: number, width: number, height: number): void;
  27453. /**
  27454. * Disable previously set scissor test rectangle
  27455. */
  27456. disableScissor(): void;
  27457. private _viewportCached;
  27458. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27459. /**
  27460. * Set the WebGL's viewport
  27461. * @param viewport defines the viewport element to be used
  27462. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27463. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27464. */
  27465. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27466. /**
  27467. * Directly set the WebGL Viewport
  27468. * @param x defines the x coordinate of the viewport (in screen space)
  27469. * @param y defines the y coordinate of the viewport (in screen space)
  27470. * @param width defines the width of the viewport (in screen space)
  27471. * @param height defines the height of the viewport (in screen space)
  27472. * @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
  27473. */
  27474. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27475. /**
  27476. * Begin a new frame
  27477. */
  27478. beginFrame(): void;
  27479. /**
  27480. * Enf the current frame
  27481. */
  27482. endFrame(): void;
  27483. /**
  27484. * Resize the view according to the canvas' size
  27485. */
  27486. resize(): void;
  27487. /**
  27488. * Force a specific size of the canvas
  27489. * @param width defines the new canvas' width
  27490. * @param height defines the new canvas' height
  27491. */
  27492. setSize(width: number, height: number): void;
  27493. /**
  27494. * Gets a boolean indicating if a webVR device was detected
  27495. * @returns true if a webVR device was detected
  27496. */
  27497. isVRDevicePresent(): boolean;
  27498. /**
  27499. * Gets the current webVR device
  27500. * @returns the current webVR device (or null)
  27501. */
  27502. getVRDevice(): any;
  27503. /**
  27504. * Initializes a webVR display and starts listening to display change events
  27505. * The onVRDisplayChangedObservable will be notified upon these changes
  27506. * @returns The onVRDisplayChangedObservable
  27507. */
  27508. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27509. /**
  27510. * Initializes a webVR display and starts listening to display change events
  27511. * The onVRDisplayChangedObservable will be notified upon these changes
  27512. * @returns A promise containing a VRDisplay and if vr is supported
  27513. */
  27514. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27515. /**
  27516. * Call this function to switch to webVR mode
  27517. * Will do nothing if webVR is not supported or if there is no webVR device
  27518. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27519. */
  27520. enableVR(): void;
  27521. /**
  27522. * Call this function to leave webVR mode
  27523. * Will do nothing if webVR is not supported or if there is no webVR device
  27524. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27525. */
  27526. disableVR(): void;
  27527. private _onVRFullScreenTriggered;
  27528. private _getVRDisplaysAsync;
  27529. /**
  27530. * Binds the frame buffer to the specified texture.
  27531. * @param texture The texture to render to or null for the default canvas
  27532. * @param faceIndex The face of the texture to render to in case of cube texture
  27533. * @param requiredWidth The width of the target to render to
  27534. * @param requiredHeight The height of the target to render to
  27535. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27536. * @param depthStencilTexture The depth stencil texture to use to render
  27537. * @param lodLevel defines le lod level to bind to the frame buffer
  27538. */
  27539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27540. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27541. /**
  27542. * Unbind the current render target texture from the webGL context
  27543. * @param texture defines the render target texture to unbind
  27544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27546. */
  27547. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27548. /**
  27549. * Force the mipmap generation for the given render target texture
  27550. * @param texture defines the render target texture to use
  27551. */
  27552. generateMipMapsForCubemap(texture: InternalTexture): void;
  27553. /**
  27554. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27555. */
  27556. flushFramebuffer(): void;
  27557. /**
  27558. * Unbind the current render target and bind the default framebuffer
  27559. */
  27560. restoreDefaultFramebuffer(): void;
  27561. /**
  27562. * Create an uniform buffer
  27563. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27564. * @param elements defines the content of the uniform buffer
  27565. * @returns the webGL uniform buffer
  27566. */
  27567. createUniformBuffer(elements: FloatArray): DataBuffer;
  27568. /**
  27569. * Create a dynamic uniform buffer
  27570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27571. * @param elements defines the content of the uniform buffer
  27572. * @returns the webGL uniform buffer
  27573. */
  27574. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27575. /**
  27576. * Update an existing uniform buffer
  27577. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27578. * @param uniformBuffer defines the target uniform buffer
  27579. * @param elements defines the content to update
  27580. * @param offset defines the offset in the uniform buffer where update should start
  27581. * @param count defines the size of the data to update
  27582. */
  27583. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27584. private _resetVertexBufferBinding;
  27585. /**
  27586. * Creates a vertex buffer
  27587. * @param data the data for the vertex buffer
  27588. * @returns the new WebGL static buffer
  27589. */
  27590. createVertexBuffer(data: DataArray): DataBuffer;
  27591. /**
  27592. * Creates a dynamic vertex buffer
  27593. * @param data the data for the dynamic vertex buffer
  27594. * @returns the new WebGL dynamic buffer
  27595. */
  27596. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27597. /**
  27598. * Update a dynamic index buffer
  27599. * @param indexBuffer defines the target index buffer
  27600. * @param indices defines the data to update
  27601. * @param offset defines the offset in the target index buffer where update should start
  27602. */
  27603. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27604. /**
  27605. * Updates a dynamic vertex buffer.
  27606. * @param vertexBuffer the vertex buffer to update
  27607. * @param data the data used to update the vertex buffer
  27608. * @param byteOffset the byte offset of the data
  27609. * @param byteLength the byte length of the data
  27610. */
  27611. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27612. private _resetIndexBufferBinding;
  27613. /**
  27614. * Creates a new index buffer
  27615. * @param indices defines the content of the index buffer
  27616. * @param updatable defines if the index buffer must be updatable
  27617. * @returns a new webGL buffer
  27618. */
  27619. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27620. /**
  27621. * Bind a webGL buffer to the webGL context
  27622. * @param buffer defines the buffer to bind
  27623. */
  27624. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27625. /**
  27626. * Bind an uniform buffer to the current webGL context
  27627. * @param buffer defines the buffer to bind
  27628. */
  27629. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27630. /**
  27631. * Bind a buffer to the current webGL context at a given location
  27632. * @param buffer defines the buffer to bind
  27633. * @param location defines the index where to bind the buffer
  27634. */
  27635. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27636. /**
  27637. * Bind a specific block at a given index in a specific shader program
  27638. * @param pipelineContext defines the pipeline context to use
  27639. * @param blockName defines the block name
  27640. * @param index defines the index where to bind the block
  27641. */
  27642. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27643. private bindIndexBuffer;
  27644. private bindBuffer;
  27645. /**
  27646. * update the bound buffer with the given data
  27647. * @param data defines the data to update
  27648. */
  27649. updateArrayBuffer(data: Float32Array): void;
  27650. private _vertexAttribPointer;
  27651. private _bindIndexBufferWithCache;
  27652. private _bindVertexBuffersAttributes;
  27653. /**
  27654. * Records a vertex array object
  27655. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27656. * @param vertexBuffers defines the list of vertex buffers to store
  27657. * @param indexBuffer defines the index buffer to store
  27658. * @param effect defines the effect to store
  27659. * @returns the new vertex array object
  27660. */
  27661. recordVertexArrayObject(vertexBuffers: {
  27662. [key: string]: VertexBuffer;
  27663. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27664. /**
  27665. * Bind a specific vertex array object
  27666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27667. * @param vertexArrayObject defines the vertex array object to bind
  27668. * @param indexBuffer defines the index buffer to bind
  27669. */
  27670. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27671. /**
  27672. * Bind webGl buffers directly to the webGL context
  27673. * @param vertexBuffer defines the vertex buffer to bind
  27674. * @param indexBuffer defines the index buffer to bind
  27675. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27676. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27677. * @param effect defines the effect associated with the vertex buffer
  27678. */
  27679. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27680. private _unbindVertexArrayObject;
  27681. /**
  27682. * Bind a list of vertex buffers to the webGL context
  27683. * @param vertexBuffers defines the list of vertex buffers to bind
  27684. * @param indexBuffer defines the index buffer to bind
  27685. * @param effect defines the effect associated with the vertex buffers
  27686. */
  27687. bindBuffers(vertexBuffers: {
  27688. [key: string]: Nullable<VertexBuffer>;
  27689. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27690. /**
  27691. * Unbind all instance attributes
  27692. */
  27693. unbindInstanceAttributes(): void;
  27694. /**
  27695. * Release and free the memory of a vertex array object
  27696. * @param vao defines the vertex array object to delete
  27697. */
  27698. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27699. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27700. /**
  27701. * Creates a webGL buffer to use with instanciation
  27702. * @param capacity defines the size of the buffer
  27703. * @returns the webGL buffer
  27704. */
  27705. createInstancesBuffer(capacity: number): DataBuffer;
  27706. /**
  27707. * Delete a webGL buffer used with instanciation
  27708. * @param buffer defines the webGL buffer to delete
  27709. */
  27710. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27711. /**
  27712. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27713. * @param instancesBuffer defines the webGL buffer to update and bind
  27714. * @param data defines the data to store in the buffer
  27715. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27716. */
  27717. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27718. /**
  27719. * Apply all cached states (depth, culling, stencil and alpha)
  27720. */
  27721. applyStates(): void;
  27722. /**
  27723. * Send a draw order
  27724. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27725. * @param indexStart defines the starting index
  27726. * @param indexCount defines the number of index to draw
  27727. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27728. */
  27729. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27730. /**
  27731. * Draw a list of points
  27732. * @param verticesStart defines the index of first vertex to draw
  27733. * @param verticesCount defines the count of vertices to draw
  27734. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27735. */
  27736. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27737. /**
  27738. * Draw a list of unindexed primitives
  27739. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27740. * @param verticesStart defines the index of first vertex to draw
  27741. * @param verticesCount defines the count of vertices to draw
  27742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27743. */
  27744. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27745. /**
  27746. * Draw a list of indexed primitives
  27747. * @param fillMode defines the primitive to use
  27748. * @param indexStart defines the starting index
  27749. * @param indexCount defines the number of index to draw
  27750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27751. */
  27752. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27753. /**
  27754. * Draw a list of unindexed primitives
  27755. * @param fillMode defines the primitive to use
  27756. * @param verticesStart defines the index of first vertex to draw
  27757. * @param verticesCount defines the count of vertices to draw
  27758. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27759. */
  27760. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27761. private _drawMode;
  27762. /** @hidden */ releaseEffect(effect: Effect): void;
  27763. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27764. /**
  27765. * Create a new effect (used to store vertex/fragment shaders)
  27766. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27767. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27768. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27769. * @param samplers defines an array of string used to represent textures
  27770. * @param defines defines the string containing the defines to use to compile the shaders
  27771. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27772. * @param onCompiled defines a function to call when the effect creation is successful
  27773. * @param onError defines a function to call when the effect creation has failed
  27774. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27775. * @returns the new Effect
  27776. */
  27777. 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;
  27778. private _compileShader;
  27779. private _compileRawShader;
  27780. /**
  27781. * Directly creates a webGL program
  27782. * @param pipelineContext defines the pipeline context to attach to
  27783. * @param vertexCode defines the vertex shader code to use
  27784. * @param fragmentCode defines the fragment shader code to use
  27785. * @param context defines the webGL context to use (if not set, the current one will be used)
  27786. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27787. * @returns the new webGL program
  27788. */
  27789. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27790. /**
  27791. * Creates a webGL program
  27792. * @param pipelineContext defines the pipeline context to attach to
  27793. * @param vertexCode defines the vertex shader code to use
  27794. * @param fragmentCode defines the fragment shader code to use
  27795. * @param defines defines the string containing the defines to use to compile the shaders
  27796. * @param context defines the webGL context to use (if not set, the current one will be used)
  27797. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27798. * @returns the new webGL program
  27799. */
  27800. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27801. /**
  27802. * Creates a new pipeline context
  27803. * @returns the new pipeline
  27804. */
  27805. createPipelineContext(): WebGLPipelineContext;
  27806. private _createShaderProgram;
  27807. private _finalizePipelineContext;
  27808. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27809. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27810. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27811. /**
  27812. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27813. * @param pipelineContext defines the pipeline context to use
  27814. * @param uniformsNames defines the list of uniform names
  27815. * @returns an array of webGL uniform locations
  27816. */
  27817. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27818. /**
  27819. * Gets the lsit of active attributes for a given webGL program
  27820. * @param pipelineContext defines the pipeline context to use
  27821. * @param attributesNames defines the list of attribute names to get
  27822. * @returns an array of indices indicating the offset of each attribute
  27823. */
  27824. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27825. /**
  27826. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27827. * @param effect defines the effect to activate
  27828. */
  27829. enableEffect(effect: Nullable<Effect>): void;
  27830. /**
  27831. * Set the value of an uniform to an array of int32
  27832. * @param uniform defines the webGL uniform location where to store the value
  27833. * @param array defines the array of int32 to store
  27834. */
  27835. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27836. /**
  27837. * Set the value of an uniform to an array of int32 (stored as vec2)
  27838. * @param uniform defines the webGL uniform location where to store the value
  27839. * @param array defines the array of int32 to store
  27840. */
  27841. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27842. /**
  27843. * Set the value of an uniform to an array of int32 (stored as vec3)
  27844. * @param uniform defines the webGL uniform location where to store the value
  27845. * @param array defines the array of int32 to store
  27846. */
  27847. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27848. /**
  27849. * Set the value of an uniform to an array of int32 (stored as vec4)
  27850. * @param uniform defines the webGL uniform location where to store the value
  27851. * @param array defines the array of int32 to store
  27852. */
  27853. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27854. /**
  27855. * Set the value of an uniform to an array of float32
  27856. * @param uniform defines the webGL uniform location where to store the value
  27857. * @param array defines the array of float32 to store
  27858. */
  27859. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27860. /**
  27861. * Set the value of an uniform to an array of float32 (stored as vec2)
  27862. * @param uniform defines the webGL uniform location where to store the value
  27863. * @param array defines the array of float32 to store
  27864. */
  27865. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27866. /**
  27867. * Set the value of an uniform to an array of float32 (stored as vec3)
  27868. * @param uniform defines the webGL uniform location where to store the value
  27869. * @param array defines the array of float32 to store
  27870. */
  27871. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27872. /**
  27873. * Set the value of an uniform to an array of float32 (stored as vec4)
  27874. * @param uniform defines the webGL uniform location where to store the value
  27875. * @param array defines the array of float32 to store
  27876. */
  27877. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27878. /**
  27879. * Set the value of an uniform to an array of number
  27880. * @param uniform defines the webGL uniform location where to store the value
  27881. * @param array defines the array of number to store
  27882. */
  27883. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27884. /**
  27885. * Set the value of an uniform to an array of number (stored as vec2)
  27886. * @param uniform defines the webGL uniform location where to store the value
  27887. * @param array defines the array of number to store
  27888. */
  27889. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27890. /**
  27891. * Set the value of an uniform to an array of number (stored as vec3)
  27892. * @param uniform defines the webGL uniform location where to store the value
  27893. * @param array defines the array of number to store
  27894. */
  27895. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27896. /**
  27897. * Set the value of an uniform to an array of number (stored as vec4)
  27898. * @param uniform defines the webGL uniform location where to store the value
  27899. * @param array defines the array of number to store
  27900. */
  27901. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27902. /**
  27903. * Set the value of an uniform to an array of float32 (stored as matrices)
  27904. * @param uniform defines the webGL uniform location where to store the value
  27905. * @param matrices defines the array of float32 to store
  27906. */
  27907. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27908. /**
  27909. * Set the value of an uniform to a matrix
  27910. * @param uniform defines the webGL uniform location where to store the value
  27911. * @param matrix defines the matrix to store
  27912. */
  27913. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27914. /**
  27915. * Set the value of an uniform to a matrix (3x3)
  27916. * @param uniform defines the webGL uniform location where to store the value
  27917. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27918. */
  27919. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27920. /**
  27921. * Set the value of an uniform to a matrix (2x2)
  27922. * @param uniform defines the webGL uniform location where to store the value
  27923. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27924. */
  27925. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27926. /**
  27927. * Set the value of an uniform to a number (int)
  27928. * @param uniform defines the webGL uniform location where to store the value
  27929. * @param value defines the int number to store
  27930. */
  27931. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27932. /**
  27933. * Set the value of an uniform to a number (float)
  27934. * @param uniform defines the webGL uniform location where to store the value
  27935. * @param value defines the float number to store
  27936. */
  27937. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27938. /**
  27939. * Set the value of an uniform to a vec2
  27940. * @param uniform defines the webGL uniform location where to store the value
  27941. * @param x defines the 1st component of the value
  27942. * @param y defines the 2nd component of the value
  27943. */
  27944. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27945. /**
  27946. * Set the value of an uniform to a vec3
  27947. * @param uniform defines the webGL uniform location where to store the value
  27948. * @param x defines the 1st component of the value
  27949. * @param y defines the 2nd component of the value
  27950. * @param z defines the 3rd component of the value
  27951. */
  27952. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27953. /**
  27954. * Set the value of an uniform to a boolean
  27955. * @param uniform defines the webGL uniform location where to store the value
  27956. * @param bool defines the boolean to store
  27957. */
  27958. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27959. /**
  27960. * Set the value of an uniform to a vec4
  27961. * @param uniform defines the webGL uniform location where to store the value
  27962. * @param x defines the 1st component of the value
  27963. * @param y defines the 2nd component of the value
  27964. * @param z defines the 3rd component of the value
  27965. * @param w defines the 4th component of the value
  27966. */
  27967. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27968. /**
  27969. * Set the value of an uniform to a Color3
  27970. * @param uniform defines the webGL uniform location where to store the value
  27971. * @param color3 defines the color to store
  27972. */
  27973. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27974. /**
  27975. * Set the value of an uniform to a Color3 and an alpha value
  27976. * @param uniform defines the webGL uniform location where to store the value
  27977. * @param color3 defines the color to store
  27978. * @param alpha defines the alpha component to store
  27979. */
  27980. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27981. /**
  27982. * Sets a Color4 on a uniform variable
  27983. * @param uniform defines the uniform location
  27984. * @param color4 defines the value to be set
  27985. */
  27986. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27987. /**
  27988. * Set various states to the webGL context
  27989. * @param culling defines backface culling state
  27990. * @param zOffset defines the value to apply to zOffset (0 by default)
  27991. * @param force defines if states must be applied even if cache is up to date
  27992. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27993. */
  27994. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27995. /**
  27996. * Set the z offset to apply to current rendering
  27997. * @param value defines the offset to apply
  27998. */
  27999. setZOffset(value: number): void;
  28000. /**
  28001. * Gets the current value of the zOffset
  28002. * @returns the current zOffset state
  28003. */
  28004. getZOffset(): number;
  28005. /**
  28006. * Enable or disable depth buffering
  28007. * @param enable defines the state to set
  28008. */
  28009. setDepthBuffer(enable: boolean): void;
  28010. /**
  28011. * Gets a boolean indicating if depth writing is enabled
  28012. * @returns the current depth writing state
  28013. */
  28014. getDepthWrite(): boolean;
  28015. /**
  28016. * Enable or disable depth writing
  28017. * @param enable defines the state to set
  28018. */
  28019. setDepthWrite(enable: boolean): void;
  28020. /**
  28021. * Enable or disable color writing
  28022. * @param enable defines the state to set
  28023. */
  28024. setColorWrite(enable: boolean): void;
  28025. /**
  28026. * Gets a boolean indicating if color writing is enabled
  28027. * @returns the current color writing state
  28028. */
  28029. getColorWrite(): boolean;
  28030. /**
  28031. * Sets alpha constants used by some alpha blending modes
  28032. * @param r defines the red component
  28033. * @param g defines the green component
  28034. * @param b defines the blue component
  28035. * @param a defines the alpha component
  28036. */
  28037. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28038. /**
  28039. * Sets the current alpha mode
  28040. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28041. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28042. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28043. */
  28044. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28045. /**
  28046. * Gets the current alpha mode
  28047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28048. * @returns the current alpha mode
  28049. */
  28050. getAlphaMode(): number;
  28051. /**
  28052. * Clears the list of texture accessible through engine.
  28053. * This can help preventing texture load conflict due to name collision.
  28054. */
  28055. clearInternalTexturesCache(): void;
  28056. /**
  28057. * Force the entire cache to be cleared
  28058. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28059. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28060. */
  28061. wipeCaches(bruteForce?: boolean): void;
  28062. /**
  28063. * Set the compressed texture format to use, based on the formats you have, and the formats
  28064. * supported by the hardware / browser.
  28065. *
  28066. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28067. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28068. * to API arguments needed to compressed textures. This puts the burden on the container
  28069. * generator to house the arcane code for determining these for current & future formats.
  28070. *
  28071. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28072. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28073. *
  28074. * Note: The result of this call is not taken into account when a texture is base64.
  28075. *
  28076. * @param formatsAvailable defines the list of those format families you have created
  28077. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28078. *
  28079. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28080. * @returns The extension selected.
  28081. */
  28082. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28083. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28084. min: number;
  28085. mag: number;
  28086. };
  28087. /** @hidden */ createTexture(): WebGLTexture;
  28088. /**
  28089. * Usually called from Texture.ts.
  28090. * Passed information to create a WebGLTexture
  28091. * @param urlArg defines a value which contains one of the following:
  28092. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28093. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28094. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28095. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28096. * @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)
  28097. * @param scene needed for loading to the correct scene
  28098. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28099. * @param onLoad optional callback to be called upon successful completion
  28100. * @param onError optional callback to be called upon failure
  28101. * @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
  28102. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28103. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28104. * @param forcedExtension defines the extension to use to pick the right loader
  28105. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28106. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28107. */
  28108. 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;
  28109. private _rescaleTexture;
  28110. private _unpackFlipYCached;
  28111. /**
  28112. * In case you are sharing the context with other applications, it might
  28113. * be interested to not cache the unpack flip y state to ensure a consistent
  28114. * value would be set.
  28115. */
  28116. enableUnpackFlipYCached: boolean;
  28117. /** @hidden */ unpackFlipY(value: boolean): void;
  28118. /** @hidden */ getUnpackAlignement(): number;
  28119. /**
  28120. * Creates a dynamic texture
  28121. * @param width defines the width of the texture
  28122. * @param height defines the height of the texture
  28123. * @param generateMipMaps defines if the engine should generate the mip levels
  28124. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28125. * @returns the dynamic texture inside an InternalTexture
  28126. */
  28127. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28128. /**
  28129. * Update the sampling mode of a given texture
  28130. * @param samplingMode defines the required sampling mode
  28131. * @param texture defines the texture to update
  28132. */
  28133. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28134. /**
  28135. * Update the content of a dynamic texture
  28136. * @param texture defines the texture to update
  28137. * @param canvas defines the canvas containing the source
  28138. * @param invertY defines if data must be stored with Y axis inverted
  28139. * @param premulAlpha defines if alpha is stored as premultiplied
  28140. * @param format defines the format of the data
  28141. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28142. */
  28143. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28144. /**
  28145. * Update a video texture
  28146. * @param texture defines the texture to update
  28147. * @param video defines the video element to use
  28148. * @param invertY defines if data must be stored with Y axis inverted
  28149. */
  28150. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28151. /**
  28152. * Updates a depth texture Comparison Mode and Function.
  28153. * If the comparison Function is equal to 0, the mode will be set to none.
  28154. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28155. * @param texture The texture to set the comparison function for
  28156. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28157. */
  28158. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28159. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28160. width: number;
  28161. height: number;
  28162. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28163. /**
  28164. * Creates a depth stencil texture.
  28165. * This is only available in WebGL 2 or with the depth texture extension available.
  28166. * @param size The size of face edge in the texture.
  28167. * @param options The options defining the texture.
  28168. * @returns The texture
  28169. */
  28170. createDepthStencilTexture(size: number | {
  28171. width: number;
  28172. height: number;
  28173. }, options: DepthTextureCreationOptions): InternalTexture;
  28174. /**
  28175. * Creates a depth stencil texture.
  28176. * This is only available in WebGL 2 or with the depth texture extension available.
  28177. * @param size The size of face edge in the texture.
  28178. * @param options The options defining the texture.
  28179. * @returns The texture
  28180. */
  28181. private _createDepthStencilTexture;
  28182. /**
  28183. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28184. * @param renderTarget The render target to set the frame buffer for
  28185. */
  28186. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28187. /**
  28188. * Creates a new render target texture
  28189. * @param size defines the size of the texture
  28190. * @param options defines the options used to create the texture
  28191. * @returns a new render target texture stored in an InternalTexture
  28192. */
  28193. createRenderTargetTexture(size: number | {
  28194. width: number;
  28195. height: number;
  28196. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28197. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28198. /**
  28199. * Updates the sample count of a render target texture
  28200. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28201. * @param texture defines the texture to update
  28202. * @param samples defines the sample count to set
  28203. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28204. */
  28205. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28206. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28207. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28208. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28209. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28210. /**
  28211. * @hidden
  28212. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28213. private _prepareWebGLTextureContinuation;
  28214. private _prepareWebGLTexture;
  28215. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28216. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28217. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28218. private setProgram;
  28219. private _boundUniforms;
  28220. /**
  28221. * Binds an effect to the webGL context
  28222. * @param effect defines the effect to bind
  28223. */
  28224. bindSamplers(effect: Effect): void;
  28225. private _activateCurrentTexture;
  28226. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28227. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28228. /**
  28229. * Sets a texture to the webGL context from a postprocess
  28230. * @param channel defines the channel to use
  28231. * @param postProcess defines the source postprocess
  28232. */
  28233. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28234. /**
  28235. * Binds the output of the passed in post process to the texture channel specified
  28236. * @param channel The channel the texture should be bound to
  28237. * @param postProcess The post process which's output should be bound
  28238. */
  28239. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28240. /**
  28241. * Unbind all textures from the webGL context
  28242. */
  28243. unbindAllTextures(): void;
  28244. /**
  28245. * Sets a texture to the according uniform.
  28246. * @param channel The texture channel
  28247. * @param uniform The uniform to set
  28248. * @param texture The texture to apply
  28249. */
  28250. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28251. /**
  28252. * Sets a depth stencil texture from a render target to the according uniform.
  28253. * @param channel The texture channel
  28254. * @param uniform The uniform to set
  28255. * @param texture The render target texture containing the depth stencil texture to apply
  28256. */
  28257. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28258. private _bindSamplerUniformToChannel;
  28259. private _getTextureWrapMode;
  28260. private _setTexture;
  28261. /**
  28262. * Sets an array of texture to the webGL context
  28263. * @param channel defines the channel where the texture array must be set
  28264. * @param uniform defines the associated uniform location
  28265. * @param textures defines the array of textures to bind
  28266. */
  28267. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28268. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28269. private _setTextureParameterFloat;
  28270. private _setTextureParameterInteger;
  28271. /**
  28272. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28273. * @param x defines the x coordinate of the rectangle where pixels must be read
  28274. * @param y defines the y coordinate of the rectangle where pixels must be read
  28275. * @param width defines the width of the rectangle where pixels must be read
  28276. * @param height defines the height of the rectangle where pixels must be read
  28277. * @returns a Uint8Array containing RGBA colors
  28278. */
  28279. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28280. /**
  28281. * Add an externaly attached data from its key.
  28282. * This method call will fail and return false, if such key already exists.
  28283. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28284. * @param key the unique key that identifies the data
  28285. * @param data the data object to associate to the key for this Engine instance
  28286. * @return true if no such key were already present and the data was added successfully, false otherwise
  28287. */
  28288. addExternalData<T>(key: string, data: T): boolean;
  28289. /**
  28290. * Get an externaly attached data from its key
  28291. * @param key the unique key that identifies the data
  28292. * @return the associated data, if present (can be null), or undefined if not present
  28293. */
  28294. getExternalData<T>(key: string): T;
  28295. /**
  28296. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28297. * @param key the unique key that identifies the data
  28298. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28299. * @return the associated data, can be null if the factory returned null.
  28300. */
  28301. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28302. /**
  28303. * Remove an externaly attached data from the Engine instance
  28304. * @param key the unique key that identifies the data
  28305. * @return true if the data was successfully removed, false if it doesn't exist
  28306. */
  28307. removeExternalData(key: string): boolean;
  28308. /**
  28309. * Unbind all vertex attributes from the webGL context
  28310. */
  28311. unbindAllAttributes(): void;
  28312. /**
  28313. * 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
  28314. */
  28315. releaseEffects(): void;
  28316. /**
  28317. * Dispose and release all associated resources
  28318. */
  28319. dispose(): void;
  28320. /**
  28321. * Display the loading screen
  28322. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28323. */
  28324. displayLoadingUI(): void;
  28325. /**
  28326. * Hide the loading screen
  28327. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28328. */
  28329. hideLoadingUI(): void;
  28330. /**
  28331. * Gets the current loading screen object
  28332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28333. */
  28334. /**
  28335. * Sets the current loading screen object
  28336. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28337. */
  28338. loadingScreen: ILoadingScreen;
  28339. /**
  28340. * Sets the current loading screen text
  28341. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28342. */
  28343. loadingUIText: string;
  28344. /**
  28345. * Sets the current loading screen background color
  28346. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28347. */
  28348. loadingUIBackgroundColor: string;
  28349. /**
  28350. * Attach a new callback raised when context lost event is fired
  28351. * @param callback defines the callback to call
  28352. */
  28353. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28354. /**
  28355. * Attach a new callback raised when context restored event is fired
  28356. * @param callback defines the callback to call
  28357. */
  28358. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28359. /**
  28360. * Gets the source code of the vertex shader associated with a specific webGL program
  28361. * @param program defines the program to use
  28362. * @returns a string containing the source code of the vertex shader associated with the program
  28363. */
  28364. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28365. /**
  28366. * Gets the source code of the fragment shader associated with a specific webGL program
  28367. * @param program defines the program to use
  28368. * @returns a string containing the source code of the fragment shader associated with the program
  28369. */
  28370. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28371. /**
  28372. * Get the current error code of the webGL context
  28373. * @returns the error code
  28374. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28375. */
  28376. getError(): number;
  28377. /**
  28378. * Gets the current framerate
  28379. * @returns a number representing the framerate
  28380. */
  28381. getFps(): number;
  28382. /**
  28383. * Gets the time spent between current and previous frame
  28384. * @returns a number representing the delta time in ms
  28385. */
  28386. getDeltaTime(): number;
  28387. private _measureFps;
  28388. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28389. private _canRenderToFloatFramebuffer;
  28390. private _canRenderToHalfFloatFramebuffer;
  28391. private _canRenderToFramebuffer;
  28392. /** @hidden */ getWebGLTextureType(type: number): number;
  28393. /** @hidden */ getInternalFormat(format: number): number;
  28394. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28395. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28396. /** @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;
  28397. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28398. /**
  28399. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28400. * @returns true if the engine can be created
  28401. * @ignorenaming
  28402. */
  28403. static isSupported(): boolean;
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. /**
  28408. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28409. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28410. */
  28411. export class EffectFallbacks {
  28412. private _defines;
  28413. private _currentRank;
  28414. private _maxRank;
  28415. private _mesh;
  28416. /**
  28417. * Removes the fallback from the bound mesh.
  28418. */
  28419. unBindMesh(): void;
  28420. /**
  28421. * Adds a fallback on the specified property.
  28422. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28423. * @param define The name of the define in the shader
  28424. */
  28425. addFallback(rank: number, define: string): void;
  28426. /**
  28427. * Sets the mesh to use CPU skinning when needing to fallback.
  28428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28429. * @param mesh The mesh to use the fallbacks.
  28430. */
  28431. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28432. /**
  28433. * Checks to see if more fallbacks are still availible.
  28434. */
  28435. readonly isMoreFallbacks: boolean;
  28436. /**
  28437. * Removes the defines that shoould be removed when falling back.
  28438. * @param currentDefines defines the current define statements for the shader.
  28439. * @param effect defines the current effect we try to compile
  28440. * @returns The resulting defines with defines of the current rank removed.
  28441. */
  28442. reduce(currentDefines: string, effect: Effect): string;
  28443. }
  28444. /**
  28445. * Options to be used when creating an effect.
  28446. */
  28447. export class EffectCreationOptions {
  28448. /**
  28449. * Atrributes that will be used in the shader.
  28450. */
  28451. attributes: string[];
  28452. /**
  28453. * Uniform varible names that will be set in the shader.
  28454. */
  28455. uniformsNames: string[];
  28456. /**
  28457. * Uniform buffer varible names that will be set in the shader.
  28458. */
  28459. uniformBuffersNames: string[];
  28460. /**
  28461. * Sampler texture variable names that will be set in the shader.
  28462. */
  28463. samplers: string[];
  28464. /**
  28465. * Define statements that will be set in the shader.
  28466. */
  28467. defines: any;
  28468. /**
  28469. * Possible fallbacks for this effect to improve performance when needed.
  28470. */
  28471. fallbacks: Nullable<EffectFallbacks>;
  28472. /**
  28473. * Callback that will be called when the shader is compiled.
  28474. */
  28475. onCompiled: Nullable<(effect: Effect) => void>;
  28476. /**
  28477. * Callback that will be called if an error occurs during shader compilation.
  28478. */
  28479. onError: Nullable<(effect: Effect, errors: string) => void>;
  28480. /**
  28481. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28482. */
  28483. indexParameters: any;
  28484. /**
  28485. * Max number of lights that can be used in the shader.
  28486. */
  28487. maxSimultaneousLights: number;
  28488. /**
  28489. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28490. */
  28491. transformFeedbackVaryings: Nullable<string[]>;
  28492. }
  28493. /**
  28494. * Effect containing vertex and fragment shader that can be executed on an object.
  28495. */
  28496. export class Effect implements IDisposable {
  28497. /**
  28498. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28499. */
  28500. static ShadersRepository: string;
  28501. /**
  28502. * Name of the effect.
  28503. */
  28504. name: any;
  28505. /**
  28506. * String container all the define statements that should be set on the shader.
  28507. */
  28508. defines: string;
  28509. /**
  28510. * Callback that will be called when the shader is compiled.
  28511. */
  28512. onCompiled: Nullable<(effect: Effect) => void>;
  28513. /**
  28514. * Callback that will be called if an error occurs during shader compilation.
  28515. */
  28516. onError: Nullable<(effect: Effect, errors: string) => void>;
  28517. /**
  28518. * Callback that will be called when effect is bound.
  28519. */
  28520. onBind: Nullable<(effect: Effect) => void>;
  28521. /**
  28522. * Unique ID of the effect.
  28523. */
  28524. uniqueId: number;
  28525. /**
  28526. * Observable that will be called when the shader is compiled.
  28527. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28528. */
  28529. onCompileObservable: Observable<Effect>;
  28530. /**
  28531. * Observable that will be called if an error occurs during shader compilation.
  28532. */
  28533. onErrorObservable: Observable<Effect>;
  28534. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28535. /**
  28536. * Observable that will be called when effect is bound.
  28537. */
  28538. readonly onBindObservable: Observable<Effect>;
  28539. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28540. private static _uniqueIdSeed;
  28541. private _engine;
  28542. private _uniformBuffersNames;
  28543. private _uniformsNames;
  28544. private _samplerList;
  28545. private _samplers;
  28546. private _isReady;
  28547. private _compilationError;
  28548. private _attributesNames;
  28549. private _attributes;
  28550. private _uniforms;
  28551. /**
  28552. * Key for the effect.
  28553. * @hidden
  28554. */ key: string;
  28555. private _indexParameters;
  28556. private _fallbacks;
  28557. private _vertexSourceCode;
  28558. private _fragmentSourceCode;
  28559. private _vertexSourceCodeOverride;
  28560. private _fragmentSourceCodeOverride;
  28561. private _transformFeedbackVaryings;
  28562. /**
  28563. * Compiled shader to webGL program.
  28564. * @hidden
  28565. */ pipelineContext: IPipelineContext;
  28566. private _valueCache;
  28567. private static _baseCache;
  28568. /**
  28569. * Instantiates an effect.
  28570. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28571. * @param baseName Name of the effect.
  28572. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28573. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28574. * @param samplers List of sampler variables that will be passed to the shader.
  28575. * @param engine Engine to be used to render the effect
  28576. * @param defines Define statements to be added to the shader.
  28577. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28578. * @param onCompiled Callback that will be called when the shader is compiled.
  28579. * @param onError Callback that will be called if an error occurs during shader compilation.
  28580. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28581. */
  28582. 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);
  28583. /**
  28584. * Unique key for this effect
  28585. */
  28586. readonly key: string;
  28587. /**
  28588. * If the effect has been compiled and prepared.
  28589. * @returns if the effect is compiled and prepared.
  28590. */
  28591. isReady(): boolean;
  28592. /**
  28593. * The engine the effect was initialized with.
  28594. * @returns the engine.
  28595. */
  28596. getEngine(): Engine;
  28597. /**
  28598. * The pipeline context for this effect
  28599. * @returns the associated pipeline context
  28600. */
  28601. getPipelineContext(): IPipelineContext;
  28602. /**
  28603. * The set of names of attribute variables for the shader.
  28604. * @returns An array of attribute names.
  28605. */
  28606. getAttributesNames(): string[];
  28607. /**
  28608. * Returns the attribute at the given index.
  28609. * @param index The index of the attribute.
  28610. * @returns The location of the attribute.
  28611. */
  28612. getAttributeLocation(index: number): number;
  28613. /**
  28614. * Returns the attribute based on the name of the variable.
  28615. * @param name of the attribute to look up.
  28616. * @returns the attribute location.
  28617. */
  28618. getAttributeLocationByName(name: string): number;
  28619. /**
  28620. * The number of attributes.
  28621. * @returns the numnber of attributes.
  28622. */
  28623. getAttributesCount(): number;
  28624. /**
  28625. * Gets the index of a uniform variable.
  28626. * @param uniformName of the uniform to look up.
  28627. * @returns the index.
  28628. */
  28629. getUniformIndex(uniformName: string): number;
  28630. /**
  28631. * Returns the attribute based on the name of the variable.
  28632. * @param uniformName of the uniform to look up.
  28633. * @returns the location of the uniform.
  28634. */
  28635. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28636. /**
  28637. * Returns an array of sampler variable names
  28638. * @returns The array of sampler variable neames.
  28639. */
  28640. getSamplers(): string[];
  28641. /**
  28642. * The error from the last compilation.
  28643. * @returns the error string.
  28644. */
  28645. getCompilationError(): string;
  28646. /**
  28647. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28648. * @param func The callback to be used.
  28649. */
  28650. executeWhenCompiled(func: (effect: Effect) => void): void;
  28651. private _checkIsReady;
  28652. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28653. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28654. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28655. private _processShaderConversion;
  28656. private _processIncludes;
  28657. private _processPrecision;
  28658. /**
  28659. * Recompiles the webGL program
  28660. * @param vertexSourceCode The source code for the vertex shader.
  28661. * @param fragmentSourceCode The source code for the fragment shader.
  28662. * @param onCompiled Callback called when completed.
  28663. * @param onError Callback called on error.
  28664. * @hidden
  28665. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28666. /**
  28667. * Prepares the effect
  28668. * @hidden
  28669. */ prepareEffect(): void;
  28670. /**
  28671. * Checks if the effect is supported. (Must be called after compilation)
  28672. */
  28673. readonly isSupported: boolean;
  28674. /**
  28675. * Binds a texture to the engine to be used as output of the shader.
  28676. * @param channel Name of the output variable.
  28677. * @param texture Texture to bind.
  28678. * @hidden
  28679. */ bindTexture(channel: string, texture: InternalTexture): void;
  28680. /**
  28681. * Sets a texture on the engine to be used in the shader.
  28682. * @param channel Name of the sampler variable.
  28683. * @param texture Texture to set.
  28684. */
  28685. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28686. /**
  28687. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28688. * @param channel Name of the sampler variable.
  28689. * @param texture Texture to set.
  28690. */
  28691. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28692. /**
  28693. * Sets an array of textures on the engine to be used in the shader.
  28694. * @param channel Name of the variable.
  28695. * @param textures Textures to set.
  28696. */
  28697. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28698. /**
  28699. * 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)
  28700. * @param channel Name of the sampler variable.
  28701. * @param postProcess Post process to get the input texture from.
  28702. */
  28703. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28704. /**
  28705. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28706. * 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)
  28707. * @param channel Name of the sampler variable.
  28708. * @param postProcess Post process to get the output texture from.
  28709. */
  28710. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28711. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28712. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28713. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28714. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28715. /**
  28716. * Binds a buffer to a uniform.
  28717. * @param buffer Buffer to bind.
  28718. * @param name Name of the uniform variable to bind to.
  28719. */
  28720. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28721. /**
  28722. * Binds block to a uniform.
  28723. * @param blockName Name of the block to bind.
  28724. * @param index Index to bind.
  28725. */
  28726. bindUniformBlock(blockName: string, index: number): void;
  28727. /**
  28728. * Sets an interger value on a uniform variable.
  28729. * @param uniformName Name of the variable.
  28730. * @param value Value to be set.
  28731. * @returns this effect.
  28732. */
  28733. setInt(uniformName: string, value: number): Effect;
  28734. /**
  28735. * Sets an int array on a uniform variable.
  28736. * @param uniformName Name of the variable.
  28737. * @param array array to be set.
  28738. * @returns this effect.
  28739. */
  28740. setIntArray(uniformName: string, array: Int32Array): Effect;
  28741. /**
  28742. * 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)
  28743. * @param uniformName Name of the variable.
  28744. * @param array array to be set.
  28745. * @returns this effect.
  28746. */
  28747. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28748. /**
  28749. * 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)
  28750. * @param uniformName Name of the variable.
  28751. * @param array array to be set.
  28752. * @returns this effect.
  28753. */
  28754. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28755. /**
  28756. * 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)
  28757. * @param uniformName Name of the variable.
  28758. * @param array array to be set.
  28759. * @returns this effect.
  28760. */
  28761. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28762. /**
  28763. * Sets an float array on a uniform variable.
  28764. * @param uniformName Name of the variable.
  28765. * @param array array to be set.
  28766. * @returns this effect.
  28767. */
  28768. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28769. /**
  28770. * 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)
  28771. * @param uniformName Name of the variable.
  28772. * @param array array to be set.
  28773. * @returns this effect.
  28774. */
  28775. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28776. /**
  28777. * 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)
  28778. * @param uniformName Name of the variable.
  28779. * @param array array to be set.
  28780. * @returns this effect.
  28781. */
  28782. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28783. /**
  28784. * 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)
  28785. * @param uniformName Name of the variable.
  28786. * @param array array to be set.
  28787. * @returns this effect.
  28788. */
  28789. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28790. /**
  28791. * Sets an array on a uniform variable.
  28792. * @param uniformName Name of the variable.
  28793. * @param array array to be set.
  28794. * @returns this effect.
  28795. */
  28796. setArray(uniformName: string, array: number[]): Effect;
  28797. /**
  28798. * 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)
  28799. * @param uniformName Name of the variable.
  28800. * @param array array to be set.
  28801. * @returns this effect.
  28802. */
  28803. setArray2(uniformName: string, array: number[]): Effect;
  28804. /**
  28805. * 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)
  28806. * @param uniformName Name of the variable.
  28807. * @param array array to be set.
  28808. * @returns this effect.
  28809. */
  28810. setArray3(uniformName: string, array: number[]): Effect;
  28811. /**
  28812. * 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)
  28813. * @param uniformName Name of the variable.
  28814. * @param array array to be set.
  28815. * @returns this effect.
  28816. */
  28817. setArray4(uniformName: string, array: number[]): Effect;
  28818. /**
  28819. * Sets matrices on a uniform variable.
  28820. * @param uniformName Name of the variable.
  28821. * @param matrices matrices to be set.
  28822. * @returns this effect.
  28823. */
  28824. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28825. /**
  28826. * Sets matrix on a uniform variable.
  28827. * @param uniformName Name of the variable.
  28828. * @param matrix matrix to be set.
  28829. * @returns this effect.
  28830. */
  28831. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28832. /**
  28833. * 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)
  28834. * @param uniformName Name of the variable.
  28835. * @param matrix matrix to be set.
  28836. * @returns this effect.
  28837. */
  28838. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28839. /**
  28840. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28841. * @param uniformName Name of the variable.
  28842. * @param matrix matrix to be set.
  28843. * @returns this effect.
  28844. */
  28845. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28846. /**
  28847. * Sets a float on a uniform variable.
  28848. * @param uniformName Name of the variable.
  28849. * @param value value to be set.
  28850. * @returns this effect.
  28851. */
  28852. setFloat(uniformName: string, value: number): Effect;
  28853. /**
  28854. * Sets a boolean on a uniform variable.
  28855. * @param uniformName Name of the variable.
  28856. * @param bool value to be set.
  28857. * @returns this effect.
  28858. */
  28859. setBool(uniformName: string, bool: boolean): Effect;
  28860. /**
  28861. * Sets a Vector2 on a uniform variable.
  28862. * @param uniformName Name of the variable.
  28863. * @param vector2 vector2 to be set.
  28864. * @returns this effect.
  28865. */
  28866. setVector2(uniformName: string, vector2: Vector2): Effect;
  28867. /**
  28868. * Sets a float2 on a uniform variable.
  28869. * @param uniformName Name of the variable.
  28870. * @param x First float in float2.
  28871. * @param y Second float in float2.
  28872. * @returns this effect.
  28873. */
  28874. setFloat2(uniformName: string, x: number, y: number): Effect;
  28875. /**
  28876. * Sets a Vector3 on a uniform variable.
  28877. * @param uniformName Name of the variable.
  28878. * @param vector3 Value to be set.
  28879. * @returns this effect.
  28880. */
  28881. setVector3(uniformName: string, vector3: Vector3): Effect;
  28882. /**
  28883. * Sets a float3 on a uniform variable.
  28884. * @param uniformName Name of the variable.
  28885. * @param x First float in float3.
  28886. * @param y Second float in float3.
  28887. * @param z Third float in float3.
  28888. * @returns this effect.
  28889. */
  28890. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28891. /**
  28892. * Sets a Vector4 on a uniform variable.
  28893. * @param uniformName Name of the variable.
  28894. * @param vector4 Value to be set.
  28895. * @returns this effect.
  28896. */
  28897. setVector4(uniformName: string, vector4: Vector4): Effect;
  28898. /**
  28899. * Sets a float4 on a uniform variable.
  28900. * @param uniformName Name of the variable.
  28901. * @param x First float in float4.
  28902. * @param y Second float in float4.
  28903. * @param z Third float in float4.
  28904. * @param w Fourth float in float4.
  28905. * @returns this effect.
  28906. */
  28907. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28908. /**
  28909. * Sets a Color3 on a uniform variable.
  28910. * @param uniformName Name of the variable.
  28911. * @param color3 Value to be set.
  28912. * @returns this effect.
  28913. */
  28914. setColor3(uniformName: string, color3: Color3): Effect;
  28915. /**
  28916. * Sets a Color4 on a uniform variable.
  28917. * @param uniformName Name of the variable.
  28918. * @param color3 Value to be set.
  28919. * @param alpha Alpha value to be set.
  28920. * @returns this effect.
  28921. */
  28922. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28923. /**
  28924. * Sets a Color4 on a uniform variable
  28925. * @param uniformName defines the name of the variable
  28926. * @param color4 defines the value to be set
  28927. * @returns this effect.
  28928. */
  28929. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28930. /** Release all associated resources */
  28931. dispose(): void;
  28932. /**
  28933. * This function will add a new shader to the shader store
  28934. * @param name the name of the shader
  28935. * @param pixelShader optional pixel shader content
  28936. * @param vertexShader optional vertex shader content
  28937. */
  28938. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28939. /**
  28940. * Store of each shader (The can be looked up using effect.key)
  28941. */
  28942. static ShadersStore: {
  28943. [key: string]: string;
  28944. };
  28945. /**
  28946. * Store of each included file for a shader (The can be looked up using effect.key)
  28947. */
  28948. static IncludesShadersStore: {
  28949. [key: string]: string;
  28950. };
  28951. /**
  28952. * Resets the cache of effects.
  28953. */
  28954. static ResetCache(): void;
  28955. }
  28956. }
  28957. declare module BABYLON {
  28958. /**
  28959. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28960. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28961. * 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;
  28962. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28963. */
  28964. export class ColorCurves {
  28965. private _dirty;
  28966. private _tempColor;
  28967. private _globalCurve;
  28968. private _highlightsCurve;
  28969. private _midtonesCurve;
  28970. private _shadowsCurve;
  28971. private _positiveCurve;
  28972. private _negativeCurve;
  28973. private _globalHue;
  28974. private _globalDensity;
  28975. private _globalSaturation;
  28976. private _globalExposure;
  28977. /**
  28978. * Gets the global Hue value.
  28979. * 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).
  28980. */
  28981. /**
  28982. * Sets the global Hue value.
  28983. * 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).
  28984. */
  28985. globalHue: number;
  28986. /**
  28987. * Gets the global Density value.
  28988. * 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.
  28989. * Values less than zero provide a filter of opposite hue.
  28990. */
  28991. /**
  28992. * Sets the global Density value.
  28993. * 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.
  28994. * Values less than zero provide a filter of opposite hue.
  28995. */
  28996. globalDensity: number;
  28997. /**
  28998. * Gets the global Saturation value.
  28999. * 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.
  29000. */
  29001. /**
  29002. * Sets the global Saturation value.
  29003. * 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.
  29004. */
  29005. globalSaturation: number;
  29006. /**
  29007. * Gets the global Exposure value.
  29008. * 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.
  29009. */
  29010. /**
  29011. * Sets the global Exposure value.
  29012. * 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.
  29013. */
  29014. globalExposure: number;
  29015. private _highlightsHue;
  29016. private _highlightsDensity;
  29017. private _highlightsSaturation;
  29018. private _highlightsExposure;
  29019. /**
  29020. * Gets the highlights Hue value.
  29021. * 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).
  29022. */
  29023. /**
  29024. * Sets the highlights Hue value.
  29025. * 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).
  29026. */
  29027. highlightsHue: number;
  29028. /**
  29029. * Gets the highlights Density value.
  29030. * 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.
  29031. * Values less than zero provide a filter of opposite hue.
  29032. */
  29033. /**
  29034. * Sets the highlights Density value.
  29035. * 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.
  29036. * Values less than zero provide a filter of opposite hue.
  29037. */
  29038. highlightsDensity: number;
  29039. /**
  29040. * Gets the highlights Saturation value.
  29041. * 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.
  29042. */
  29043. /**
  29044. * Sets the highlights Saturation value.
  29045. * 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.
  29046. */
  29047. highlightsSaturation: number;
  29048. /**
  29049. * Gets the highlights Exposure value.
  29050. * 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.
  29051. */
  29052. /**
  29053. * Sets the highlights Exposure value.
  29054. * 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.
  29055. */
  29056. highlightsExposure: number;
  29057. private _midtonesHue;
  29058. private _midtonesDensity;
  29059. private _midtonesSaturation;
  29060. private _midtonesExposure;
  29061. /**
  29062. * Gets the midtones Hue value.
  29063. * 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).
  29064. */
  29065. /**
  29066. * Sets the midtones Hue value.
  29067. * 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).
  29068. */
  29069. midtonesHue: number;
  29070. /**
  29071. * Gets the midtones Density value.
  29072. * 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.
  29073. * Values less than zero provide a filter of opposite hue.
  29074. */
  29075. /**
  29076. * Sets the midtones Density value.
  29077. * 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.
  29078. * Values less than zero provide a filter of opposite hue.
  29079. */
  29080. midtonesDensity: number;
  29081. /**
  29082. * Gets the midtones Saturation value.
  29083. * 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.
  29084. */
  29085. /**
  29086. * Sets the midtones Saturation value.
  29087. * 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.
  29088. */
  29089. midtonesSaturation: number;
  29090. /**
  29091. * Gets the midtones Exposure value.
  29092. * 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.
  29093. */
  29094. /**
  29095. * Sets the midtones Exposure value.
  29096. * 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.
  29097. */
  29098. midtonesExposure: number;
  29099. private _shadowsHue;
  29100. private _shadowsDensity;
  29101. private _shadowsSaturation;
  29102. private _shadowsExposure;
  29103. /**
  29104. * Gets the shadows Hue value.
  29105. * 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).
  29106. */
  29107. /**
  29108. * Sets the shadows Hue value.
  29109. * 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).
  29110. */
  29111. shadowsHue: number;
  29112. /**
  29113. * Gets the shadows Density value.
  29114. * 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.
  29115. * Values less than zero provide a filter of opposite hue.
  29116. */
  29117. /**
  29118. * Sets the shadows Density value.
  29119. * 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.
  29120. * Values less than zero provide a filter of opposite hue.
  29121. */
  29122. shadowsDensity: number;
  29123. /**
  29124. * Gets the shadows Saturation value.
  29125. * 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.
  29126. */
  29127. /**
  29128. * Sets the shadows Saturation value.
  29129. * 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.
  29130. */
  29131. shadowsSaturation: number;
  29132. /**
  29133. * Gets the shadows Exposure value.
  29134. * 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.
  29135. */
  29136. /**
  29137. * Sets the shadows Exposure value.
  29138. * 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.
  29139. */
  29140. shadowsExposure: number;
  29141. /**
  29142. * Returns the class name
  29143. * @returns The class name
  29144. */
  29145. getClassName(): string;
  29146. /**
  29147. * Binds the color curves to the shader.
  29148. * @param colorCurves The color curve to bind
  29149. * @param effect The effect to bind to
  29150. * @param positiveUniform The positive uniform shader parameter
  29151. * @param neutralUniform The neutral uniform shader parameter
  29152. * @param negativeUniform The negative uniform shader parameter
  29153. */
  29154. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29155. /**
  29156. * Prepare the list of uniforms associated with the ColorCurves effects.
  29157. * @param uniformsList The list of uniforms used in the effect
  29158. */
  29159. static PrepareUniforms(uniformsList: string[]): void;
  29160. /**
  29161. * Returns color grading data based on a hue, density, saturation and exposure value.
  29162. * @param filterHue The hue of the color filter.
  29163. * @param filterDensity The density of the color filter.
  29164. * @param saturation The saturation.
  29165. * @param exposure The exposure.
  29166. * @param result The result data container.
  29167. */
  29168. private getColorGradingDataToRef;
  29169. /**
  29170. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29171. * @param value The input slider value in range [-100,100].
  29172. * @returns Adjusted value.
  29173. */
  29174. private static applyColorGradingSliderNonlinear;
  29175. /**
  29176. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29177. * @param hue The hue (H) input.
  29178. * @param saturation The saturation (S) input.
  29179. * @param brightness The brightness (B) input.
  29180. * @result An RGBA color represented as Vector4.
  29181. */
  29182. private static fromHSBToRef;
  29183. /**
  29184. * Returns a value clamped between min and max
  29185. * @param value The value to clamp
  29186. * @param min The minimum of value
  29187. * @param max The maximum of value
  29188. * @returns The clamped value.
  29189. */
  29190. private static clamp;
  29191. /**
  29192. * Clones the current color curve instance.
  29193. * @return The cloned curves
  29194. */
  29195. clone(): ColorCurves;
  29196. /**
  29197. * Serializes the current color curve instance to a json representation.
  29198. * @return a JSON representation
  29199. */
  29200. serialize(): any;
  29201. /**
  29202. * Parses the color curve from a json representation.
  29203. * @param source the JSON source to parse
  29204. * @return The parsed curves
  29205. */
  29206. static Parse(source: any): ColorCurves;
  29207. }
  29208. }
  29209. declare module BABYLON {
  29210. /**
  29211. * Interface to follow in your material defines to integrate easily the
  29212. * Image proccessing functions.
  29213. * @hidden
  29214. */
  29215. export interface IImageProcessingConfigurationDefines {
  29216. IMAGEPROCESSING: boolean;
  29217. VIGNETTE: boolean;
  29218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29219. VIGNETTEBLENDMODEOPAQUE: boolean;
  29220. TONEMAPPING: boolean;
  29221. TONEMAPPING_ACES: boolean;
  29222. CONTRAST: boolean;
  29223. EXPOSURE: boolean;
  29224. COLORCURVES: boolean;
  29225. COLORGRADING: boolean;
  29226. COLORGRADING3D: boolean;
  29227. SAMPLER3DGREENDEPTH: boolean;
  29228. SAMPLER3DBGRMAP: boolean;
  29229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29230. }
  29231. /**
  29232. * @hidden
  29233. */
  29234. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29235. IMAGEPROCESSING: boolean;
  29236. VIGNETTE: boolean;
  29237. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29238. VIGNETTEBLENDMODEOPAQUE: boolean;
  29239. TONEMAPPING: boolean;
  29240. TONEMAPPING_ACES: boolean;
  29241. CONTRAST: boolean;
  29242. COLORCURVES: boolean;
  29243. COLORGRADING: boolean;
  29244. COLORGRADING3D: boolean;
  29245. SAMPLER3DGREENDEPTH: boolean;
  29246. SAMPLER3DBGRMAP: boolean;
  29247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29248. EXPOSURE: boolean;
  29249. constructor();
  29250. }
  29251. /**
  29252. * This groups together the common properties used for image processing either in direct forward pass
  29253. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29254. * or not.
  29255. */
  29256. export class ImageProcessingConfiguration {
  29257. /**
  29258. * Default tone mapping applied in BabylonJS.
  29259. */
  29260. static readonly TONEMAPPING_STANDARD: number;
  29261. /**
  29262. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29263. * to other engines rendering to increase portability.
  29264. */
  29265. static readonly TONEMAPPING_ACES: number;
  29266. /**
  29267. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29268. */
  29269. colorCurves: Nullable<ColorCurves>;
  29270. private _colorCurvesEnabled;
  29271. /**
  29272. * Gets wether the color curves effect is enabled.
  29273. */
  29274. /**
  29275. * Sets wether the color curves effect is enabled.
  29276. */
  29277. colorCurvesEnabled: boolean;
  29278. private _colorGradingTexture;
  29279. /**
  29280. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29281. */
  29282. /**
  29283. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29284. */
  29285. colorGradingTexture: Nullable<BaseTexture>;
  29286. private _colorGradingEnabled;
  29287. /**
  29288. * Gets wether the color grading effect is enabled.
  29289. */
  29290. /**
  29291. * Sets wether the color grading effect is enabled.
  29292. */
  29293. colorGradingEnabled: boolean;
  29294. private _colorGradingWithGreenDepth;
  29295. /**
  29296. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29297. */
  29298. /**
  29299. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29300. */
  29301. colorGradingWithGreenDepth: boolean;
  29302. private _colorGradingBGR;
  29303. /**
  29304. * Gets wether the color grading texture contains BGR values.
  29305. */
  29306. /**
  29307. * Sets wether the color grading texture contains BGR values.
  29308. */
  29309. colorGradingBGR: boolean;
  29310. /** @hidden */ exposure: number;
  29311. /**
  29312. * Gets the Exposure used in the effect.
  29313. */
  29314. /**
  29315. * Sets the Exposure used in the effect.
  29316. */
  29317. exposure: number;
  29318. private _toneMappingEnabled;
  29319. /**
  29320. * Gets wether the tone mapping effect is enabled.
  29321. */
  29322. /**
  29323. * Sets wether the tone mapping effect is enabled.
  29324. */
  29325. toneMappingEnabled: boolean;
  29326. private _toneMappingType;
  29327. /**
  29328. * Gets the type of tone mapping effect.
  29329. */
  29330. /**
  29331. * Sets the type of tone mapping effect used in BabylonJS.
  29332. */
  29333. toneMappingType: number;
  29334. protected _contrast: number;
  29335. /**
  29336. * Gets the contrast used in the effect.
  29337. */
  29338. /**
  29339. * Sets the contrast used in the effect.
  29340. */
  29341. contrast: number;
  29342. /**
  29343. * Vignette stretch size.
  29344. */
  29345. vignetteStretch: number;
  29346. /**
  29347. * Vignette centre X Offset.
  29348. */
  29349. vignetteCentreX: number;
  29350. /**
  29351. * Vignette centre Y Offset.
  29352. */
  29353. vignetteCentreY: number;
  29354. /**
  29355. * Vignette weight or intensity of the vignette effect.
  29356. */
  29357. vignetteWeight: number;
  29358. /**
  29359. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29360. * if vignetteEnabled is set to true.
  29361. */
  29362. vignetteColor: Color4;
  29363. /**
  29364. * Camera field of view used by the Vignette effect.
  29365. */
  29366. vignetteCameraFov: number;
  29367. private _vignetteBlendMode;
  29368. /**
  29369. * Gets the vignette blend mode allowing different kind of effect.
  29370. */
  29371. /**
  29372. * Sets the vignette blend mode allowing different kind of effect.
  29373. */
  29374. vignetteBlendMode: number;
  29375. private _vignetteEnabled;
  29376. /**
  29377. * Gets wether the vignette effect is enabled.
  29378. */
  29379. /**
  29380. * Sets wether the vignette effect is enabled.
  29381. */
  29382. vignetteEnabled: boolean;
  29383. private _applyByPostProcess;
  29384. /**
  29385. * Gets wether the image processing is applied through a post process or not.
  29386. */
  29387. /**
  29388. * Sets wether the image processing is applied through a post process or not.
  29389. */
  29390. applyByPostProcess: boolean;
  29391. private _isEnabled;
  29392. /**
  29393. * Gets wether the image processing is enabled or not.
  29394. */
  29395. /**
  29396. * Sets wether the image processing is enabled or not.
  29397. */
  29398. isEnabled: boolean;
  29399. /**
  29400. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29401. */
  29402. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29403. /**
  29404. * Method called each time the image processing information changes requires to recompile the effect.
  29405. */
  29406. protected _updateParameters(): void;
  29407. /**
  29408. * Gets the current class name.
  29409. * @return "ImageProcessingConfiguration"
  29410. */
  29411. getClassName(): string;
  29412. /**
  29413. * Prepare the list of uniforms associated with the Image Processing effects.
  29414. * @param uniforms The list of uniforms used in the effect
  29415. * @param defines the list of defines currently in use
  29416. */
  29417. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29418. /**
  29419. * Prepare the list of samplers associated with the Image Processing effects.
  29420. * @param samplersList The list of uniforms used in the effect
  29421. * @param defines the list of defines currently in use
  29422. */
  29423. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29424. /**
  29425. * Prepare the list of defines associated to the shader.
  29426. * @param defines the list of defines to complete
  29427. * @param forPostProcess Define if we are currently in post process mode or not
  29428. */
  29429. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29430. /**
  29431. * Returns true if all the image processing information are ready.
  29432. * @returns True if ready, otherwise, false
  29433. */
  29434. isReady(): boolean;
  29435. /**
  29436. * Binds the image processing to the shader.
  29437. * @param effect The effect to bind to
  29438. * @param aspectRatio Define the current aspect ratio of the effect
  29439. */
  29440. bind(effect: Effect, aspectRatio?: number): void;
  29441. /**
  29442. * Clones the current image processing instance.
  29443. * @return The cloned image processing
  29444. */
  29445. clone(): ImageProcessingConfiguration;
  29446. /**
  29447. * Serializes the current image processing instance to a json representation.
  29448. * @return a JSON representation
  29449. */
  29450. serialize(): any;
  29451. /**
  29452. * Parses the image processing from a json representation.
  29453. * @param source the JSON source to parse
  29454. * @return The parsed image processing
  29455. */
  29456. static Parse(source: any): ImageProcessingConfiguration;
  29457. private static _VIGNETTEMODE_MULTIPLY;
  29458. private static _VIGNETTEMODE_OPAQUE;
  29459. /**
  29460. * Used to apply the vignette as a mix with the pixel color.
  29461. */
  29462. static readonly VIGNETTEMODE_MULTIPLY: number;
  29463. /**
  29464. * Used to apply the vignette as a replacement of the pixel color.
  29465. */
  29466. static readonly VIGNETTEMODE_OPAQUE: number;
  29467. }
  29468. }
  29469. declare module BABYLON {
  29470. /**
  29471. * This represents all the required information to add a fresnel effect on a material:
  29472. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29473. */
  29474. export class FresnelParameters {
  29475. private _isEnabled;
  29476. /**
  29477. * Define if the fresnel effect is enable or not.
  29478. */
  29479. isEnabled: boolean;
  29480. /**
  29481. * Define the color used on edges (grazing angle)
  29482. */
  29483. leftColor: Color3;
  29484. /**
  29485. * Define the color used on center
  29486. */
  29487. rightColor: Color3;
  29488. /**
  29489. * Define bias applied to computed fresnel term
  29490. */
  29491. bias: number;
  29492. /**
  29493. * Defined the power exponent applied to fresnel term
  29494. */
  29495. power: number;
  29496. /**
  29497. * Clones the current fresnel and its valuues
  29498. * @returns a clone fresnel configuration
  29499. */
  29500. clone(): FresnelParameters;
  29501. /**
  29502. * Serializes the current fresnel parameters to a JSON representation.
  29503. * @return the JSON serialization
  29504. */
  29505. serialize(): any;
  29506. /**
  29507. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29508. * @param parsedFresnelParameters Define the JSON representation
  29509. * @returns the parsed parameters
  29510. */
  29511. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29512. }
  29513. }
  29514. declare module BABYLON {
  29515. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29516. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29517. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29518. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29519. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29520. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29521. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29523. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29524. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29525. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29527. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29528. /**
  29529. * Decorator used to define property that can be serialized as reference to a camera
  29530. * @param sourceName defines the name of the property to decorate
  29531. */
  29532. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29533. /**
  29534. * Class used to help serialization objects
  29535. */
  29536. export class SerializationHelper {
  29537. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29538. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29539. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29540. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29541. /**
  29542. * Appends the serialized animations from the source animations
  29543. * @param source Source containing the animations
  29544. * @param destination Target to store the animations
  29545. */
  29546. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29547. /**
  29548. * Static function used to serialized a specific entity
  29549. * @param entity defines the entity to serialize
  29550. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29551. * @returns a JSON compatible object representing the serialization of the entity
  29552. */
  29553. static Serialize<T>(entity: T, serializationObject?: any): any;
  29554. /**
  29555. * Creates a new entity from a serialization data object
  29556. * @param creationFunction defines a function used to instanciated the new entity
  29557. * @param source defines the source serialization data
  29558. * @param scene defines the hosting scene
  29559. * @param rootUrl defines the root url for resources
  29560. * @returns a new entity
  29561. */
  29562. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29563. /**
  29564. * Clones an object
  29565. * @param creationFunction defines the function used to instanciate the new object
  29566. * @param source defines the source object
  29567. * @returns the cloned object
  29568. */
  29569. static Clone<T>(creationFunction: () => T, source: T): T;
  29570. /**
  29571. * Instanciates a new object based on a source one (some data will be shared between both object)
  29572. * @param creationFunction defines the function used to instanciate the new object
  29573. * @param source defines the source object
  29574. * @returns the new object
  29575. */
  29576. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29577. }
  29578. }
  29579. declare module BABYLON {
  29580. /**
  29581. * This is the base class of all the camera used in the application.
  29582. * @see http://doc.babylonjs.com/features/cameras
  29583. */
  29584. export class Camera extends Node {
  29585. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29586. /**
  29587. * This is the default projection mode used by the cameras.
  29588. * It helps recreating a feeling of perspective and better appreciate depth.
  29589. * This is the best way to simulate real life cameras.
  29590. */
  29591. static readonly PERSPECTIVE_CAMERA: number;
  29592. /**
  29593. * This helps creating camera with an orthographic mode.
  29594. * 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.
  29595. */
  29596. static readonly ORTHOGRAPHIC_CAMERA: number;
  29597. /**
  29598. * This is the default FOV mode for perspective cameras.
  29599. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29600. */
  29601. static readonly FOVMODE_VERTICAL_FIXED: number;
  29602. /**
  29603. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29604. */
  29605. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29606. /**
  29607. * This specifies ther is no need for a camera rig.
  29608. * Basically only one eye is rendered corresponding to the camera.
  29609. */
  29610. static readonly RIG_MODE_NONE: number;
  29611. /**
  29612. * Simulates a camera Rig with one blue eye and one red eye.
  29613. * This can be use with 3d blue and red glasses.
  29614. */
  29615. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29616. /**
  29617. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29618. */
  29619. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29620. /**
  29621. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29622. */
  29623. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29624. /**
  29625. * Defines that both eyes of the camera will be rendered over under each other.
  29626. */
  29627. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29628. /**
  29629. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29630. */
  29631. static readonly RIG_MODE_VR: number;
  29632. /**
  29633. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29634. */
  29635. static readonly RIG_MODE_WEBVR: number;
  29636. /**
  29637. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29638. */
  29639. static readonly RIG_MODE_CUSTOM: number;
  29640. /**
  29641. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29642. */
  29643. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29644. /**
  29645. * Define the input manager associated with the camera.
  29646. */
  29647. inputs: CameraInputsManager<Camera>;
  29648. /** @hidden */ position: Vector3;
  29649. /**
  29650. * Define the current local position of the camera in the scene
  29651. */
  29652. position: Vector3;
  29653. /**
  29654. * The vector the camera should consider as up.
  29655. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29656. */
  29657. upVector: Vector3;
  29658. /**
  29659. * Define the current limit on the left side for an orthographic camera
  29660. * In scene unit
  29661. */
  29662. orthoLeft: Nullable<number>;
  29663. /**
  29664. * Define the current limit on the right side for an orthographic camera
  29665. * In scene unit
  29666. */
  29667. orthoRight: Nullable<number>;
  29668. /**
  29669. * Define the current limit on the bottom side for an orthographic camera
  29670. * In scene unit
  29671. */
  29672. orthoBottom: Nullable<number>;
  29673. /**
  29674. * Define the current limit on the top side for an orthographic camera
  29675. * In scene unit
  29676. */
  29677. orthoTop: Nullable<number>;
  29678. /**
  29679. * Field Of View is set in Radians. (default is 0.8)
  29680. */
  29681. fov: number;
  29682. /**
  29683. * Define the minimum distance the camera can see from.
  29684. * This is important to note that the depth buffer are not infinite and the closer it starts
  29685. * the more your scene might encounter depth fighting issue.
  29686. */
  29687. minZ: number;
  29688. /**
  29689. * Define the maximum distance the camera can see to.
  29690. * This is important to note that the depth buffer are not infinite and the further it end
  29691. * the more your scene might encounter depth fighting issue.
  29692. */
  29693. maxZ: number;
  29694. /**
  29695. * Define the default inertia of the camera.
  29696. * This helps giving a smooth feeling to the camera movement.
  29697. */
  29698. inertia: number;
  29699. /**
  29700. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29701. */
  29702. mode: number;
  29703. /**
  29704. * Define wether the camera is intermediate.
  29705. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29706. */
  29707. isIntermediate: boolean;
  29708. /**
  29709. * Define the viewport of the camera.
  29710. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29711. */
  29712. viewport: Viewport;
  29713. /**
  29714. * Restricts the camera to viewing objects with the same layerMask.
  29715. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29716. */
  29717. layerMask: number;
  29718. /**
  29719. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29720. */
  29721. fovMode: number;
  29722. /**
  29723. * Rig mode of the camera.
  29724. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29725. * This is normally controlled byt the camera themselves as internal use.
  29726. */
  29727. cameraRigMode: number;
  29728. /**
  29729. * Defines the distance between both "eyes" in case of a RIG
  29730. */
  29731. interaxialDistance: number;
  29732. /**
  29733. * Defines if stereoscopic rendering is done side by side or over under.
  29734. */
  29735. isStereoscopicSideBySide: boolean;
  29736. /**
  29737. * 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
  29738. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29739. * else in the scene.
  29740. */
  29741. customRenderTargets: RenderTargetTexture[];
  29742. /**
  29743. * When set, the camera will render to this render target instead of the default canvas
  29744. */
  29745. outputRenderTarget: Nullable<RenderTargetTexture>;
  29746. /**
  29747. * Observable triggered when the camera view matrix has changed.
  29748. */
  29749. onViewMatrixChangedObservable: Observable<Camera>;
  29750. /**
  29751. * Observable triggered when the camera Projection matrix has changed.
  29752. */
  29753. onProjectionMatrixChangedObservable: Observable<Camera>;
  29754. /**
  29755. * Observable triggered when the inputs have been processed.
  29756. */
  29757. onAfterCheckInputsObservable: Observable<Camera>;
  29758. /**
  29759. * Observable triggered when reset has been called and applied to the camera.
  29760. */
  29761. onRestoreStateObservable: Observable<Camera>;
  29762. /** @hidden */ cameraRigParams: any;
  29763. /** @hidden */ rigCameras: Camera[];
  29764. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29765. protected _webvrViewMatrix: Matrix;
  29766. /** @hidden */ skipRendering: boolean;
  29767. /** @hidden */ projectionMatrix: Matrix;
  29768. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29769. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29770. protected _globalPosition: Vector3;
  29771. /** hidden */ computedViewMatrix: Matrix;
  29772. private _doNotComputeProjectionMatrix;
  29773. private _transformMatrix;
  29774. private _frustumPlanes;
  29775. private _refreshFrustumPlanes;
  29776. private _storedFov;
  29777. private _stateStored;
  29778. /**
  29779. * Instantiates a new camera object.
  29780. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29781. * @see http://doc.babylonjs.com/features/cameras
  29782. * @param name Defines the name of the camera in the scene
  29783. * @param position Defines the position of the camera
  29784. * @param scene Defines the scene the camera belongs too
  29785. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29786. */
  29787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29788. /**
  29789. * Store current camera state (fov, position, etc..)
  29790. * @returns the camera
  29791. */
  29792. storeState(): Camera;
  29793. /**
  29794. * Restores the camera state values if it has been stored. You must call storeState() first
  29795. */
  29796. protected _restoreStateValues(): boolean;
  29797. /**
  29798. * Restored camera state. You must call storeState() first.
  29799. * @returns true if restored and false otherwise
  29800. */
  29801. restoreState(): boolean;
  29802. /**
  29803. * Gets the class name of the camera.
  29804. * @returns the class name
  29805. */
  29806. getClassName(): string;
  29807. /** @hidden */ protected readonly _isCamera: boolean;
  29808. /**
  29809. * Gets a string representation of the camera useful for debug purpose.
  29810. * @param fullDetails Defines that a more verboe level of logging is required
  29811. * @returns the string representation
  29812. */
  29813. toString(fullDetails?: boolean): string;
  29814. /**
  29815. * Gets the current world space position of the camera.
  29816. */
  29817. readonly globalPosition: Vector3;
  29818. /**
  29819. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29820. * @returns the active meshe list
  29821. */
  29822. getActiveMeshes(): SmartArray<AbstractMesh>;
  29823. /**
  29824. * Check wether a mesh is part of the current active mesh list of the camera
  29825. * @param mesh Defines the mesh to check
  29826. * @returns true if active, false otherwise
  29827. */
  29828. isActiveMesh(mesh: Mesh): boolean;
  29829. /**
  29830. * Is this camera ready to be used/rendered
  29831. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29832. * @return true if the camera is ready
  29833. */
  29834. isReady(completeCheck?: boolean): boolean;
  29835. /** @hidden */ initCache(): void;
  29836. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29837. /** @hidden */ isSynchronized(): boolean;
  29838. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29839. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29840. /**
  29841. * Attach the input controls to a specific dom element to get the input from.
  29842. * @param element Defines the element the controls should be listened from
  29843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29844. */
  29845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29846. /**
  29847. * Detach the current controls from the specified dom element.
  29848. * @param element Defines the element to stop listening the inputs from
  29849. */
  29850. detachControl(element: HTMLElement): void;
  29851. /**
  29852. * Update the camera state according to the different inputs gathered during the frame.
  29853. */
  29854. update(): void;
  29855. /** @hidden */ checkInputs(): void;
  29856. /** @hidden */
  29857. readonly rigCameras: Camera[];
  29858. /**
  29859. * Gets the post process used by the rig cameras
  29860. */
  29861. readonly rigPostProcess: Nullable<PostProcess>;
  29862. /**
  29863. * Internal, gets the first post proces.
  29864. * @returns the first post process to be run on this camera.
  29865. */ getFirstPostProcess(): Nullable<PostProcess>;
  29866. private _cascadePostProcessesToRigCams;
  29867. /**
  29868. * Attach a post process to the camera.
  29869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29870. * @param postProcess The post process to attach to the camera
  29871. * @param insertAt The position of the post process in case several of them are in use in the scene
  29872. * @returns the position the post process has been inserted at
  29873. */
  29874. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29875. /**
  29876. * Detach a post process to the camera.
  29877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29878. * @param postProcess The post process to detach from the camera
  29879. */
  29880. detachPostProcess(postProcess: PostProcess): void;
  29881. /**
  29882. * Gets the current world matrix of the camera
  29883. */
  29884. getWorldMatrix(): Matrix;
  29885. /** @hidden */ getViewMatrix(): Matrix;
  29886. /**
  29887. * Gets the current view matrix of the camera.
  29888. * @param force forces the camera to recompute the matrix without looking at the cached state
  29889. * @returns the view matrix
  29890. */
  29891. getViewMatrix(force?: boolean): Matrix;
  29892. /**
  29893. * Freeze the projection matrix.
  29894. * It will prevent the cache check of the camera projection compute and can speed up perf
  29895. * if no parameter of the camera are meant to change
  29896. * @param projection Defines manually a projection if necessary
  29897. */
  29898. freezeProjectionMatrix(projection?: Matrix): void;
  29899. /**
  29900. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29901. */
  29902. unfreezeProjectionMatrix(): void;
  29903. /**
  29904. * Gets the current projection matrix of the camera.
  29905. * @param force forces the camera to recompute the matrix without looking at the cached state
  29906. * @returns the projection matrix
  29907. */
  29908. getProjectionMatrix(force?: boolean): Matrix;
  29909. /**
  29910. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29911. * @returns a Matrix
  29912. */
  29913. getTransformationMatrix(): Matrix;
  29914. private _updateFrustumPlanes;
  29915. /**
  29916. * Checks if a cullable object (mesh...) is in the camera frustum
  29917. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29918. * @param target The object to check
  29919. * @returns true if the object is in frustum otherwise false
  29920. */
  29921. isInFrustum(target: ICullable): boolean;
  29922. /**
  29923. * Checks if a cullable object (mesh...) is in the camera frustum
  29924. * Unlike isInFrustum this cheks the full bounding box
  29925. * @param target The object to check
  29926. * @returns true if the object is in frustum otherwise false
  29927. */
  29928. isCompletelyInFrustum(target: ICullable): boolean;
  29929. /**
  29930. * Gets a ray in the forward direction from the camera.
  29931. * @param length Defines the length of the ray to create
  29932. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29933. * @param origin Defines the start point of the ray which defaults to the camera position
  29934. * @returns the forward ray
  29935. */
  29936. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29937. /**
  29938. * Releases resources associated with this node.
  29939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29941. */
  29942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29943. /** @hidden */ isLeftCamera: boolean;
  29944. /**
  29945. * Gets the left camera of a rig setup in case of Rigged Camera
  29946. */
  29947. readonly isLeftCamera: boolean;
  29948. /** @hidden */ isRightCamera: boolean;
  29949. /**
  29950. * Gets the right camera of a rig setup in case of Rigged Camera
  29951. */
  29952. readonly isRightCamera: boolean;
  29953. /**
  29954. * Gets the left camera of a rig setup in case of Rigged Camera
  29955. */
  29956. readonly leftCamera: Nullable<FreeCamera>;
  29957. /**
  29958. * Gets the right camera of a rig setup in case of Rigged Camera
  29959. */
  29960. readonly rightCamera: Nullable<FreeCamera>;
  29961. /**
  29962. * Gets the left camera target of a rig setup in case of Rigged Camera
  29963. * @returns the target position
  29964. */
  29965. getLeftTarget(): Nullable<Vector3>;
  29966. /**
  29967. * Gets the right camera target of a rig setup in case of Rigged Camera
  29968. * @returns the target position
  29969. */
  29970. getRightTarget(): Nullable<Vector3>;
  29971. /**
  29972. * @hidden
  29973. */
  29974. setCameraRigMode(mode: number, rigParams: any): void;
  29975. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29976. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29977. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29978. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29979. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29980. protected _updateCameraRotationMatrix(): void;
  29981. protected _updateWebVRCameraRotationMatrix(): void;
  29982. /**
  29983. * This function MUST be overwritten by the different WebVR cameras available.
  29984. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29985. * @hidden
  29986. */ getWebVRProjectionMatrix(): Matrix;
  29987. /**
  29988. * This function MUST be overwritten by the different WebVR cameras available.
  29989. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29990. * @hidden
  29991. */ getWebVRViewMatrix(): Matrix;
  29992. /** @hidden */
  29993. setCameraRigParameter(name: string, value: any): void;
  29994. /**
  29995. * needs to be overridden by children so sub has required properties to be copied
  29996. * @hidden
  29997. */
  29998. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29999. /**
  30000. * May need to be overridden by children
  30001. * @hidden
  30002. */ updateRigCameras(): void;
  30003. /** @hidden */ setupInputs(): void;
  30004. /**
  30005. * Serialiaze the camera setup to a json represention
  30006. * @returns the JSON representation
  30007. */
  30008. serialize(): any;
  30009. /**
  30010. * Clones the current camera.
  30011. * @param name The cloned camera name
  30012. * @returns the cloned camera
  30013. */
  30014. clone(name: string): Camera;
  30015. /**
  30016. * Gets the direction of the camera relative to a given local axis.
  30017. * @param localAxis Defines the reference axis to provide a relative direction.
  30018. * @return the direction
  30019. */
  30020. getDirection(localAxis: Vector3): Vector3;
  30021. /**
  30022. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30023. * @param localAxis Defines the reference axis to provide a relative direction.
  30024. * @param result Defines the vector to store the result in
  30025. */
  30026. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30027. /**
  30028. * Gets a camera constructor for a given camera type
  30029. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30030. * @param name The name of the camera the result will be able to instantiate
  30031. * @param scene The scene the result will construct the camera in
  30032. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30033. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30034. * @returns a factory method to construc the camera
  30035. */
  30036. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30037. /**
  30038. * Compute the world matrix of the camera.
  30039. * @returns the camera workd matrix
  30040. */
  30041. computeWorldMatrix(): Matrix;
  30042. /**
  30043. * Parse a JSON and creates the camera from the parsed information
  30044. * @param parsedCamera The JSON to parse
  30045. * @param scene The scene to instantiate the camera in
  30046. * @returns the newly constructed camera
  30047. */
  30048. static Parse(parsedCamera: any, scene: Scene): Camera;
  30049. }
  30050. }
  30051. declare module BABYLON {
  30052. /**
  30053. * Interface for any object that can request an animation frame
  30054. */
  30055. export interface ICustomAnimationFrameRequester {
  30056. /**
  30057. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30058. */
  30059. renderFunction?: Function;
  30060. /**
  30061. * Called to request the next frame to render to
  30062. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30063. */
  30064. requestAnimationFrame: Function;
  30065. /**
  30066. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30067. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30068. */
  30069. requestID?: number;
  30070. }
  30071. /**
  30072. * Interface containing an array of animations
  30073. */
  30074. export interface IAnimatable {
  30075. /**
  30076. * Array of animations
  30077. */
  30078. animations: Nullable<Array<Animation>>;
  30079. }
  30080. /** Interface used by value gradients (color, factor, ...) */
  30081. export interface IValueGradient {
  30082. /**
  30083. * Gets or sets the gradient value (between 0 and 1)
  30084. */
  30085. gradient: number;
  30086. }
  30087. /** Class used to store color4 gradient */
  30088. export class ColorGradient implements IValueGradient {
  30089. /**
  30090. * Gets or sets the gradient value (between 0 and 1)
  30091. */
  30092. gradient: number;
  30093. /**
  30094. * Gets or sets first associated color
  30095. */
  30096. color1: Color4;
  30097. /**
  30098. * Gets or sets second associated color
  30099. */
  30100. color2?: Color4;
  30101. /**
  30102. * Will get a color picked randomly between color1 and color2.
  30103. * If color2 is undefined then color1 will be used
  30104. * @param result defines the target Color4 to store the result in
  30105. */
  30106. getColorToRef(result: Color4): void;
  30107. }
  30108. /** Class used to store color 3 gradient */
  30109. export class Color3Gradient implements IValueGradient {
  30110. /**
  30111. * Gets or sets the gradient value (between 0 and 1)
  30112. */
  30113. gradient: number;
  30114. /**
  30115. * Gets or sets the associated color
  30116. */
  30117. color: Color3;
  30118. }
  30119. /** Class used to store factor gradient */
  30120. export class FactorGradient implements IValueGradient {
  30121. /**
  30122. * Gets or sets the gradient value (between 0 and 1)
  30123. */
  30124. gradient: number;
  30125. /**
  30126. * Gets or sets first associated factor
  30127. */
  30128. factor1: number;
  30129. /**
  30130. * Gets or sets second associated factor
  30131. */
  30132. factor2?: number;
  30133. /**
  30134. * Will get a number picked randomly between factor1 and factor2.
  30135. * If factor2 is undefined then factor1 will be used
  30136. * @returns the picked number
  30137. */
  30138. getFactor(): number;
  30139. }
  30140. /**
  30141. * @ignore
  30142. * Application error to support additional information when loading a file
  30143. */
  30144. export class LoadFileError extends Error {
  30145. /** defines the optional web request */
  30146. request?: WebRequest | undefined;
  30147. private static _setPrototypeOf;
  30148. /**
  30149. * Creates a new LoadFileError
  30150. * @param message defines the message of the error
  30151. * @param request defines the optional web request
  30152. */
  30153. constructor(message: string,
  30154. /** defines the optional web request */
  30155. request?: WebRequest | undefined);
  30156. }
  30157. /**
  30158. * Class used to define a retry strategy when error happens while loading assets
  30159. */
  30160. export class RetryStrategy {
  30161. /**
  30162. * Function used to defines an exponential back off strategy
  30163. * @param maxRetries defines the maximum number of retries (3 by default)
  30164. * @param baseInterval defines the interval between retries
  30165. * @returns the strategy function to use
  30166. */
  30167. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30168. }
  30169. /**
  30170. * File request interface
  30171. */
  30172. export interface IFileRequest {
  30173. /**
  30174. * Raised when the request is complete (success or error).
  30175. */
  30176. onCompleteObservable: Observable<IFileRequest>;
  30177. /**
  30178. * Aborts the request for a file.
  30179. */
  30180. abort: () => void;
  30181. }
  30182. /**
  30183. * Class containing a set of static utilities functions
  30184. */
  30185. export class Tools {
  30186. /**
  30187. * Gets or sets the base URL to use to load assets
  30188. */
  30189. static BaseUrl: string;
  30190. /**
  30191. * Enable/Disable Custom HTTP Request Headers globally.
  30192. * default = false
  30193. * @see CustomRequestHeaders
  30194. */
  30195. static UseCustomRequestHeaders: boolean;
  30196. /**
  30197. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30198. * i.e. when loading files, where the server/service expects an Authorization header
  30199. */
  30200. static CustomRequestHeaders: {
  30201. [key: string]: string;
  30202. };
  30203. /**
  30204. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30205. */
  30206. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30207. /**
  30208. * Default behaviour for cors in the application.
  30209. * It can be a string if the expected behavior is identical in the entire app.
  30210. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30211. */
  30212. static CorsBehavior: string | ((url: string | string[]) => string);
  30213. /**
  30214. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30215. * @ignorenaming
  30216. */
  30217. static UseFallbackTexture: boolean;
  30218. /**
  30219. * Use this object to register external classes like custom textures or material
  30220. * to allow the laoders to instantiate them
  30221. */
  30222. static RegisteredExternalClasses: {
  30223. [key: string]: Object;
  30224. };
  30225. /**
  30226. * Texture content used if a texture cannot loaded
  30227. * @ignorenaming
  30228. */
  30229. static fallbackTexture: string;
  30230. /**
  30231. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30232. * @param u defines the coordinate on X axis
  30233. * @param v defines the coordinate on Y axis
  30234. * @param width defines the width of the source data
  30235. * @param height defines the height of the source data
  30236. * @param pixels defines the source byte array
  30237. * @param color defines the output color
  30238. */
  30239. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30240. /**
  30241. * Interpolates between a and b via alpha
  30242. * @param a The lower value (returned when alpha = 0)
  30243. * @param b The upper value (returned when alpha = 1)
  30244. * @param alpha The interpolation-factor
  30245. * @return The mixed value
  30246. */
  30247. static Mix(a: number, b: number, alpha: number): number;
  30248. /**
  30249. * Tries to instantiate a new object from a given class name
  30250. * @param className defines the class name to instantiate
  30251. * @returns the new object or null if the system was not able to do the instantiation
  30252. */
  30253. static Instantiate(className: string): any;
  30254. /**
  30255. * Provides a slice function that will work even on IE
  30256. * @param data defines the array to slice
  30257. * @param start defines the start of the data (optional)
  30258. * @param end defines the end of the data (optional)
  30259. * @returns the new sliced array
  30260. */
  30261. static Slice<T>(data: T, start?: number, end?: number): T;
  30262. /**
  30263. * Polyfill for setImmediate
  30264. * @param action defines the action to execute after the current execution block
  30265. */
  30266. static SetImmediate(action: () => void): void;
  30267. /**
  30268. * Function indicating if a number is an exponent of 2
  30269. * @param value defines the value to test
  30270. * @returns true if the value is an exponent of 2
  30271. */
  30272. static IsExponentOfTwo(value: number): boolean;
  30273. private static _tmpFloatArray;
  30274. /**
  30275. * Returns the nearest 32-bit single precision float representation of a Number
  30276. * @param value A Number. If the parameter is of a different type, it will get converted
  30277. * to a number or to NaN if it cannot be converted
  30278. * @returns number
  30279. */
  30280. static FloatRound(value: number): number;
  30281. /**
  30282. * Find the next highest power of two.
  30283. * @param x Number to start search from.
  30284. * @return Next highest power of two.
  30285. */
  30286. static CeilingPOT(x: number): number;
  30287. /**
  30288. * Find the next lowest power of two.
  30289. * @param x Number to start search from.
  30290. * @return Next lowest power of two.
  30291. */
  30292. static FloorPOT(x: number): number;
  30293. /**
  30294. * Find the nearest power of two.
  30295. * @param x Number to start search from.
  30296. * @return Next nearest power of two.
  30297. */
  30298. static NearestPOT(x: number): number;
  30299. /**
  30300. * Get the closest exponent of two
  30301. * @param value defines the value to approximate
  30302. * @param max defines the maximum value to return
  30303. * @param mode defines how to define the closest value
  30304. * @returns closest exponent of two of the given value
  30305. */
  30306. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30307. /**
  30308. * Extracts the filename from a path
  30309. * @param path defines the path to use
  30310. * @returns the filename
  30311. */
  30312. static GetFilename(path: string): string;
  30313. /**
  30314. * Extracts the "folder" part of a path (everything before the filename).
  30315. * @param uri The URI to extract the info from
  30316. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30317. * @returns The "folder" part of the path
  30318. */
  30319. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30320. /**
  30321. * Extracts text content from a DOM element hierarchy
  30322. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30323. */
  30324. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30325. /**
  30326. * Convert an angle in radians to degrees
  30327. * @param angle defines the angle to convert
  30328. * @returns the angle in degrees
  30329. */
  30330. static ToDegrees(angle: number): number;
  30331. /**
  30332. * Convert an angle in degrees to radians
  30333. * @param angle defines the angle to convert
  30334. * @returns the angle in radians
  30335. */
  30336. static ToRadians(angle: number): number;
  30337. /**
  30338. * Encode a buffer to a base64 string
  30339. * @param buffer defines the buffer to encode
  30340. * @returns the encoded string
  30341. */
  30342. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30343. /**
  30344. * Extracts minimum and maximum values from a list of indexed positions
  30345. * @param positions defines the positions to use
  30346. * @param indices defines the indices to the positions
  30347. * @param indexStart defines the start index
  30348. * @param indexCount defines the end index
  30349. * @param bias defines bias value to add to the result
  30350. * @return minimum and maximum values
  30351. */
  30352. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30353. minimum: Vector3;
  30354. maximum: Vector3;
  30355. };
  30356. /**
  30357. * Extracts minimum and maximum values from a list of positions
  30358. * @param positions defines the positions to use
  30359. * @param start defines the start index in the positions array
  30360. * @param count defines the number of positions to handle
  30361. * @param bias defines bias value to add to the result
  30362. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30363. * @return minimum and maximum values
  30364. */
  30365. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30366. minimum: Vector3;
  30367. maximum: Vector3;
  30368. };
  30369. /**
  30370. * Returns an array if obj is not an array
  30371. * @param obj defines the object to evaluate as an array
  30372. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30373. * @returns either obj directly if obj is an array or a new array containing obj
  30374. */
  30375. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30376. /**
  30377. * Gets the pointer prefix to use
  30378. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30379. */
  30380. static GetPointerPrefix(): string;
  30381. /**
  30382. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30383. * @param func - the function to be called
  30384. * @param requester - the object that will request the next frame. Falls back to window.
  30385. * @returns frame number
  30386. */
  30387. static QueueNewFrame(func: () => void, requester?: any): number;
  30388. /**
  30389. * Ask the browser to promote the current element to fullscreen rendering mode
  30390. * @param element defines the DOM element to promote
  30391. */
  30392. static RequestFullscreen(element: HTMLElement): void;
  30393. /**
  30394. * Asks the browser to exit fullscreen mode
  30395. */
  30396. static ExitFullscreen(): void;
  30397. /**
  30398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30399. * @param url define the url we are trying
  30400. * @param element define the dom element where to configure the cors policy
  30401. */
  30402. static SetCorsBehavior(url: string | string[], element: {
  30403. crossOrigin: string | null;
  30404. }): void;
  30405. /**
  30406. * Removes unwanted characters from an url
  30407. * @param url defines the url to clean
  30408. * @returns the cleaned url
  30409. */
  30410. static CleanUrl(url: string): string;
  30411. /**
  30412. * Gets or sets a function used to pre-process url before using them to load assets
  30413. */
  30414. static PreprocessUrl: (url: string) => string;
  30415. /**
  30416. * Loads an image as an HTMLImageElement.
  30417. * @param input url string, ArrayBuffer, or Blob to load
  30418. * @param onLoad callback called when the image successfully loads
  30419. * @param onError callback called when the image fails to load
  30420. * @param offlineProvider offline provider for caching
  30421. * @returns the HTMLImageElement of the loaded image
  30422. */
  30423. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30424. /**
  30425. * Loads a file
  30426. * @param url url string, ArrayBuffer, or Blob to load
  30427. * @param onSuccess callback called when the file successfully loads
  30428. * @param onProgress callback called while file is loading (if the server supports this mode)
  30429. * @param offlineProvider defines the offline provider for caching
  30430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30431. * @param onError callback called when the file fails to load
  30432. * @returns a file request object
  30433. */
  30434. 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;
  30435. /**
  30436. * Load a script (identified by an url). When the url returns, the
  30437. * content of this file is added into a new script element, attached to the DOM (body element)
  30438. * @param scriptUrl defines the url of the script to laod
  30439. * @param onSuccess defines the callback called when the script is loaded
  30440. * @param onError defines the callback to call if an error occurs
  30441. * @param scriptId defines the id of the script element
  30442. */
  30443. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30444. /**
  30445. * Load an asynchronous script (identified by an url). When the url returns, the
  30446. * content of this file is added into a new script element, attached to the DOM (body element)
  30447. * @param scriptUrl defines the url of the script to laod
  30448. * @param scriptId defines the id of the script element
  30449. * @returns a promise request object
  30450. */
  30451. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30452. /**
  30453. * Loads a file from a blob
  30454. * @param fileToLoad defines the blob to use
  30455. * @param callback defines the callback to call when data is loaded
  30456. * @param progressCallback defines the callback to call during loading process
  30457. * @returns a file request object
  30458. */
  30459. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30460. /**
  30461. * Loads a file
  30462. * @param fileToLoad defines the file to load
  30463. * @param callback defines the callback to call when data is loaded
  30464. * @param progressCallBack defines the callback to call during loading process
  30465. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30466. * @returns a file request object
  30467. */
  30468. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30469. /**
  30470. * Creates a data url from a given string content
  30471. * @param content defines the content to convert
  30472. * @returns the new data url link
  30473. */
  30474. static FileAsURL(content: string): string;
  30475. /**
  30476. * Format the given number to a specific decimal format
  30477. * @param value defines the number to format
  30478. * @param decimals defines the number of decimals to use
  30479. * @returns the formatted string
  30480. */
  30481. static Format(value: number, decimals?: number): string;
  30482. /**
  30483. * Checks if a given vector is inside a specific range
  30484. * @param v defines the vector to test
  30485. * @param min defines the minimum range
  30486. * @param max defines the maximum range
  30487. */
  30488. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30489. /**
  30490. * Tries to copy an object by duplicating every property
  30491. * @param source defines the source object
  30492. * @param destination defines the target object
  30493. * @param doNotCopyList defines a list of properties to avoid
  30494. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30495. */
  30496. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30497. /**
  30498. * Gets a boolean indicating if the given object has no own property
  30499. * @param obj defines the object to test
  30500. * @returns true if object has no own property
  30501. */
  30502. static IsEmpty(obj: any): boolean;
  30503. /**
  30504. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30505. * @param str Source string
  30506. * @param suffix Suffix to search for in the source string
  30507. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30508. */
  30509. static EndsWith(str: string, suffix: string): boolean;
  30510. /**
  30511. * Function used to register events at window level
  30512. * @param events defines the events to register
  30513. */
  30514. static RegisterTopRootEvents(events: {
  30515. name: string;
  30516. handler: Nullable<(e: FocusEvent) => any>;
  30517. }[]): void;
  30518. /**
  30519. * Function used to unregister events from window level
  30520. * @param events defines the events to unregister
  30521. */
  30522. static UnregisterTopRootEvents(events: {
  30523. name: string;
  30524. handler: Nullable<(e: FocusEvent) => any>;
  30525. }[]): void;
  30526. /**
  30527. * @ignore
  30528. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30529. /**
  30530. * Dumps the current bound framebuffer
  30531. * @param width defines the rendering width
  30532. * @param height defines the rendering height
  30533. * @param engine defines the hosting engine
  30534. * @param successCallback defines the callback triggered once the data are available
  30535. * @param mimeType defines the mime type of the result
  30536. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30537. */
  30538. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30539. /**
  30540. * Converts the canvas data to blob.
  30541. * This acts as a polyfill for browsers not supporting the to blob function.
  30542. * @param canvas Defines the canvas to extract the data from
  30543. * @param successCallback Defines the callback triggered once the data are available
  30544. * @param mimeType Defines the mime type of the result
  30545. */
  30546. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30547. /**
  30548. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30549. * @param successCallback defines the callback triggered once the data are available
  30550. * @param mimeType defines the mime type of the result
  30551. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30552. */
  30553. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30554. /**
  30555. * Downloads a blob in the browser
  30556. * @param blob defines the blob to download
  30557. * @param fileName defines the name of the downloaded file
  30558. */
  30559. static Download(blob: Blob, fileName: string): void;
  30560. /**
  30561. * Captures a screenshot of the current rendering
  30562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30563. * @param engine defines the rendering engine
  30564. * @param camera defines the source camera
  30565. * @param size This parameter can be set to a single number or to an object with the
  30566. * following (optional) properties: precision, width, height. If a single number is passed,
  30567. * it will be used for both width and height. If an object is passed, the screenshot size
  30568. * will be derived from the parameters. The precision property is a multiplier allowing
  30569. * rendering at a higher or lower resolution
  30570. * @param successCallback defines the callback receives a single parameter which contains the
  30571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30572. * src parameter of an <img> to display it
  30573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30574. * Check your browser for supported MIME types
  30575. */
  30576. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30577. /**
  30578. * Generates an image screenshot from the specified camera.
  30579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30580. * @param engine The engine to use for rendering
  30581. * @param camera The camera to use for rendering
  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 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 The MIME type of the screenshot image (default: image/png).
  30591. * Check your browser for supported MIME types
  30592. * @param samples Texture samples (default: 1)
  30593. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30594. * @param fileName A name for for the downloaded file.
  30595. */
  30596. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30597. /**
  30598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30599. * Be aware Math.random() could cause collisions, but:
  30600. * "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"
  30601. * @returns a pseudo random id
  30602. */
  30603. static RandomId(): string;
  30604. /**
  30605. * Test if the given uri is a base64 string
  30606. * @param uri The uri to test
  30607. * @return True if the uri is a base64 string or false otherwise
  30608. */
  30609. static IsBase64(uri: string): boolean;
  30610. /**
  30611. * Decode the given base64 uri.
  30612. * @param uri The uri to decode
  30613. * @return The decoded base64 data.
  30614. */
  30615. static DecodeBase64(uri: string): ArrayBuffer;
  30616. /**
  30617. * Gets the absolute url.
  30618. * @param url the input url
  30619. * @return the absolute url
  30620. */
  30621. static GetAbsoluteUrl(url: string): string;
  30622. /**
  30623. * No log
  30624. */
  30625. static readonly NoneLogLevel: number;
  30626. /**
  30627. * Only message logs
  30628. */
  30629. static readonly MessageLogLevel: number;
  30630. /**
  30631. * Only warning logs
  30632. */
  30633. static readonly WarningLogLevel: number;
  30634. /**
  30635. * Only error logs
  30636. */
  30637. static readonly ErrorLogLevel: number;
  30638. /**
  30639. * All logs
  30640. */
  30641. static readonly AllLogLevel: number;
  30642. /**
  30643. * Gets a value indicating the number of loading errors
  30644. * @ignorenaming
  30645. */
  30646. static readonly errorsCount: number;
  30647. /**
  30648. * Callback called when a new log is added
  30649. */
  30650. static OnNewCacheEntry: (entry: string) => void;
  30651. /**
  30652. * Log a message to the console
  30653. * @param message defines the message to log
  30654. */
  30655. static Log(message: string): void;
  30656. /**
  30657. * Write a warning message to the console
  30658. * @param message defines the message to log
  30659. */
  30660. static Warn(message: string): void;
  30661. /**
  30662. * Write an error message to the console
  30663. * @param message defines the message to log
  30664. */
  30665. static Error(message: string): void;
  30666. /**
  30667. * Gets current log cache (list of logs)
  30668. */
  30669. static readonly LogCache: string;
  30670. /**
  30671. * Clears the log cache
  30672. */
  30673. static ClearLogCache(): void;
  30674. /**
  30675. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30676. */
  30677. static LogLevels: number;
  30678. /**
  30679. * Checks if the loaded document was accessed via `file:`-Protocol.
  30680. * @returns boolean
  30681. */
  30682. static IsFileURL(): boolean;
  30683. /**
  30684. * Checks if the window object exists
  30685. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30686. */
  30687. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30688. /**
  30689. * No performance log
  30690. */
  30691. static readonly PerformanceNoneLogLevel: number;
  30692. /**
  30693. * Use user marks to log performance
  30694. */
  30695. static readonly PerformanceUserMarkLogLevel: number;
  30696. /**
  30697. * Log performance to the console
  30698. */
  30699. static readonly PerformanceConsoleLogLevel: number;
  30700. private static _performance;
  30701. /**
  30702. * Sets the current performance log level
  30703. */
  30704. static PerformanceLogLevel: number;
  30705. private static _StartPerformanceCounterDisabled;
  30706. private static _EndPerformanceCounterDisabled;
  30707. private static _StartUserMark;
  30708. private static _EndUserMark;
  30709. private static _StartPerformanceConsole;
  30710. private static _EndPerformanceConsole;
  30711. /**
  30712. * Starts a performance counter
  30713. */
  30714. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30715. /**
  30716. * Ends a specific performance coutner
  30717. */
  30718. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30719. /**
  30720. * Gets either window.performance.now() if supported or Date.now() else
  30721. */
  30722. static readonly Now: number;
  30723. /**
  30724. * This method will return the name of the class used to create the instance of the given object.
  30725. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30726. * @param object the object to get the class name from
  30727. * @param isType defines if the object is actually a type
  30728. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30729. */
  30730. static GetClassName(object: any, isType?: boolean): string;
  30731. /**
  30732. * Gets the first element of an array satisfying a given predicate
  30733. * @param array defines the array to browse
  30734. * @param predicate defines the predicate to use
  30735. * @returns null if not found or the element
  30736. */
  30737. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30738. /**
  30739. * This method will return the name of the full name of the class, including its owning module (if any).
  30740. * 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).
  30741. * @param object the object to get the class name from
  30742. * @param isType defines if the object is actually a type
  30743. * @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.
  30744. * @ignorenaming
  30745. */
  30746. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30747. /**
  30748. * Returns a promise that resolves after the given amount of time.
  30749. * @param delay Number of milliseconds to delay
  30750. * @returns Promise that resolves after the given amount of time
  30751. */
  30752. static DelayAsync(delay: number): Promise<void>;
  30753. /**
  30754. * Gets the current gradient from an array of IValueGradient
  30755. * @param ratio defines the current ratio to get
  30756. * @param gradients defines the array of IValueGradient
  30757. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30758. */
  30759. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30760. }
  30761. /**
  30762. * This class is used to track a performance counter which is number based.
  30763. * The user has access to many properties which give statistics of different nature.
  30764. *
  30765. * The implementer can track two kinds of Performance Counter: time and count.
  30766. * 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.
  30767. * 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.
  30768. */
  30769. export class PerfCounter {
  30770. /**
  30771. * Gets or sets a global boolean to turn on and off all the counters
  30772. */
  30773. static Enabled: boolean;
  30774. /**
  30775. * Returns the smallest value ever
  30776. */
  30777. readonly min: number;
  30778. /**
  30779. * Returns the biggest value ever
  30780. */
  30781. readonly max: number;
  30782. /**
  30783. * Returns the average value since the performance counter is running
  30784. */
  30785. readonly average: number;
  30786. /**
  30787. * Returns the average value of the last second the counter was monitored
  30788. */
  30789. readonly lastSecAverage: number;
  30790. /**
  30791. * Returns the current value
  30792. */
  30793. readonly current: number;
  30794. /**
  30795. * Gets the accumulated total
  30796. */
  30797. readonly total: number;
  30798. /**
  30799. * Gets the total value count
  30800. */
  30801. readonly count: number;
  30802. /**
  30803. * Creates a new counter
  30804. */
  30805. constructor();
  30806. /**
  30807. * Call this method to start monitoring a new frame.
  30808. * 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.
  30809. */
  30810. fetchNewFrame(): void;
  30811. /**
  30812. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30813. * @param newCount the count value to add to the monitored count
  30814. * @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.
  30815. */
  30816. addCount(newCount: number, fetchResult: boolean): void;
  30817. /**
  30818. * Start monitoring this performance counter
  30819. */
  30820. beginMonitoring(): void;
  30821. /**
  30822. * Compute the time lapsed since the previous beginMonitoring() call.
  30823. * @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
  30824. */
  30825. endMonitoring(newFrame?: boolean): void;
  30826. private _fetchResult;
  30827. private _startMonitoringTime;
  30828. private _min;
  30829. private _max;
  30830. private _average;
  30831. private _current;
  30832. private _totalValueCount;
  30833. private _totalAccumulated;
  30834. private _lastSecAverage;
  30835. private _lastSecAccumulated;
  30836. private _lastSecTime;
  30837. private _lastSecValueCount;
  30838. }
  30839. /**
  30840. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30841. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30842. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30843. * @param name The name of the class, case should be preserved
  30844. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30845. */
  30846. export function className(name: string, module?: string): (target: Object) => void;
  30847. /**
  30848. * An implementation of a loop for asynchronous functions.
  30849. */
  30850. export class AsyncLoop {
  30851. /**
  30852. * Defines the number of iterations for the loop
  30853. */
  30854. iterations: number;
  30855. /**
  30856. * Defines the current index of the loop.
  30857. */
  30858. index: number;
  30859. private _done;
  30860. private _fn;
  30861. private _successCallback;
  30862. /**
  30863. * Constructor.
  30864. * @param iterations the number of iterations.
  30865. * @param func the function to run each iteration
  30866. * @param successCallback the callback that will be called upon succesful execution
  30867. * @param offset starting offset.
  30868. */
  30869. constructor(
  30870. /**
  30871. * Defines the number of iterations for the loop
  30872. */
  30873. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30874. /**
  30875. * Execute the next iteration. Must be called after the last iteration was finished.
  30876. */
  30877. executeNext(): void;
  30878. /**
  30879. * Break the loop and run the success callback.
  30880. */
  30881. breakLoop(): void;
  30882. /**
  30883. * Create and run an async loop.
  30884. * @param iterations the number of iterations.
  30885. * @param fn the function to run each iteration
  30886. * @param successCallback the callback that will be called upon succesful execution
  30887. * @param offset starting offset.
  30888. * @returns the created async loop object
  30889. */
  30890. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30891. /**
  30892. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30893. * @param iterations total number of iterations
  30894. * @param syncedIterations number of synchronous iterations in each async iteration.
  30895. * @param fn the function to call each iteration.
  30896. * @param callback a success call back that will be called when iterating stops.
  30897. * @param breakFunction a break condition (optional)
  30898. * @param timeout timeout settings for the setTimeout function. default - 0.
  30899. * @returns the created async loop object
  30900. */
  30901. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30902. }
  30903. }
  30904. declare module BABYLON {
  30905. /** @hidden */
  30906. export interface ICollisionCoordinator {
  30907. createCollider(): Collider;
  30908. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30909. init(scene: Scene): void;
  30910. }
  30911. /** @hidden */
  30912. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30913. private _scene;
  30914. private _scaledPosition;
  30915. private _scaledVelocity;
  30916. private _finalPosition;
  30917. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30918. createCollider(): Collider;
  30919. init(scene: Scene): void;
  30920. private _collideWithWorld;
  30921. }
  30922. }
  30923. declare module BABYLON {
  30924. /**
  30925. * This class defines the direct association between an animation and a target
  30926. */
  30927. export class TargetedAnimation {
  30928. /**
  30929. * Animation to perform
  30930. */
  30931. animation: Animation;
  30932. /**
  30933. * Target to animate
  30934. */
  30935. target: any;
  30936. }
  30937. /**
  30938. * Use this class to create coordinated animations on multiple targets
  30939. */
  30940. export class AnimationGroup implements IDisposable {
  30941. /** The name of the animation group */
  30942. name: string;
  30943. private _scene;
  30944. private _targetedAnimations;
  30945. private _animatables;
  30946. private _from;
  30947. private _to;
  30948. private _isStarted;
  30949. private _isPaused;
  30950. private _speedRatio;
  30951. /**
  30952. * Gets or sets the unique id of the node
  30953. */
  30954. uniqueId: number;
  30955. /**
  30956. * This observable will notify when one animation have ended
  30957. */
  30958. onAnimationEndObservable: Observable<TargetedAnimation>;
  30959. /**
  30960. * Observer raised when one animation loops
  30961. */
  30962. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30963. /**
  30964. * This observable will notify when all animations have ended.
  30965. */
  30966. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30967. /**
  30968. * This observable will notify when all animations have paused.
  30969. */
  30970. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30971. /**
  30972. * This observable will notify when all animations are playing.
  30973. */
  30974. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30975. /**
  30976. * Gets the first frame
  30977. */
  30978. readonly from: number;
  30979. /**
  30980. * Gets the last frame
  30981. */
  30982. readonly to: number;
  30983. /**
  30984. * Define if the animations are started
  30985. */
  30986. readonly isStarted: boolean;
  30987. /**
  30988. * Gets a value indicating that the current group is playing
  30989. */
  30990. readonly isPlaying: boolean;
  30991. /**
  30992. * Gets or sets the speed ratio to use for all animations
  30993. */
  30994. /**
  30995. * Gets or sets the speed ratio to use for all animations
  30996. */
  30997. speedRatio: number;
  30998. /**
  30999. * Gets the targeted animations for this animation group
  31000. */
  31001. readonly targetedAnimations: Array<TargetedAnimation>;
  31002. /**
  31003. * returning the list of animatables controlled by this animation group.
  31004. */
  31005. readonly animatables: Array<Animatable>;
  31006. /**
  31007. * Instantiates a new Animation Group.
  31008. * This helps managing several animations at once.
  31009. * @see http://doc.babylonjs.com/how_to/group
  31010. * @param name Defines the name of the group
  31011. * @param scene Defines the scene the group belongs to
  31012. */
  31013. constructor(
  31014. /** The name of the animation group */
  31015. name: string, scene?: Nullable<Scene>);
  31016. /**
  31017. * Add an animation (with its target) in the group
  31018. * @param animation defines the animation we want to add
  31019. * @param target defines the target of the animation
  31020. * @returns the TargetedAnimation object
  31021. */
  31022. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31023. /**
  31024. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31025. * It can add constant keys at begin or end
  31026. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31027. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31028. * @returns the animation group
  31029. */
  31030. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31031. /**
  31032. * Start all animations on given targets
  31033. * @param loop defines if animations must loop
  31034. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31035. * @param from defines the from key (optional)
  31036. * @param to defines the to key (optional)
  31037. * @returns the current animation group
  31038. */
  31039. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31040. /**
  31041. * Pause all animations
  31042. * @returns the animation group
  31043. */
  31044. pause(): AnimationGroup;
  31045. /**
  31046. * Play all animations to initial state
  31047. * This function will start() the animations if they were not started or will restart() them if they were paused
  31048. * @param loop defines if animations must loop
  31049. * @returns the animation group
  31050. */
  31051. play(loop?: boolean): AnimationGroup;
  31052. /**
  31053. * Reset all animations to initial state
  31054. * @returns the animation group
  31055. */
  31056. reset(): AnimationGroup;
  31057. /**
  31058. * Restart animations from key 0
  31059. * @returns the animation group
  31060. */
  31061. restart(): AnimationGroup;
  31062. /**
  31063. * Stop all animations
  31064. * @returns the animation group
  31065. */
  31066. stop(): AnimationGroup;
  31067. /**
  31068. * Set animation weight for all animatables
  31069. * @param weight defines the weight to use
  31070. * @return the animationGroup
  31071. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31072. */
  31073. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31074. /**
  31075. * Synchronize and normalize all animatables with a source animatable
  31076. * @param root defines the root animatable to synchronize with
  31077. * @return the animationGroup
  31078. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31079. */
  31080. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31081. /**
  31082. * Goes to a specific frame in this animation group
  31083. * @param frame the frame number to go to
  31084. * @return the animationGroup
  31085. */
  31086. goToFrame(frame: number): AnimationGroup;
  31087. /**
  31088. * Dispose all associated resources
  31089. */
  31090. dispose(): void;
  31091. private _checkAnimationGroupEnded;
  31092. /**
  31093. * Clone the current animation group and returns a copy
  31094. * @param newName defines the name of the new group
  31095. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31096. * @returns the new aniamtion group
  31097. */
  31098. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31099. /**
  31100. * Returns a new AnimationGroup object parsed from the source provided.
  31101. * @param parsedAnimationGroup defines the source
  31102. * @param scene defines the scene that will receive the animationGroup
  31103. * @returns a new AnimationGroup
  31104. */
  31105. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31106. /**
  31107. * Returns the string "AnimationGroup"
  31108. * @returns "AnimationGroup"
  31109. */
  31110. getClassName(): string;
  31111. /**
  31112. * Creates a detailled string about the object
  31113. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31114. * @returns a string representing the object
  31115. */
  31116. toString(fullDetails?: boolean): string;
  31117. }
  31118. }
  31119. declare module BABYLON {
  31120. /**
  31121. * Define an interface for all classes that will hold resources
  31122. */
  31123. export interface IDisposable {
  31124. /**
  31125. * Releases all held resources
  31126. */
  31127. dispose(): void;
  31128. }
  31129. /** Interface defining initialization parameters for Scene class */
  31130. export interface SceneOptions {
  31131. /**
  31132. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31133. * It will improve performance when the number of geometries becomes important.
  31134. */
  31135. useGeometryUniqueIdsMap?: boolean;
  31136. /**
  31137. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31138. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31139. */
  31140. useMaterialMeshMap?: boolean;
  31141. /**
  31142. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31143. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31144. */
  31145. useClonedMeshhMap?: boolean;
  31146. }
  31147. /**
  31148. * Represents a scene to be rendered by the engine.
  31149. * @see http://doc.babylonjs.com/features/scene
  31150. */
  31151. export class Scene extends AbstractScene implements IAnimatable {
  31152. private static _uniqueIdCounter;
  31153. /** The fog is deactivated */
  31154. static readonly FOGMODE_NONE: number;
  31155. /** The fog density is following an exponential function */
  31156. static readonly FOGMODE_EXP: number;
  31157. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31158. static readonly FOGMODE_EXP2: number;
  31159. /** The fog density is following a linear function. */
  31160. static readonly FOGMODE_LINEAR: number;
  31161. /**
  31162. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31164. */
  31165. static MinDeltaTime: number;
  31166. /**
  31167. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31168. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31169. */
  31170. static MaxDeltaTime: number;
  31171. /**
  31172. * Factory used to create the default material.
  31173. * @param name The name of the material to create
  31174. * @param scene The scene to create the material for
  31175. * @returns The default material
  31176. */
  31177. static DefaultMaterialFactory(scene: Scene): Material;
  31178. /**
  31179. * Factory used to create the a collision coordinator.
  31180. * @returns The collision coordinator
  31181. */
  31182. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31183. /** @hidden */ protected readonly _isScene: boolean;
  31184. /**
  31185. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31186. */
  31187. autoClear: boolean;
  31188. /**
  31189. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31190. */
  31191. autoClearDepthAndStencil: boolean;
  31192. /**
  31193. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31194. */
  31195. clearColor: Color4;
  31196. /**
  31197. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31198. */
  31199. ambientColor: Color3;
  31200. /**
  31201. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31202. * It should only be one of the following (if not the default embedded one):
  31203. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31204. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31205. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31206. * The material properties need to be setup according to the type of texture in use.
  31207. */
  31208. environmentBRDFTexture: BaseTexture;
  31209. /** @hidden */
  31210. protected _environmentTexture: Nullable<BaseTexture>;
  31211. /**
  31212. * Texture used in all pbr material as the reflection texture.
  31213. * As in the majority of the scene they are the same (exception for multi room and so on),
  31214. * this is easier to reference from here than from all the materials.
  31215. */
  31216. /**
  31217. * Texture used in all pbr material as the reflection texture.
  31218. * As in the majority of the scene they are the same (exception for multi room and so on),
  31219. * this is easier to set here than in all the materials.
  31220. */
  31221. environmentTexture: Nullable<BaseTexture>;
  31222. /** @hidden */
  31223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31224. /**
  31225. * Default image processing configuration used either in the rendering
  31226. * Forward main pass or through the imageProcessingPostProcess if present.
  31227. * As in the majority of the scene they are the same (exception for multi camera),
  31228. * this is easier to reference from here than from all the materials and post process.
  31229. *
  31230. * No setter as we it is a shared configuration, you can set the values instead.
  31231. */
  31232. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31233. private _forceWireframe;
  31234. /**
  31235. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31236. */
  31237. forceWireframe: boolean;
  31238. private _forcePointsCloud;
  31239. /**
  31240. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31241. */
  31242. forcePointsCloud: boolean;
  31243. /**
  31244. * Gets or sets the active clipplane 1
  31245. */
  31246. clipPlane: Nullable<Plane>;
  31247. /**
  31248. * Gets or sets the active clipplane 2
  31249. */
  31250. clipPlane2: Nullable<Plane>;
  31251. /**
  31252. * Gets or sets the active clipplane 3
  31253. */
  31254. clipPlane3: Nullable<Plane>;
  31255. /**
  31256. * Gets or sets the active clipplane 4
  31257. */
  31258. clipPlane4: Nullable<Plane>;
  31259. /**
  31260. * Gets or sets a boolean indicating if animations are enabled
  31261. */
  31262. animationsEnabled: boolean;
  31263. private _animationPropertiesOverride;
  31264. /**
  31265. * Gets or sets the animation properties override
  31266. */
  31267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31268. /**
  31269. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31270. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31271. */
  31272. useConstantAnimationDeltaTime: boolean;
  31273. /**
  31274. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31275. * Please note that it requires to run a ray cast through the scene on every frame
  31276. */
  31277. constantlyUpdateMeshUnderPointer: boolean;
  31278. /**
  31279. * Defines the HTML cursor to use when hovering over interactive elements
  31280. */
  31281. hoverCursor: string;
  31282. /**
  31283. * Defines the HTML default cursor to use (empty by default)
  31284. */
  31285. defaultCursor: string;
  31286. /**
  31287. * This is used to call preventDefault() on pointer down
  31288. * in order to block unwanted artifacts like system double clicks
  31289. */
  31290. preventDefaultOnPointerDown: boolean;
  31291. /**
  31292. * This is used to call preventDefault() on pointer up
  31293. * in order to block unwanted artifacts like system double clicks
  31294. */
  31295. preventDefaultOnPointerUp: boolean;
  31296. /**
  31297. * Gets or sets user defined metadata
  31298. */
  31299. metadata: any;
  31300. /**
  31301. * For internal use only. Please do not use.
  31302. */
  31303. reservedDataStore: any;
  31304. /**
  31305. * Gets the name of the plugin used to load this scene (null by default)
  31306. */
  31307. loadingPluginName: string;
  31308. /**
  31309. * Use this array to add regular expressions used to disable offline support for specific urls
  31310. */
  31311. disableOfflineSupportExceptionRules: RegExp[];
  31312. /**
  31313. * An event triggered when the scene is disposed.
  31314. */
  31315. onDisposeObservable: Observable<Scene>;
  31316. private _onDisposeObserver;
  31317. /** Sets a function to be executed when this scene is disposed. */
  31318. onDispose: () => void;
  31319. /**
  31320. * An event triggered before rendering the scene (right after animations and physics)
  31321. */
  31322. onBeforeRenderObservable: Observable<Scene>;
  31323. private _onBeforeRenderObserver;
  31324. /** Sets a function to be executed before rendering this scene */
  31325. beforeRender: Nullable<() => void>;
  31326. /**
  31327. * An event triggered after rendering the scene
  31328. */
  31329. onAfterRenderObservable: Observable<Scene>;
  31330. private _onAfterRenderObserver;
  31331. /** Sets a function to be executed after rendering this scene */
  31332. afterRender: Nullable<() => void>;
  31333. /**
  31334. * An event triggered before animating the scene
  31335. */
  31336. onBeforeAnimationsObservable: Observable<Scene>;
  31337. /**
  31338. * An event triggered after animations processing
  31339. */
  31340. onAfterAnimationsObservable: Observable<Scene>;
  31341. /**
  31342. * An event triggered before draw calls are ready to be sent
  31343. */
  31344. onBeforeDrawPhaseObservable: Observable<Scene>;
  31345. /**
  31346. * An event triggered after draw calls have been sent
  31347. */
  31348. onAfterDrawPhaseObservable: Observable<Scene>;
  31349. /**
  31350. * An event triggered when the scene is ready
  31351. */
  31352. onReadyObservable: Observable<Scene>;
  31353. /**
  31354. * An event triggered before rendering a camera
  31355. */
  31356. onBeforeCameraRenderObservable: Observable<Camera>;
  31357. private _onBeforeCameraRenderObserver;
  31358. /** Sets a function to be executed before rendering a camera*/
  31359. beforeCameraRender: () => void;
  31360. /**
  31361. * An event triggered after rendering a camera
  31362. */
  31363. onAfterCameraRenderObservable: Observable<Camera>;
  31364. private _onAfterCameraRenderObserver;
  31365. /** Sets a function to be executed after rendering a camera*/
  31366. afterCameraRender: () => void;
  31367. /**
  31368. * An event triggered when active meshes evaluation is about to start
  31369. */
  31370. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31371. /**
  31372. * An event triggered when active meshes evaluation is done
  31373. */
  31374. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31375. /**
  31376. * An event triggered when particles rendering is about to start
  31377. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31378. */
  31379. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31380. /**
  31381. * An event triggered when particles rendering is done
  31382. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31383. */
  31384. onAfterParticlesRenderingObservable: Observable<Scene>;
  31385. /**
  31386. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31387. */
  31388. onDataLoadedObservable: Observable<Scene>;
  31389. /**
  31390. * An event triggered when a camera is created
  31391. */
  31392. onNewCameraAddedObservable: Observable<Camera>;
  31393. /**
  31394. * An event triggered when a camera is removed
  31395. */
  31396. onCameraRemovedObservable: Observable<Camera>;
  31397. /**
  31398. * An event triggered when a light is created
  31399. */
  31400. onNewLightAddedObservable: Observable<Light>;
  31401. /**
  31402. * An event triggered when a light is removed
  31403. */
  31404. onLightRemovedObservable: Observable<Light>;
  31405. /**
  31406. * An event triggered when a geometry is created
  31407. */
  31408. onNewGeometryAddedObservable: Observable<Geometry>;
  31409. /**
  31410. * An event triggered when a geometry is removed
  31411. */
  31412. onGeometryRemovedObservable: Observable<Geometry>;
  31413. /**
  31414. * An event triggered when a transform node is created
  31415. */
  31416. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31417. /**
  31418. * An event triggered when a transform node is removed
  31419. */
  31420. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31421. /**
  31422. * An event triggered when a mesh is created
  31423. */
  31424. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31425. /**
  31426. * An event triggered when a mesh is removed
  31427. */
  31428. onMeshRemovedObservable: Observable<AbstractMesh>;
  31429. /**
  31430. * An event triggered when a skeleton is created
  31431. */
  31432. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31433. /**
  31434. * An event triggered when a skeleton is removed
  31435. */
  31436. onSkeletonRemovedObservable: Observable<Skeleton>;
  31437. /**
  31438. * An event triggered when a material is created
  31439. */
  31440. onNewMaterialAddedObservable: Observable<Material>;
  31441. /**
  31442. * An event triggered when a material is removed
  31443. */
  31444. onMaterialRemovedObservable: Observable<Material>;
  31445. /**
  31446. * An event triggered when a texture is created
  31447. */
  31448. onNewTextureAddedObservable: Observable<BaseTexture>;
  31449. /**
  31450. * An event triggered when a texture is removed
  31451. */
  31452. onTextureRemovedObservable: Observable<BaseTexture>;
  31453. /**
  31454. * An event triggered when render targets are about to be rendered
  31455. * Can happen multiple times per frame.
  31456. */
  31457. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31458. /**
  31459. * An event triggered when render targets were rendered.
  31460. * Can happen multiple times per frame.
  31461. */
  31462. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31463. /**
  31464. * An event triggered before calculating deterministic simulation step
  31465. */
  31466. onBeforeStepObservable: Observable<Scene>;
  31467. /**
  31468. * An event triggered after calculating deterministic simulation step
  31469. */
  31470. onAfterStepObservable: Observable<Scene>;
  31471. /**
  31472. * An event triggered when the activeCamera property is updated
  31473. */
  31474. onActiveCameraChanged: Observable<Scene>;
  31475. /**
  31476. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31477. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31478. * 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)
  31479. */
  31480. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31481. /**
  31482. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31483. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31484. * 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)
  31485. */
  31486. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31487. /**
  31488. * This Observable will when a mesh has been imported into the scene.
  31489. */
  31490. onMeshImportedObservable: Observable<AbstractMesh>;
  31491. /**
  31492. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31493. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31494. */
  31495. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31496. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31497. /**
  31498. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31499. */
  31500. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31501. /**
  31502. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31503. */
  31504. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31505. /**
  31506. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31507. */
  31508. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31509. private _onPointerMove;
  31510. private _onPointerDown;
  31511. private _onPointerUp;
  31512. /** Callback called when a pointer move is detected */
  31513. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31514. /** Callback called when a pointer down is detected */
  31515. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31516. /** Callback called when a pointer up is detected */
  31517. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31518. /** Callback called when a pointer pick is detected */
  31519. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31520. /**
  31521. * 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).
  31522. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31523. */
  31524. onPrePointerObservable: Observable<PointerInfoPre>;
  31525. /**
  31526. * Observable event triggered each time an input event is received from the rendering canvas
  31527. */
  31528. onPointerObservable: Observable<PointerInfo>;
  31529. /**
  31530. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31531. */
  31532. readonly unTranslatedPointer: Vector2;
  31533. /** The distance in pixel that you have to move to prevent some events */
  31534. static DragMovementThreshold: number;
  31535. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31536. static LongPressDelay: number;
  31537. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31538. static DoubleClickDelay: number;
  31539. /** If you need to check double click without raising a single click at first click, enable this flag */
  31540. static ExclusiveDoubleClickMode: boolean;
  31541. private _initClickEvent;
  31542. private _initActionManager;
  31543. private _delayedSimpleClick;
  31544. private _delayedSimpleClickTimeout;
  31545. private _previousDelayedSimpleClickTimeout;
  31546. private _meshPickProceed;
  31547. private _previousButtonPressed;
  31548. private _currentPickResult;
  31549. private _previousPickResult;
  31550. private _totalPointersPressed;
  31551. private _doubleClickOccured;
  31552. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31553. cameraToUseForPointers: Nullable<Camera>;
  31554. private _pointerX;
  31555. private _pointerY;
  31556. private _unTranslatedPointerX;
  31557. private _unTranslatedPointerY;
  31558. private _startingPointerPosition;
  31559. private _previousStartingPointerPosition;
  31560. private _startingPointerTime;
  31561. private _previousStartingPointerTime;
  31562. private _pointerCaptures;
  31563. private _timeAccumulator;
  31564. private _currentStepId;
  31565. private _currentInternalStep;
  31566. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31567. /**
  31568. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31569. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31570. */
  31571. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31572. /**
  31573. * Observable event triggered each time an keyboard event is received from the hosting window
  31574. */
  31575. onKeyboardObservable: Observable<KeyboardInfo>;
  31576. private _onKeyDown;
  31577. private _onKeyUp;
  31578. private _onCanvasFocusObserver;
  31579. private _onCanvasBlurObserver;
  31580. private _useRightHandedSystem;
  31581. /**
  31582. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31583. */
  31584. useRightHandedSystem: boolean;
  31585. /**
  31586. * Sets the step Id used by deterministic lock step
  31587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31588. * @param newStepId defines the step Id
  31589. */
  31590. setStepId(newStepId: number): void;
  31591. /**
  31592. * Gets the step Id used by deterministic lock step
  31593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31594. * @returns the step Id
  31595. */
  31596. getStepId(): number;
  31597. /**
  31598. * Gets the internal step used by deterministic lock step
  31599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31600. * @returns the internal step
  31601. */
  31602. getInternalStep(): number;
  31603. private _fogEnabled;
  31604. /**
  31605. * Gets or sets a boolean indicating if fog is enabled on this scene
  31606. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31607. * (Default is true)
  31608. */
  31609. fogEnabled: boolean;
  31610. private _fogMode;
  31611. /**
  31612. * Gets or sets the fog mode to use
  31613. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31614. * | mode | value |
  31615. * | --- | --- |
  31616. * | FOGMODE_NONE | 0 |
  31617. * | FOGMODE_EXP | 1 |
  31618. * | FOGMODE_EXP2 | 2 |
  31619. * | FOGMODE_LINEAR | 3 |
  31620. */
  31621. fogMode: number;
  31622. /**
  31623. * Gets or sets the fog color to use
  31624. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31625. * (Default is Color3(0.2, 0.2, 0.3))
  31626. */
  31627. fogColor: Color3;
  31628. /**
  31629. * Gets or sets the fog density to use
  31630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31631. * (Default is 0.1)
  31632. */
  31633. fogDensity: number;
  31634. /**
  31635. * Gets or sets the fog start distance to use
  31636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31637. * (Default is 0)
  31638. */
  31639. fogStart: number;
  31640. /**
  31641. * Gets or sets the fog end distance to use
  31642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31643. * (Default is 1000)
  31644. */
  31645. fogEnd: number;
  31646. private _shadowsEnabled;
  31647. /**
  31648. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31649. */
  31650. shadowsEnabled: boolean;
  31651. private _lightsEnabled;
  31652. /**
  31653. * Gets or sets a boolean indicating if lights are enabled on this scene
  31654. */
  31655. lightsEnabled: boolean;
  31656. /** All of the active cameras added to this scene. */
  31657. activeCameras: Camera[];
  31658. /** @hidden */ activeCamera: Nullable<Camera>;
  31659. /** Gets or sets the current active camera */
  31660. activeCamera: Nullable<Camera>;
  31661. private _defaultMaterial;
  31662. /** The default material used on meshes when no material is affected */
  31663. /** The default material used on meshes when no material is affected */
  31664. defaultMaterial: Material;
  31665. private _texturesEnabled;
  31666. /**
  31667. * Gets or sets a boolean indicating if textures are enabled on this scene
  31668. */
  31669. texturesEnabled: boolean;
  31670. /**
  31671. * Gets or sets a boolean indicating if particles are enabled on this scene
  31672. */
  31673. particlesEnabled: boolean;
  31674. /**
  31675. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31676. */
  31677. spritesEnabled: boolean;
  31678. private _skeletonsEnabled;
  31679. /**
  31680. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31681. */
  31682. skeletonsEnabled: boolean;
  31683. /**
  31684. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31685. */
  31686. lensFlaresEnabled: boolean;
  31687. /**
  31688. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31690. */
  31691. collisionsEnabled: boolean;
  31692. private _collisionCoordinator;
  31693. /** @hidden */
  31694. readonly collisionCoordinator: ICollisionCoordinator;
  31695. /**
  31696. * Defines the gravity applied to this scene (used only for collisions)
  31697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31698. */
  31699. gravity: Vector3;
  31700. /**
  31701. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31702. */
  31703. postProcessesEnabled: boolean;
  31704. /**
  31705. * The list of postprocesses added to the scene
  31706. */
  31707. postProcesses: PostProcess[];
  31708. /**
  31709. * Gets the current postprocess manager
  31710. */
  31711. postProcessManager: PostProcessManager;
  31712. /**
  31713. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31714. */
  31715. renderTargetsEnabled: boolean;
  31716. /**
  31717. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31718. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31719. */
  31720. dumpNextRenderTargets: boolean;
  31721. /**
  31722. * The list of user defined render targets added to the scene
  31723. */
  31724. customRenderTargets: RenderTargetTexture[];
  31725. /**
  31726. * Defines if texture loading must be delayed
  31727. * If true, textures will only be loaded when they need to be rendered
  31728. */
  31729. useDelayedTextureLoading: boolean;
  31730. /**
  31731. * Gets the list of meshes imported to the scene through SceneLoader
  31732. */
  31733. importedMeshesFiles: String[];
  31734. /**
  31735. * Gets or sets a boolean indicating if probes are enabled on this scene
  31736. */
  31737. probesEnabled: boolean;
  31738. /**
  31739. * Gets or sets the current offline provider to use to store scene data
  31740. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31741. */
  31742. offlineProvider: IOfflineProvider;
  31743. /**
  31744. * Gets or sets the action manager associated with the scene
  31745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31746. */
  31747. actionManager: AbstractActionManager;
  31748. private _meshesForIntersections;
  31749. /**
  31750. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31751. */
  31752. proceduralTexturesEnabled: boolean;
  31753. private _engine;
  31754. private _totalVertices;
  31755. /** @hidden */ activeIndices: PerfCounter;
  31756. /** @hidden */ activeParticles: PerfCounter;
  31757. /** @hidden */ activeBones: PerfCounter;
  31758. private _animationRatio;
  31759. /** @hidden */ animationTimeLast: number;
  31760. /** @hidden */ animationTime: number;
  31761. /**
  31762. * Gets or sets a general scale for animation speed
  31763. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31764. */
  31765. animationTimeScale: number;
  31766. /** @hidden */ cachedMaterial: Nullable<Material>;
  31767. /** @hidden */ cachedEffect: Nullable<Effect>;
  31768. /** @hidden */ cachedVisibility: Nullable<number>;
  31769. private _renderId;
  31770. private _frameId;
  31771. private _executeWhenReadyTimeoutId;
  31772. private _intermediateRendering;
  31773. private _viewUpdateFlag;
  31774. private _projectionUpdateFlag;
  31775. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31776. private _activeRequests;
  31777. /** @hidden */ pendingData: any[];
  31778. private _isDisposed;
  31779. /**
  31780. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31781. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31782. */
  31783. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31784. private _activeMeshes;
  31785. private _processedMaterials;
  31786. private _renderTargets;
  31787. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31788. private _activeSkeletons;
  31789. private _softwareSkinnedMeshes;
  31790. private _renderingManager;
  31791. /** @hidden */ activeAnimatables: Animatable[];
  31792. private _transformMatrix;
  31793. private _sceneUbo;
  31794. /** @hidden */ viewMatrix: Matrix;
  31795. private _projectionMatrix;
  31796. private _wheelEventName;
  31797. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31798. /** @hidden */ frustumPlanes: Plane[];
  31799. /**
  31800. * Gets the list of frustum planes (built from the active camera)
  31801. */
  31802. readonly frustumPlanes: Plane[];
  31803. /**
  31804. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31805. * This is useful if there are more lights that the maximum simulteanous authorized
  31806. */
  31807. requireLightSorting: boolean;
  31808. /** @hidden */
  31809. readonly useMaterialMeshMap: boolean;
  31810. /** @hidden */
  31811. readonly useClonedMeshhMap: boolean;
  31812. private _pointerOverMesh;
  31813. private _pickedDownMesh;
  31814. private _pickedUpMesh;
  31815. private _externalData;
  31816. private _uid;
  31817. /**
  31818. * @hidden
  31819. * Backing store of defined scene components.
  31820. */ components: ISceneComponent[];
  31821. /**
  31822. * @hidden
  31823. * Backing store of defined scene components.
  31824. */ serializableComponents: ISceneSerializableComponent[];
  31825. /**
  31826. * List of components to register on the next registration step.
  31827. */
  31828. private _transientComponents;
  31829. /**
  31830. * Registers the transient components if needed.
  31831. */
  31832. private _registerTransientComponents;
  31833. /**
  31834. * @hidden
  31835. * Add a component to the scene.
  31836. * Note that the ccomponent could be registered on th next frame if this is called after
  31837. * the register component stage.
  31838. * @param component Defines the component to add to the scene
  31839. */ addComponent(component: ISceneComponent): void;
  31840. /**
  31841. * @hidden
  31842. * Gets a component from the scene.
  31843. * @param name defines the name of the component to retrieve
  31844. * @returns the component or null if not present
  31845. */ getComponent(name: string): Nullable<ISceneComponent>;
  31846. /**
  31847. * @hidden
  31848. * Defines the actions happening before camera updates.
  31849. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31850. /**
  31851. * @hidden
  31852. * Defines the actions happening before clear the canvas.
  31853. */ beforeClearStage: Stage<SimpleStageAction>;
  31854. /**
  31855. * @hidden
  31856. * Defines the actions when collecting render targets for the frame.
  31857. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31858. /**
  31859. * @hidden
  31860. * Defines the actions happening for one camera in the frame.
  31861. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31862. /**
  31863. * @hidden
  31864. * Defines the actions happening during the per mesh ready checks.
  31865. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31866. /**
  31867. * @hidden
  31868. * Defines the actions happening before evaluate active mesh checks.
  31869. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31870. /**
  31871. * @hidden
  31872. * Defines the actions happening during the evaluate sub mesh checks.
  31873. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31874. /**
  31875. * @hidden
  31876. * Defines the actions happening during the active mesh stage.
  31877. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31878. /**
  31879. * @hidden
  31880. * Defines the actions happening during the per camera render target step.
  31881. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  31882. /**
  31883. * @hidden
  31884. * Defines the actions happening just before the active camera is drawing.
  31885. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31886. /**
  31887. * @hidden
  31888. * Defines the actions happening just before a render target is drawing.
  31889. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31890. /**
  31891. * @hidden
  31892. * Defines the actions happening just before a rendering group is drawing.
  31893. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31894. /**
  31895. * @hidden
  31896. * Defines the actions happening just before a mesh is drawing.
  31897. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31898. /**
  31899. * @hidden
  31900. * Defines the actions happening just after a mesh has been drawn.
  31901. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31902. /**
  31903. * @hidden
  31904. * Defines the actions happening just after a rendering group has been drawn.
  31905. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31906. /**
  31907. * @hidden
  31908. * Defines the actions happening just after the active camera has been drawn.
  31909. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31910. /**
  31911. * @hidden
  31912. * Defines the actions happening just after a render target has been drawn.
  31913. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31914. /**
  31915. * @hidden
  31916. * Defines the actions happening just after rendering all cameras and computing intersections.
  31917. */ afterRenderStage: Stage<SimpleStageAction>;
  31918. /**
  31919. * @hidden
  31920. * Defines the actions happening when a pointer move event happens.
  31921. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31922. /**
  31923. * @hidden
  31924. * Defines the actions happening when a pointer down event happens.
  31925. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31926. /**
  31927. * @hidden
  31928. * Defines the actions happening when a pointer up event happens.
  31929. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31930. /**
  31931. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31932. */
  31933. private geometriesByUniqueId;
  31934. /**
  31935. * Creates a new Scene
  31936. * @param engine defines the engine to use to render this scene
  31937. * @param options defines the scene options
  31938. */
  31939. constructor(engine: Engine, options?: SceneOptions);
  31940. /**
  31941. * Gets a string idenfifying the name of the class
  31942. * @returns "Scene" string
  31943. */
  31944. getClassName(): string;
  31945. private _defaultMeshCandidates;
  31946. /**
  31947. * @hidden
  31948. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31949. private _defaultSubMeshCandidates;
  31950. /**
  31951. * @hidden
  31952. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31953. /**
  31954. * Sets the default candidate providers for the scene.
  31955. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31956. * and getCollidingSubMeshCandidates to their default function
  31957. */
  31958. setDefaultCandidateProviders(): void;
  31959. /**
  31960. * Gets the mesh that is currently under the pointer
  31961. */
  31962. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31963. /**
  31964. * Gets or sets the current on-screen X position of the pointer
  31965. */
  31966. pointerX: number;
  31967. /**
  31968. * Gets or sets the current on-screen Y position of the pointer
  31969. */
  31970. pointerY: number;
  31971. /**
  31972. * Gets the cached material (ie. the latest rendered one)
  31973. * @returns the cached material
  31974. */
  31975. getCachedMaterial(): Nullable<Material>;
  31976. /**
  31977. * Gets the cached effect (ie. the latest rendered one)
  31978. * @returns the cached effect
  31979. */
  31980. getCachedEffect(): Nullable<Effect>;
  31981. /**
  31982. * Gets the cached visibility state (ie. the latest rendered one)
  31983. * @returns the cached visibility state
  31984. */
  31985. getCachedVisibility(): Nullable<number>;
  31986. /**
  31987. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31988. * @param material defines the current material
  31989. * @param effect defines the current effect
  31990. * @param visibility defines the current visibility state
  31991. * @returns true if one parameter is not cached
  31992. */
  31993. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31994. /**
  31995. * Gets the engine associated with the scene
  31996. * @returns an Engine
  31997. */
  31998. getEngine(): Engine;
  31999. /**
  32000. * Gets the total number of vertices rendered per frame
  32001. * @returns the total number of vertices rendered per frame
  32002. */
  32003. getTotalVertices(): number;
  32004. /**
  32005. * Gets the performance counter for total vertices
  32006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32007. */
  32008. readonly totalVerticesPerfCounter: PerfCounter;
  32009. /**
  32010. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32011. * @returns the total number of active indices rendered per frame
  32012. */
  32013. getActiveIndices(): number;
  32014. /**
  32015. * Gets the performance counter for active indices
  32016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32017. */
  32018. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32019. /**
  32020. * Gets the total number of active particles rendered per frame
  32021. * @returns the total number of active particles rendered per frame
  32022. */
  32023. getActiveParticles(): number;
  32024. /**
  32025. * Gets the performance counter for active particles
  32026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32027. */
  32028. readonly activeParticlesPerfCounter: PerfCounter;
  32029. /**
  32030. * Gets the total number of active bones rendered per frame
  32031. * @returns the total number of active bones rendered per frame
  32032. */
  32033. getActiveBones(): number;
  32034. /**
  32035. * Gets the performance counter for active bones
  32036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32037. */
  32038. readonly activeBonesPerfCounter: PerfCounter;
  32039. /**
  32040. * Gets the array of active meshes
  32041. * @returns an array of AbstractMesh
  32042. */
  32043. getActiveMeshes(): SmartArray<AbstractMesh>;
  32044. /**
  32045. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32046. * @returns a number
  32047. */
  32048. getAnimationRatio(): number;
  32049. /**
  32050. * Gets an unique Id for the current render phase
  32051. * @returns a number
  32052. */
  32053. getRenderId(): number;
  32054. /**
  32055. * Gets an unique Id for the current frame
  32056. * @returns a number
  32057. */
  32058. getFrameId(): number;
  32059. /** Call this function if you want to manually increment the render Id*/
  32060. incrementRenderId(): void;
  32061. private _updatePointerPosition;
  32062. private _createUbo;
  32063. private _setRayOnPointerInfo;
  32064. /**
  32065. * Use this method to simulate a pointer move on a mesh
  32066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32069. * @returns the current scene
  32070. */
  32071. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32072. private _processPointerMove;
  32073. private _checkPrePointerObservable;
  32074. /**
  32075. * Use this method to simulate a pointer down on a mesh
  32076. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32077. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32078. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32079. * @returns the current scene
  32080. */
  32081. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32082. private _processPointerDown;
  32083. /**
  32084. * Use this method to simulate a pointer up on a mesh
  32085. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32086. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32087. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32088. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32089. * @returns the current scene
  32090. */
  32091. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32092. private _processPointerUp;
  32093. /**
  32094. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32095. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32096. * @returns true if the pointer was captured
  32097. */
  32098. isPointerCaptured(pointerId?: number): boolean;
  32099. /** @hidden */ isPointerSwiping(): boolean;
  32100. /**
  32101. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32102. * @param attachUp defines if you want to attach events to pointerup
  32103. * @param attachDown defines if you want to attach events to pointerdown
  32104. * @param attachMove defines if you want to attach events to pointermove
  32105. */
  32106. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32107. /** Detaches all event handlers*/
  32108. detachControl(): void;
  32109. /**
  32110. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32111. * Delay loaded resources are not taking in account
  32112. * @return true if all required resources are ready
  32113. */
  32114. isReady(): boolean;
  32115. /** Resets all cached information relative to material (including effect and visibility) */
  32116. resetCachedMaterial(): void;
  32117. /**
  32118. * Registers a function to be called before every frame render
  32119. * @param func defines the function to register
  32120. */
  32121. registerBeforeRender(func: () => void): void;
  32122. /**
  32123. * Unregisters a function called before every frame render
  32124. * @param func defines the function to unregister
  32125. */
  32126. unregisterBeforeRender(func: () => void): void;
  32127. /**
  32128. * Registers a function to be called after every frame render
  32129. * @param func defines the function to register
  32130. */
  32131. registerAfterRender(func: () => void): void;
  32132. /**
  32133. * Unregisters a function called after every frame render
  32134. * @param func defines the function to unregister
  32135. */
  32136. unregisterAfterRender(func: () => void): void;
  32137. private _executeOnceBeforeRender;
  32138. /**
  32139. * The provided function will run before render once and will be disposed afterwards.
  32140. * A timeout delay can be provided so that the function will be executed in N ms.
  32141. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32142. * @param func The function to be executed.
  32143. * @param timeout optional delay in ms
  32144. */
  32145. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32146. /** @hidden */ addPendingData(data: any): void;
  32147. /** @hidden */ removePendingData(data: any): void;
  32148. /**
  32149. * Returns the number of items waiting to be loaded
  32150. * @returns the number of items waiting to be loaded
  32151. */
  32152. getWaitingItemsCount(): number;
  32153. /**
  32154. * Returns a boolean indicating if the scene is still loading data
  32155. */
  32156. readonly isLoading: boolean;
  32157. /**
  32158. * Registers a function to be executed when the scene is ready
  32159. * @param {Function} func - the function to be executed
  32160. */
  32161. executeWhenReady(func: () => void): void;
  32162. /**
  32163. * Returns a promise that resolves when the scene is ready
  32164. * @returns A promise that resolves when the scene is ready
  32165. */
  32166. whenReadyAsync(): Promise<void>;
  32167. /** @hidden */ checkIsReady(): void;
  32168. /**
  32169. * Gets all animatable attached to the scene
  32170. */
  32171. readonly animatables: Animatable[];
  32172. /**
  32173. * Resets the last animation time frame.
  32174. * Useful to override when animations start running when loading a scene for the first time.
  32175. */
  32176. resetLastAnimationTimeFrame(): void;
  32177. /**
  32178. * Gets the current view matrix
  32179. * @returns a Matrix
  32180. */
  32181. getViewMatrix(): Matrix;
  32182. /**
  32183. * Gets the current projection matrix
  32184. * @returns a Matrix
  32185. */
  32186. getProjectionMatrix(): Matrix;
  32187. /**
  32188. * Gets the current transform matrix
  32189. * @returns a Matrix made of View * Projection
  32190. */
  32191. getTransformMatrix(): Matrix;
  32192. /**
  32193. * Sets the current transform matrix
  32194. * @param viewL defines the View matrix to use
  32195. * @param projectionL defines the Projection matrix to use
  32196. * @param viewR defines the right View matrix to use (if provided)
  32197. * @param projectionR defines the right Projection matrix to use (if provided)
  32198. */
  32199. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32200. /**
  32201. * Gets the uniform buffer used to store scene data
  32202. * @returns a UniformBuffer
  32203. */
  32204. getSceneUniformBuffer(): UniformBuffer;
  32205. /**
  32206. * Gets an unique (relatively to the current scene) Id
  32207. * @returns an unique number for the scene
  32208. */
  32209. getUniqueId(): number;
  32210. /**
  32211. * Add a mesh to the list of scene's meshes
  32212. * @param newMesh defines the mesh to add
  32213. * @param recursive if all child meshes should also be added to the scene
  32214. */
  32215. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32216. /**
  32217. * Remove a mesh for the list of scene's meshes
  32218. * @param toRemove defines the mesh to remove
  32219. * @param recursive if all child meshes should also be removed from the scene
  32220. * @returns the index where the mesh was in the mesh list
  32221. */
  32222. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32223. /**
  32224. * Add a transform node to the list of scene's transform nodes
  32225. * @param newTransformNode defines the transform node to add
  32226. */
  32227. addTransformNode(newTransformNode: TransformNode): void;
  32228. /**
  32229. * Remove a transform node for the list of scene's transform nodes
  32230. * @param toRemove defines the transform node to remove
  32231. * @returns the index where the transform node was in the transform node list
  32232. */
  32233. removeTransformNode(toRemove: TransformNode): number;
  32234. /**
  32235. * Remove a skeleton for the list of scene's skeletons
  32236. * @param toRemove defines the skeleton to remove
  32237. * @returns the index where the skeleton was in the skeleton list
  32238. */
  32239. removeSkeleton(toRemove: Skeleton): number;
  32240. /**
  32241. * Remove a morph target for the list of scene's morph targets
  32242. * @param toRemove defines the morph target to remove
  32243. * @returns the index where the morph target was in the morph target list
  32244. */
  32245. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32246. /**
  32247. * Remove a light for the list of scene's lights
  32248. * @param toRemove defines the light to remove
  32249. * @returns the index where the light was in the light list
  32250. */
  32251. removeLight(toRemove: Light): number;
  32252. /**
  32253. * Remove a camera for the list of scene's cameras
  32254. * @param toRemove defines the camera to remove
  32255. * @returns the index where the camera was in the camera list
  32256. */
  32257. removeCamera(toRemove: Camera): number;
  32258. /**
  32259. * Remove a particle system for the list of scene's particle systems
  32260. * @param toRemove defines the particle system to remove
  32261. * @returns the index where the particle system was in the particle system list
  32262. */
  32263. removeParticleSystem(toRemove: IParticleSystem): number;
  32264. /**
  32265. * Remove a animation for the list of scene's animations
  32266. * @param toRemove defines the animation to remove
  32267. * @returns the index where the animation was in the animation list
  32268. */
  32269. removeAnimation(toRemove: Animation): number;
  32270. /**
  32271. * Removes the given animation group from this scene.
  32272. * @param toRemove The animation group to remove
  32273. * @returns The index of the removed animation group
  32274. */
  32275. removeAnimationGroup(toRemove: AnimationGroup): number;
  32276. /**
  32277. * Removes the given multi-material from this scene.
  32278. * @param toRemove The multi-material to remove
  32279. * @returns The index of the removed multi-material
  32280. */
  32281. removeMultiMaterial(toRemove: MultiMaterial): number;
  32282. /**
  32283. * Removes the given material from this scene.
  32284. * @param toRemove The material to remove
  32285. * @returns The index of the removed material
  32286. */
  32287. removeMaterial(toRemove: Material): number;
  32288. /**
  32289. * Removes the given action manager from this scene.
  32290. * @param toRemove The action manager to remove
  32291. * @returns The index of the removed action manager
  32292. */
  32293. removeActionManager(toRemove: AbstractActionManager): number;
  32294. /**
  32295. * Removes the given texture from this scene.
  32296. * @param toRemove The texture to remove
  32297. * @returns The index of the removed texture
  32298. */
  32299. removeTexture(toRemove: BaseTexture): number;
  32300. /**
  32301. * Adds the given light to this scene
  32302. * @param newLight The light to add
  32303. */
  32304. addLight(newLight: Light): void;
  32305. /**
  32306. * Sorts the list list based on light priorities
  32307. */
  32308. sortLightsByPriority(): void;
  32309. /**
  32310. * Adds the given camera to this scene
  32311. * @param newCamera The camera to add
  32312. */
  32313. addCamera(newCamera: Camera): void;
  32314. /**
  32315. * Adds the given skeleton to this scene
  32316. * @param newSkeleton The skeleton to add
  32317. */
  32318. addSkeleton(newSkeleton: Skeleton): void;
  32319. /**
  32320. * Adds the given particle system to this scene
  32321. * @param newParticleSystem The particle system to add
  32322. */
  32323. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32324. /**
  32325. * Adds the given animation to this scene
  32326. * @param newAnimation The animation to add
  32327. */
  32328. addAnimation(newAnimation: Animation): void;
  32329. /**
  32330. * Adds the given animation group to this scene.
  32331. * @param newAnimationGroup The animation group to add
  32332. */
  32333. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32334. /**
  32335. * Adds the given multi-material to this scene
  32336. * @param newMultiMaterial The multi-material to add
  32337. */
  32338. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32339. /**
  32340. * Adds the given material to this scene
  32341. * @param newMaterial The material to add
  32342. */
  32343. addMaterial(newMaterial: Material): void;
  32344. /**
  32345. * Adds the given morph target to this scene
  32346. * @param newMorphTargetManager The morph target to add
  32347. */
  32348. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32349. /**
  32350. * Adds the given geometry to this scene
  32351. * @param newGeometry The geometry to add
  32352. */
  32353. addGeometry(newGeometry: Geometry): void;
  32354. /**
  32355. * Adds the given action manager to this scene
  32356. * @param newActionManager The action manager to add
  32357. */
  32358. addActionManager(newActionManager: AbstractActionManager): void;
  32359. /**
  32360. * Adds the given texture to this scene.
  32361. * @param newTexture The texture to add
  32362. */
  32363. addTexture(newTexture: BaseTexture): void;
  32364. /**
  32365. * Switch active camera
  32366. * @param newCamera defines the new active camera
  32367. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32368. */
  32369. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32370. /**
  32371. * sets the active camera of the scene using its ID
  32372. * @param id defines the camera's ID
  32373. * @return the new active camera or null if none found.
  32374. */
  32375. setActiveCameraByID(id: string): Nullable<Camera>;
  32376. /**
  32377. * sets the active camera of the scene using its name
  32378. * @param name defines the camera's name
  32379. * @returns the new active camera or null if none found.
  32380. */
  32381. setActiveCameraByName(name: string): Nullable<Camera>;
  32382. /**
  32383. * get an animation group using its name
  32384. * @param name defines the material's name
  32385. * @return the animation group or null if none found.
  32386. */
  32387. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32388. /**
  32389. * Get a material using its unique id
  32390. * @param uniqueId defines the material's unique id
  32391. * @return the material or null if none found.
  32392. */
  32393. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32394. /**
  32395. * get a material using its id
  32396. * @param id defines the material's ID
  32397. * @return the material or null if none found.
  32398. */
  32399. getMaterialByID(id: string): Nullable<Material>;
  32400. /**
  32401. * Gets a material using its name
  32402. * @param name defines the material's name
  32403. * @return the material or null if none found.
  32404. */
  32405. getMaterialByName(name: string): Nullable<Material>;
  32406. /**
  32407. * Gets a camera using its id
  32408. * @param id defines the id to look for
  32409. * @returns the camera or null if not found
  32410. */
  32411. getCameraByID(id: string): Nullable<Camera>;
  32412. /**
  32413. * Gets a camera using its unique id
  32414. * @param uniqueId defines the unique id to look for
  32415. * @returns the camera or null if not found
  32416. */
  32417. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32418. /**
  32419. * Gets a camera using its name
  32420. * @param name defines the camera's name
  32421. * @return the camera or null if none found.
  32422. */
  32423. getCameraByName(name: string): Nullable<Camera>;
  32424. /**
  32425. * Gets a bone using its id
  32426. * @param id defines the bone's id
  32427. * @return the bone or null if not found
  32428. */
  32429. getBoneByID(id: string): Nullable<Bone>;
  32430. /**
  32431. * Gets a bone using its id
  32432. * @param name defines the bone's name
  32433. * @return the bone or null if not found
  32434. */
  32435. getBoneByName(name: string): Nullable<Bone>;
  32436. /**
  32437. * Gets a light node using its name
  32438. * @param name defines the the light's name
  32439. * @return the light or null if none found.
  32440. */
  32441. getLightByName(name: string): Nullable<Light>;
  32442. /**
  32443. * Gets a light node using its id
  32444. * @param id defines the light's id
  32445. * @return the light or null if none found.
  32446. */
  32447. getLightByID(id: string): Nullable<Light>;
  32448. /**
  32449. * Gets a light node using its scene-generated unique ID
  32450. * @param uniqueId defines the light's unique id
  32451. * @return the light or null if none found.
  32452. */
  32453. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32454. /**
  32455. * Gets a particle system by id
  32456. * @param id defines the particle system id
  32457. * @return the corresponding system or null if none found
  32458. */
  32459. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32460. /**
  32461. * Gets a geometry using its ID
  32462. * @param id defines the geometry's id
  32463. * @return the geometry or null if none found.
  32464. */
  32465. getGeometryByID(id: string): Nullable<Geometry>;
  32466. private _getGeometryByUniqueID;
  32467. /**
  32468. * Add a new geometry to this scene
  32469. * @param geometry defines the geometry to be added to the scene.
  32470. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32471. * @return a boolean defining if the geometry was added or not
  32472. */
  32473. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32474. /**
  32475. * Removes an existing geometry
  32476. * @param geometry defines the geometry to be removed from the scene
  32477. * @return a boolean defining if the geometry was removed or not
  32478. */
  32479. removeGeometry(geometry: Geometry): boolean;
  32480. /**
  32481. * Gets the list of geometries attached to the scene
  32482. * @returns an array of Geometry
  32483. */
  32484. getGeometries(): Geometry[];
  32485. /**
  32486. * Gets the first added mesh found of a given ID
  32487. * @param id defines the id to search for
  32488. * @return the mesh found or null if not found at all
  32489. */
  32490. getMeshByID(id: string): Nullable<AbstractMesh>;
  32491. /**
  32492. * Gets a list of meshes using their id
  32493. * @param id defines the id to search for
  32494. * @returns a list of meshes
  32495. */
  32496. getMeshesByID(id: string): Array<AbstractMesh>;
  32497. /**
  32498. * Gets the first added transform node found of a given ID
  32499. * @param id defines the id to search for
  32500. * @return the found transform node or null if not found at all.
  32501. */
  32502. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32503. /**
  32504. * Gets a transform node with its auto-generated unique id
  32505. * @param uniqueId efines the unique id to search for
  32506. * @return the found transform node or null if not found at all.
  32507. */
  32508. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32509. /**
  32510. * Gets a list of transform nodes using their id
  32511. * @param id defines the id to search for
  32512. * @returns a list of transform nodes
  32513. */
  32514. getTransformNodesByID(id: string): Array<TransformNode>;
  32515. /**
  32516. * Gets a mesh with its auto-generated unique id
  32517. * @param uniqueId defines the unique id to search for
  32518. * @return the found mesh or null if not found at all.
  32519. */
  32520. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32521. /**
  32522. * Gets a the last added mesh using a given id
  32523. * @param id defines the id to search for
  32524. * @return the found mesh or null if not found at all.
  32525. */
  32526. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32527. /**
  32528. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32529. * @param id defines the id to search for
  32530. * @return the found node or null if not found at all
  32531. */
  32532. getLastEntryByID(id: string): Nullable<Node>;
  32533. /**
  32534. * Gets a node (Mesh, Camera, Light) using a given id
  32535. * @param id defines the id to search for
  32536. * @return the found node or null if not found at all
  32537. */
  32538. getNodeByID(id: string): Nullable<Node>;
  32539. /**
  32540. * Gets a node (Mesh, Camera, Light) using a given name
  32541. * @param name defines the name to search for
  32542. * @return the found node or null if not found at all.
  32543. */
  32544. getNodeByName(name: string): Nullable<Node>;
  32545. /**
  32546. * Gets a mesh using a given name
  32547. * @param name defines the name to search for
  32548. * @return the found mesh or null if not found at all.
  32549. */
  32550. getMeshByName(name: string): Nullable<AbstractMesh>;
  32551. /**
  32552. * Gets a transform node using a given name
  32553. * @param name defines the name to search for
  32554. * @return the found transform node or null if not found at all.
  32555. */
  32556. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32557. /**
  32558. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32559. * @param id defines the id to search for
  32560. * @return the found skeleton or null if not found at all.
  32561. */
  32562. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32563. /**
  32564. * Gets a skeleton using a given auto generated unique id
  32565. * @param uniqueId defines the unique id to search for
  32566. * @return the found skeleton or null if not found at all.
  32567. */
  32568. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32569. /**
  32570. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32571. * @param id defines the id to search for
  32572. * @return the found skeleton or null if not found at all.
  32573. */
  32574. getSkeletonById(id: string): Nullable<Skeleton>;
  32575. /**
  32576. * Gets a skeleton using a given name
  32577. * @param name defines the name to search for
  32578. * @return the found skeleton or null if not found at all.
  32579. */
  32580. getSkeletonByName(name: string): Nullable<Skeleton>;
  32581. /**
  32582. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32583. * @param id defines the id to search for
  32584. * @return the found morph target manager or null if not found at all.
  32585. */
  32586. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32587. /**
  32588. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32589. * @param id defines the id to search for
  32590. * @return the found morph target or null if not found at all.
  32591. */
  32592. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32593. /**
  32594. * Gets a boolean indicating if the given mesh is active
  32595. * @param mesh defines the mesh to look for
  32596. * @returns true if the mesh is in the active list
  32597. */
  32598. isActiveMesh(mesh: AbstractMesh): boolean;
  32599. /**
  32600. * Return a unique id as a string which can serve as an identifier for the scene
  32601. */
  32602. readonly uid: string;
  32603. /**
  32604. * Add an externaly attached data from its key.
  32605. * This method call will fail and return false, if such key already exists.
  32606. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32607. * @param key the unique key that identifies the data
  32608. * @param data the data object to associate to the key for this Engine instance
  32609. * @return true if no such key were already present and the data was added successfully, false otherwise
  32610. */
  32611. addExternalData<T>(key: string, data: T): boolean;
  32612. /**
  32613. * Get an externaly attached data from its key
  32614. * @param key the unique key that identifies the data
  32615. * @return the associated data, if present (can be null), or undefined if not present
  32616. */
  32617. getExternalData<T>(key: string): Nullable<T>;
  32618. /**
  32619. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32620. * @param key the unique key that identifies the data
  32621. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32622. * @return the associated data, can be null if the factory returned null.
  32623. */
  32624. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32625. /**
  32626. * Remove an externaly attached data from the Engine instance
  32627. * @param key the unique key that identifies the data
  32628. * @return true if the data was successfully removed, false if it doesn't exist
  32629. */
  32630. removeExternalData(key: string): boolean;
  32631. private _evaluateSubMesh;
  32632. /**
  32633. * Clear the processed materials smart array preventing retention point in material dispose.
  32634. */
  32635. freeProcessedMaterials(): void;
  32636. private _preventFreeActiveMeshesAndRenderingGroups;
  32637. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32638. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32639. * when disposing several meshes in a row or a hierarchy of meshes.
  32640. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32641. */
  32642. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32643. /**
  32644. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32645. */
  32646. freeActiveMeshes(): void;
  32647. /**
  32648. * Clear the info related to rendering groups preventing retention points during dispose.
  32649. */
  32650. freeRenderingGroups(): void;
  32651. /** @hidden */ isInIntermediateRendering(): boolean;
  32652. /**
  32653. * Lambda returning the list of potentially active meshes.
  32654. */
  32655. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32656. /**
  32657. * Lambda returning the list of potentially active sub meshes.
  32658. */
  32659. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32660. /**
  32661. * Lambda returning the list of potentially intersecting sub meshes.
  32662. */
  32663. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32664. /**
  32665. * Lambda returning the list of potentially colliding sub meshes.
  32666. */
  32667. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32668. private _activeMeshesFrozen;
  32669. /**
  32670. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32671. * @returns the current scene
  32672. */
  32673. freezeActiveMeshes(): Scene;
  32674. /**
  32675. * Use this function to restart evaluating active meshes on every frame
  32676. * @returns the current scene
  32677. */
  32678. unfreezeActiveMeshes(): Scene;
  32679. private _evaluateActiveMeshes;
  32680. private _activeMesh;
  32681. /**
  32682. * Update the transform matrix to update from the current active camera
  32683. * @param force defines a boolean used to force the update even if cache is up to date
  32684. */
  32685. updateTransformMatrix(force?: boolean): void;
  32686. private _bindFrameBuffer;
  32687. /** @hidden */ allowPostProcessClearColor: boolean;
  32688. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32689. private _processSubCameras;
  32690. private _checkIntersections;
  32691. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32692. /**
  32693. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32694. */
  32695. getDeterministicFrameTime: () => number;
  32696. /** @hidden */ animate(): void;
  32697. /** Execute all animations (for a frame) */
  32698. animate(): void;
  32699. /**
  32700. * Render the scene
  32701. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32702. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32703. */
  32704. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32705. /**
  32706. * Freeze all materials
  32707. * A frozen material will not be updatable but should be faster to render
  32708. */
  32709. freezeMaterials(): void;
  32710. /**
  32711. * Unfreeze all materials
  32712. * A frozen material will not be updatable but should be faster to render
  32713. */
  32714. unfreezeMaterials(): void;
  32715. /**
  32716. * Releases all held ressources
  32717. */
  32718. dispose(): void;
  32719. /**
  32720. * Gets if the scene is already disposed
  32721. */
  32722. readonly isDisposed: boolean;
  32723. /**
  32724. * Call this function to reduce memory footprint of the scene.
  32725. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32726. */
  32727. clearCachedVertexData(): void;
  32728. /**
  32729. * This function will remove the local cached buffer data from texture.
  32730. * It will save memory but will prevent the texture from being rebuilt
  32731. */
  32732. cleanCachedTextureBuffer(): void;
  32733. /**
  32734. * Get the world extend vectors with an optional filter
  32735. *
  32736. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32737. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32738. */
  32739. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32740. min: Vector3;
  32741. max: Vector3;
  32742. };
  32743. /**
  32744. * Creates a ray that can be used to pick in the scene
  32745. * @param x defines the x coordinate of the origin (on-screen)
  32746. * @param y defines the y coordinate of the origin (on-screen)
  32747. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32748. * @param camera defines the camera to use for the picking
  32749. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32750. * @returns a Ray
  32751. */
  32752. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32753. /**
  32754. * Creates a ray that can be used to pick in the scene
  32755. * @param x defines the x coordinate of the origin (on-screen)
  32756. * @param y defines the y coordinate of the origin (on-screen)
  32757. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32758. * @param result defines the ray where to store the picking ray
  32759. * @param camera defines the camera to use for the picking
  32760. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32761. * @returns the current scene
  32762. */
  32763. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32764. /**
  32765. * Creates a ray that can be used to pick in the scene
  32766. * @param x defines the x coordinate of the origin (on-screen)
  32767. * @param y defines the y coordinate of the origin (on-screen)
  32768. * @param camera defines the camera to use for the picking
  32769. * @returns a Ray
  32770. */
  32771. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32772. /**
  32773. * Creates a ray that can be used to pick in the scene
  32774. * @param x defines the x coordinate of the origin (on-screen)
  32775. * @param y defines the y coordinate of the origin (on-screen)
  32776. * @param result defines the ray where to store the picking ray
  32777. * @param camera defines the camera to use for the picking
  32778. * @returns the current scene
  32779. */
  32780. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32781. /** Launch a ray to try to pick a mesh in the scene
  32782. * @param x position on screen
  32783. * @param y position on screen
  32784. * @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
  32785. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32786. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32787. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32788. * @returns a PickingInfo
  32789. */
  32790. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32791. /** Use the given ray to pick a mesh in the scene
  32792. * @param ray The ray to use to pick meshes
  32793. * @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
  32794. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32795. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32796. * @returns a PickingInfo
  32797. */
  32798. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32799. /**
  32800. * Launch a ray to try to pick a mesh in the scene
  32801. * @param x X position on screen
  32802. * @param y Y position on screen
  32803. * @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
  32804. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32805. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32806. * @returns an array of PickingInfo
  32807. */
  32808. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32809. /**
  32810. * Launch a ray to try to pick a mesh in the scene
  32811. * @param ray Ray to use
  32812. * @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
  32813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32814. * @returns an array of PickingInfo
  32815. */
  32816. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32817. /**
  32818. * Force the value of meshUnderPointer
  32819. * @param mesh defines the mesh to use
  32820. */
  32821. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32822. /**
  32823. * Gets the mesh under the pointer
  32824. * @returns a Mesh or null if no mesh is under the pointer
  32825. */
  32826. getPointerOverMesh(): Nullable<AbstractMesh>;
  32827. /** @hidden */ rebuildGeometries(): void;
  32828. /** @hidden */ rebuildTextures(): void;
  32829. private _getByTags;
  32830. /**
  32831. * Get a list of meshes by tags
  32832. * @param tagsQuery defines the tags query to use
  32833. * @param forEach defines a predicate used to filter results
  32834. * @returns an array of Mesh
  32835. */
  32836. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32837. /**
  32838. * Get a list of cameras by tags
  32839. * @param tagsQuery defines the tags query to use
  32840. * @param forEach defines a predicate used to filter results
  32841. * @returns an array of Camera
  32842. */
  32843. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32844. /**
  32845. * Get a list of lights by tags
  32846. * @param tagsQuery defines the tags query to use
  32847. * @param forEach defines a predicate used to filter results
  32848. * @returns an array of Light
  32849. */
  32850. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32851. /**
  32852. * Get a list of materials by tags
  32853. * @param tagsQuery defines the tags query to use
  32854. * @param forEach defines a predicate used to filter results
  32855. * @returns an array of Material
  32856. */
  32857. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32858. /**
  32859. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32860. * This allowed control for front to back rendering or reversly depending of the special needs.
  32861. *
  32862. * @param renderingGroupId The rendering group id corresponding to its index
  32863. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32864. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32865. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32866. */
  32867. 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;
  32868. /**
  32869. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32870. *
  32871. * @param renderingGroupId The rendering group id corresponding to its index
  32872. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32873. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32874. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32875. */
  32876. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32877. /**
  32878. * Gets the current auto clear configuration for one rendering group of the rendering
  32879. * manager.
  32880. * @param index the rendering group index to get the information for
  32881. * @returns The auto clear setup for the requested rendering group
  32882. */
  32883. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32884. private _blockMaterialDirtyMechanism;
  32885. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32886. blockMaterialDirtyMechanism: boolean;
  32887. /**
  32888. * Will flag all materials as dirty to trigger new shader compilation
  32889. * @param flag defines the flag used to specify which material part must be marked as dirty
  32890. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32891. */
  32892. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32893. /** @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;
  32894. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32895. }
  32896. }
  32897. declare module BABYLON {
  32898. /**
  32899. * Set of assets to keep when moving a scene into an asset container.
  32900. */
  32901. export class KeepAssets extends AbstractScene {
  32902. }
  32903. /**
  32904. * Container with a set of assets that can be added or removed from a scene.
  32905. */
  32906. export class AssetContainer extends AbstractScene {
  32907. /**
  32908. * The scene the AssetContainer belongs to.
  32909. */
  32910. scene: Scene;
  32911. /**
  32912. * Instantiates an AssetContainer.
  32913. * @param scene The scene the AssetContainer belongs to.
  32914. */
  32915. constructor(scene: Scene);
  32916. /**
  32917. * Adds all the assets from the container to the scene.
  32918. */
  32919. addAllToScene(): void;
  32920. /**
  32921. * Removes all the assets in the container from the scene
  32922. */
  32923. removeAllFromScene(): void;
  32924. /**
  32925. * Disposes all the assets in the container
  32926. */
  32927. dispose(): void;
  32928. private _moveAssets;
  32929. /**
  32930. * Removes all the assets contained in the scene and adds them to the container.
  32931. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32932. */
  32933. moveAllFromScene(keepAssets?: KeepAssets): void;
  32934. /**
  32935. * 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.
  32936. * @returns the root mesh
  32937. */
  32938. createRootMesh(): Mesh;
  32939. }
  32940. }
  32941. declare module BABYLON {
  32942. /**
  32943. * Defines how the parser contract is defined.
  32944. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32945. */
  32946. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32947. /**
  32948. * Defines how the individual parser contract is defined.
  32949. * These parser can parse an individual asset
  32950. */
  32951. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32952. /**
  32953. * Base class of the scene acting as a container for the different elements composing a scene.
  32954. * This class is dynamically extended by the different components of the scene increasing
  32955. * flexibility and reducing coupling
  32956. */
  32957. export abstract class AbstractScene {
  32958. /**
  32959. * Stores the list of available parsers in the application.
  32960. */
  32961. private static _BabylonFileParsers;
  32962. /**
  32963. * Stores the list of available individual parsers in the application.
  32964. */
  32965. private static _IndividualBabylonFileParsers;
  32966. /**
  32967. * Adds a parser in the list of available ones
  32968. * @param name Defines the name of the parser
  32969. * @param parser Defines the parser to add
  32970. */
  32971. static AddParser(name: string, parser: BabylonFileParser): void;
  32972. /**
  32973. * Gets a general parser from the list of avaialble ones
  32974. * @param name Defines the name of the parser
  32975. * @returns the requested parser or null
  32976. */
  32977. static GetParser(name: string): Nullable<BabylonFileParser>;
  32978. /**
  32979. * Adds n individual parser in the list of available ones
  32980. * @param name Defines the name of the parser
  32981. * @param parser Defines the parser to add
  32982. */
  32983. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32984. /**
  32985. * Gets an individual parser from the list of avaialble ones
  32986. * @param name Defines the name of the parser
  32987. * @returns the requested parser or null
  32988. */
  32989. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32990. /**
  32991. * Parser json data and populate both a scene and its associated container object
  32992. * @param jsonData Defines the data to parse
  32993. * @param scene Defines the scene to parse the data for
  32994. * @param container Defines the container attached to the parsing sequence
  32995. * @param rootUrl Defines the root url of the data
  32996. */
  32997. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32998. /**
  32999. * Gets the list of root nodes (ie. nodes with no parent)
  33000. */
  33001. rootNodes: Node[];
  33002. /** All of the cameras added to this scene
  33003. * @see http://doc.babylonjs.com/babylon101/cameras
  33004. */
  33005. cameras: Camera[];
  33006. /**
  33007. * All of the lights added to this scene
  33008. * @see http://doc.babylonjs.com/babylon101/lights
  33009. */
  33010. lights: Light[];
  33011. /**
  33012. * All of the (abstract) meshes added to this scene
  33013. */
  33014. meshes: AbstractMesh[];
  33015. /**
  33016. * The list of skeletons added to the scene
  33017. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33018. */
  33019. skeletons: Skeleton[];
  33020. /**
  33021. * All of the particle systems added to this scene
  33022. * @see http://doc.babylonjs.com/babylon101/particles
  33023. */
  33024. particleSystems: IParticleSystem[];
  33025. /**
  33026. * Gets a list of Animations associated with the scene
  33027. */
  33028. animations: Animation[];
  33029. /**
  33030. * All of the animation groups added to this scene
  33031. * @see http://doc.babylonjs.com/how_to/group
  33032. */
  33033. animationGroups: AnimationGroup[];
  33034. /**
  33035. * All of the multi-materials added to this scene
  33036. * @see http://doc.babylonjs.com/how_to/multi_materials
  33037. */
  33038. multiMaterials: MultiMaterial[];
  33039. /**
  33040. * All of the materials added to this scene
  33041. * In the context of a Scene, it is not supposed to be modified manually.
  33042. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33043. * Note also that the order of the Material wihin the array is not significant and might change.
  33044. * @see http://doc.babylonjs.com/babylon101/materials
  33045. */
  33046. materials: Material[];
  33047. /**
  33048. * The list of morph target managers added to the scene
  33049. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33050. */
  33051. morphTargetManagers: MorphTargetManager[];
  33052. /**
  33053. * The list of geometries used in the scene.
  33054. */
  33055. geometries: Geometry[];
  33056. /**
  33057. * All of the tranform nodes added to this scene
  33058. * In the context of a Scene, it is not supposed to be modified manually.
  33059. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33060. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33061. * @see http://doc.babylonjs.com/how_to/transformnode
  33062. */
  33063. transformNodes: TransformNode[];
  33064. /**
  33065. * ActionManagers available on the scene.
  33066. */
  33067. actionManagers: AbstractActionManager[];
  33068. /**
  33069. * Textures to keep.
  33070. */
  33071. textures: BaseTexture[];
  33072. /**
  33073. * Environment texture for the scene
  33074. */
  33075. environmentTexture: Nullable<BaseTexture>;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. /**
  33080. * Defines a sound that can be played in the application.
  33081. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33083. */
  33084. export class Sound {
  33085. /**
  33086. * The name of the sound in the scene.
  33087. */
  33088. name: string;
  33089. /**
  33090. * Does the sound autoplay once loaded.
  33091. */
  33092. autoplay: boolean;
  33093. /**
  33094. * Does the sound loop after it finishes playing once.
  33095. */
  33096. loop: boolean;
  33097. /**
  33098. * Does the sound use a custom attenuation curve to simulate the falloff
  33099. * happening when the source gets further away from the camera.
  33100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33101. */
  33102. useCustomAttenuation: boolean;
  33103. /**
  33104. * The sound track id this sound belongs to.
  33105. */
  33106. soundTrackId: number;
  33107. /**
  33108. * Is this sound currently played.
  33109. */
  33110. isPlaying: boolean;
  33111. /**
  33112. * Is this sound currently paused.
  33113. */
  33114. isPaused: boolean;
  33115. /**
  33116. * Does this sound enables spatial sound.
  33117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33118. */
  33119. spatialSound: boolean;
  33120. /**
  33121. * Define the reference distance the sound should be heard perfectly.
  33122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33123. */
  33124. refDistance: number;
  33125. /**
  33126. * Define the roll off factor of spatial sounds.
  33127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33128. */
  33129. rolloffFactor: number;
  33130. /**
  33131. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33133. */
  33134. maxDistance: number;
  33135. /**
  33136. * Define the distance attenuation model the sound will follow.
  33137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33138. */
  33139. distanceModel: string;
  33140. /**
  33141. * @hidden
  33142. * Back Compat
  33143. **/
  33144. onended: () => any;
  33145. /**
  33146. * Observable event when the current playing sound finishes.
  33147. */
  33148. onEndedObservable: Observable<Sound>;
  33149. private _panningModel;
  33150. private _playbackRate;
  33151. private _streaming;
  33152. private _startTime;
  33153. private _startOffset;
  33154. private _position;
  33155. /** @hidden */ positionInEmitterSpace: boolean;
  33156. private _localDirection;
  33157. private _volume;
  33158. private _isReadyToPlay;
  33159. private _isDirectional;
  33160. private _readyToPlayCallback;
  33161. private _audioBuffer;
  33162. private _soundSource;
  33163. private _streamingSource;
  33164. private _soundPanner;
  33165. private _soundGain;
  33166. private _inputAudioNode;
  33167. private _outputAudioNode;
  33168. private _coneInnerAngle;
  33169. private _coneOuterAngle;
  33170. private _coneOuterGain;
  33171. private _scene;
  33172. private _connectedTransformNode;
  33173. private _customAttenuationFunction;
  33174. private _registerFunc;
  33175. private _isOutputConnected;
  33176. private _htmlAudioElement;
  33177. private _urlType;
  33178. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33179. /**
  33180. * Create a sound and attach it to a scene
  33181. * @param name Name of your sound
  33182. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33183. * @param scene defines the scene the sound belongs to
  33184. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33185. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33186. */
  33187. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33188. /**
  33189. * Release the sound and its associated resources
  33190. */
  33191. dispose(): void;
  33192. /**
  33193. * Gets if the sounds is ready to be played or not.
  33194. * @returns true if ready, otherwise false
  33195. */
  33196. isReady(): boolean;
  33197. private _soundLoaded;
  33198. /**
  33199. * Sets the data of the sound from an audiobuffer
  33200. * @param audioBuffer The audioBuffer containing the data
  33201. */
  33202. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33203. /**
  33204. * Updates the current sounds options such as maxdistance, loop...
  33205. * @param options A JSON object containing values named as the object properties
  33206. */
  33207. updateOptions(options: any): void;
  33208. private _createSpatialParameters;
  33209. private _updateSpatialParameters;
  33210. /**
  33211. * Switch the panning model to HRTF:
  33212. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33214. */
  33215. switchPanningModelToHRTF(): void;
  33216. /**
  33217. * Switch the panning model to Equal Power:
  33218. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33220. */
  33221. switchPanningModelToEqualPower(): void;
  33222. private _switchPanningModel;
  33223. /**
  33224. * Connect this sound to a sound track audio node like gain...
  33225. * @param soundTrackAudioNode the sound track audio node to connect to
  33226. */
  33227. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33228. /**
  33229. * Transform this sound into a directional source
  33230. * @param coneInnerAngle Size of the inner cone in degree
  33231. * @param coneOuterAngle Size of the outer cone in degree
  33232. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33233. */
  33234. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33235. /**
  33236. * Gets or sets the inner angle for the directional cone.
  33237. */
  33238. /**
  33239. * Gets or sets the inner angle for the directional cone.
  33240. */
  33241. directionalConeInnerAngle: number;
  33242. /**
  33243. * Gets or sets the outer angle for the directional cone.
  33244. */
  33245. /**
  33246. * Gets or sets the outer angle for the directional cone.
  33247. */
  33248. directionalConeOuterAngle: number;
  33249. /**
  33250. * Sets the position of the emitter if spatial sound is enabled
  33251. * @param newPosition Defines the new posisiton
  33252. */
  33253. setPosition(newPosition: Vector3): void;
  33254. /**
  33255. * Sets the local direction of the emitter if spatial sound is enabled
  33256. * @param newLocalDirection Defines the new local direction
  33257. */
  33258. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33259. private _updateDirection;
  33260. /** @hidden */
  33261. updateDistanceFromListener(): void;
  33262. /**
  33263. * Sets a new custom attenuation function for the sound.
  33264. * @param callback Defines the function used for the attenuation
  33265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33266. */
  33267. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33268. /**
  33269. * Play the sound
  33270. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33271. * @param offset (optional) Start the sound setting it at a specific time
  33272. */
  33273. play(time?: number, offset?: number): void;
  33274. private _onended;
  33275. /**
  33276. * Stop the sound
  33277. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33278. */
  33279. stop(time?: number): void;
  33280. /**
  33281. * Put the sound in pause
  33282. */
  33283. pause(): void;
  33284. /**
  33285. * Sets a dedicated volume for this sounds
  33286. * @param newVolume Define the new volume of the sound
  33287. * @param time Define in how long the sound should be at this value
  33288. */
  33289. setVolume(newVolume: number, time?: number): void;
  33290. /**
  33291. * Set the sound play back rate
  33292. * @param newPlaybackRate Define the playback rate the sound should be played at
  33293. */
  33294. setPlaybackRate(newPlaybackRate: number): void;
  33295. /**
  33296. * Gets the volume of the sound.
  33297. * @returns the volume of the sound
  33298. */
  33299. getVolume(): number;
  33300. /**
  33301. * Attach the sound to a dedicated mesh
  33302. * @param transformNode The transform node to connect the sound with
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33304. */
  33305. attachToMesh(transformNode: TransformNode): void;
  33306. /**
  33307. * Detach the sound from the previously attached mesh
  33308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33309. */
  33310. detachFromMesh(): void;
  33311. private _onRegisterAfterWorldMatrixUpdate;
  33312. /**
  33313. * Clone the current sound in the scene.
  33314. * @returns the new sound clone
  33315. */
  33316. clone(): Nullable<Sound>;
  33317. /**
  33318. * Gets the current underlying audio buffer containing the data
  33319. * @returns the audio buffer
  33320. */
  33321. getAudioBuffer(): Nullable<AudioBuffer>;
  33322. /**
  33323. * Serializes the Sound in a JSON representation
  33324. * @returns the JSON representation of the sound
  33325. */
  33326. serialize(): any;
  33327. /**
  33328. * Parse a JSON representation of a sound to innstantiate in a given scene
  33329. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33330. * @param scene Define the scene the new parsed sound should be created in
  33331. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33332. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33333. * @returns the newly parsed sound
  33334. */
  33335. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33336. }
  33337. }
  33338. declare module BABYLON {
  33339. /**
  33340. * This defines an action helpful to play a defined sound on a triggered action.
  33341. */
  33342. export class PlaySoundAction extends Action {
  33343. private _sound;
  33344. /**
  33345. * Instantiate the action
  33346. * @param triggerOptions defines the trigger options
  33347. * @param sound defines the sound to play
  33348. * @param condition defines the trigger related conditions
  33349. */
  33350. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33351. /** @hidden */ prepare(): void;
  33352. /**
  33353. * Execute the action and play the sound.
  33354. */
  33355. execute(): void;
  33356. /**
  33357. * Serializes the actions and its related information.
  33358. * @param parent defines the object to serialize in
  33359. * @returns the serialized object
  33360. */
  33361. serialize(parent: any): any;
  33362. }
  33363. /**
  33364. * This defines an action helpful to stop a defined sound on a triggered action.
  33365. */
  33366. export class StopSoundAction extends Action {
  33367. private _sound;
  33368. /**
  33369. * Instantiate the action
  33370. * @param triggerOptions defines the trigger options
  33371. * @param sound defines the sound to stop
  33372. * @param condition defines the trigger related conditions
  33373. */
  33374. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33375. /** @hidden */ prepare(): void;
  33376. /**
  33377. * Execute the action and stop the sound.
  33378. */
  33379. execute(): void;
  33380. /**
  33381. * Serializes the actions and its related information.
  33382. * @param parent defines the object to serialize in
  33383. * @returns the serialized object
  33384. */
  33385. serialize(parent: any): any;
  33386. }
  33387. }
  33388. declare module BABYLON {
  33389. /**
  33390. * This defines an action responsible to change the value of a property
  33391. * by interpolating between its current value and the newly set one once triggered.
  33392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33393. */
  33394. export class InterpolateValueAction extends Action {
  33395. /**
  33396. * Defines the path of the property where the value should be interpolated
  33397. */
  33398. propertyPath: string;
  33399. /**
  33400. * Defines the target value at the end of the interpolation.
  33401. */
  33402. value: any;
  33403. /**
  33404. * Defines the time it will take for the property to interpolate to the value.
  33405. */
  33406. duration: number;
  33407. /**
  33408. * Defines if the other scene animations should be stopped when the action has been triggered
  33409. */
  33410. stopOtherAnimations?: boolean;
  33411. /**
  33412. * Defines a callback raised once the interpolation animation has been done.
  33413. */
  33414. onInterpolationDone?: () => void;
  33415. /**
  33416. * Observable triggered once the interpolation animation has been done.
  33417. */
  33418. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33419. private _target;
  33420. private _effectiveTarget;
  33421. private _property;
  33422. /**
  33423. * Instantiate the action
  33424. * @param triggerOptions defines the trigger options
  33425. * @param target defines the object containing the value to interpolate
  33426. * @param propertyPath defines the path to the property in the target object
  33427. * @param value defines the target value at the end of the interpolation
  33428. * @param duration deines the time it will take for the property to interpolate to the value.
  33429. * @param condition defines the trigger related conditions
  33430. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33431. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33432. */
  33433. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33434. /** @hidden */ prepare(): void;
  33435. /**
  33436. * Execute the action starts the value interpolation.
  33437. */
  33438. execute(): void;
  33439. /**
  33440. * Serializes the actions and its related information.
  33441. * @param parent defines the object to serialize in
  33442. * @returns the serialized object
  33443. */
  33444. serialize(parent: any): any;
  33445. }
  33446. }
  33447. declare module BABYLON {
  33448. /**
  33449. * Options allowed during the creation of a sound track.
  33450. */
  33451. export interface ISoundTrackOptions {
  33452. /**
  33453. * The volume the sound track should take during creation
  33454. */
  33455. volume?: number;
  33456. /**
  33457. * Define if the sound track is the main sound track of the scene
  33458. */
  33459. mainTrack?: boolean;
  33460. }
  33461. /**
  33462. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33463. * It will be also used in a future release to apply effects on a specific track.
  33464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33465. */
  33466. export class SoundTrack {
  33467. /**
  33468. * The unique identifier of the sound track in the scene.
  33469. */
  33470. id: number;
  33471. /**
  33472. * The list of sounds included in the sound track.
  33473. */
  33474. soundCollection: Array<Sound>;
  33475. private _outputAudioNode;
  33476. private _scene;
  33477. private _isMainTrack;
  33478. private _connectedAnalyser;
  33479. private _options;
  33480. private _isInitialized;
  33481. /**
  33482. * Creates a new sound track.
  33483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33484. * @param scene Define the scene the sound track belongs to
  33485. * @param options
  33486. */
  33487. constructor(scene: Scene, options?: ISoundTrackOptions);
  33488. private _initializeSoundTrackAudioGraph;
  33489. /**
  33490. * Release the sound track and its associated resources
  33491. */
  33492. dispose(): void;
  33493. /**
  33494. * Adds a sound to this sound track
  33495. * @param sound define the cound to add
  33496. * @ignoreNaming
  33497. */
  33498. AddSound(sound: Sound): void;
  33499. /**
  33500. * Removes a sound to this sound track
  33501. * @param sound define the cound to remove
  33502. * @ignoreNaming
  33503. */
  33504. RemoveSound(sound: Sound): void;
  33505. /**
  33506. * Set a global volume for the full sound track.
  33507. * @param newVolume Define the new volume of the sound track
  33508. */
  33509. setVolume(newVolume: number): void;
  33510. /**
  33511. * Switch the panning model to HRTF:
  33512. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33514. */
  33515. switchPanningModelToHRTF(): void;
  33516. /**
  33517. * Switch the panning model to Equal Power:
  33518. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33520. */
  33521. switchPanningModelToEqualPower(): void;
  33522. /**
  33523. * Connect the sound track to an audio analyser allowing some amazing
  33524. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33526. * @param analyser The analyser to connect to the engine
  33527. */
  33528. connectToAnalyser(analyser: Analyser): void;
  33529. }
  33530. }
  33531. declare module BABYLON {
  33532. interface AbstractScene {
  33533. /**
  33534. * The list of sounds used in the scene.
  33535. */
  33536. sounds: Nullable<Array<Sound>>;
  33537. }
  33538. interface Scene {
  33539. /**
  33540. * @hidden
  33541. * Backing field
  33542. */ mainSoundTrack: SoundTrack;
  33543. /**
  33544. * The main sound track played by the scene.
  33545. * It cotains your primary collection of sounds.
  33546. */
  33547. mainSoundTrack: SoundTrack;
  33548. /**
  33549. * The list of sound tracks added to the scene
  33550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33551. */
  33552. soundTracks: Nullable<Array<SoundTrack>>;
  33553. /**
  33554. * Gets a sound using a given name
  33555. * @param name defines the name to search for
  33556. * @return the found sound or null if not found at all.
  33557. */
  33558. getSoundByName(name: string): Nullable<Sound>;
  33559. /**
  33560. * Gets or sets if audio support is enabled
  33561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33562. */
  33563. audioEnabled: boolean;
  33564. /**
  33565. * Gets or sets if audio will be output to headphones
  33566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33567. */
  33568. headphone: boolean;
  33569. }
  33570. /**
  33571. * Defines the sound scene component responsible to manage any sounds
  33572. * in a given scene.
  33573. */
  33574. export class AudioSceneComponent implements ISceneSerializableComponent {
  33575. /**
  33576. * The component name helpfull to identify the component in the list of scene components.
  33577. */
  33578. readonly name: string;
  33579. /**
  33580. * The scene the component belongs to.
  33581. */
  33582. scene: Scene;
  33583. private _audioEnabled;
  33584. /**
  33585. * Gets whether audio is enabled or not.
  33586. * Please use related enable/disable method to switch state.
  33587. */
  33588. readonly audioEnabled: boolean;
  33589. private _headphone;
  33590. /**
  33591. * Gets whether audio is outputing to headphone or not.
  33592. * Please use the according Switch methods to change output.
  33593. */
  33594. readonly headphone: boolean;
  33595. /**
  33596. * Creates a new instance of the component for the given scene
  33597. * @param scene Defines the scene to register the component in
  33598. */
  33599. constructor(scene: Scene);
  33600. /**
  33601. * Registers the component in a given scene
  33602. */
  33603. register(): void;
  33604. /**
  33605. * Rebuilds the elements related to this component in case of
  33606. * context lost for instance.
  33607. */
  33608. rebuild(): void;
  33609. /**
  33610. * Serializes the component data to the specified json object
  33611. * @param serializationObject The object to serialize to
  33612. */
  33613. serialize(serializationObject: any): void;
  33614. /**
  33615. * Adds all the element from the container to the scene
  33616. * @param container the container holding the elements
  33617. */
  33618. addFromContainer(container: AbstractScene): void;
  33619. /**
  33620. * Removes all the elements in the container from the scene
  33621. * @param container contains the elements to remove
  33622. * @param dispose if the removed element should be disposed (default: false)
  33623. */
  33624. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33625. /**
  33626. * Disposes the component and the associated ressources.
  33627. */
  33628. dispose(): void;
  33629. /**
  33630. * Disables audio in the associated scene.
  33631. */
  33632. disableAudio(): void;
  33633. /**
  33634. * Enables audio in the associated scene.
  33635. */
  33636. enableAudio(): void;
  33637. /**
  33638. * Switch audio to headphone output.
  33639. */
  33640. switchAudioModeForHeadphones(): void;
  33641. /**
  33642. * Switch audio to normal speakers.
  33643. */
  33644. switchAudioModeForNormalSpeakers(): void;
  33645. private _afterRender;
  33646. }
  33647. }
  33648. declare module BABYLON {
  33649. /**
  33650. * Wraps one or more Sound objects and selects one with random weight for playback.
  33651. */
  33652. export class WeightedSound {
  33653. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33654. loop: boolean;
  33655. private _coneInnerAngle;
  33656. private _coneOuterAngle;
  33657. private _volume;
  33658. /** A Sound is currently playing. */
  33659. isPlaying: boolean;
  33660. /** A Sound is currently paused. */
  33661. isPaused: boolean;
  33662. private _sounds;
  33663. private _weights;
  33664. private _currentIndex?;
  33665. /**
  33666. * Creates a new WeightedSound from the list of sounds given.
  33667. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33668. * @param sounds Array of Sounds that will be selected from.
  33669. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33670. */
  33671. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33672. /**
  33673. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33674. */
  33675. /**
  33676. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33677. */
  33678. directionalConeInnerAngle: number;
  33679. /**
  33680. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33681. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33682. */
  33683. /**
  33684. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33685. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33686. */
  33687. directionalConeOuterAngle: number;
  33688. /**
  33689. * Playback volume.
  33690. */
  33691. /**
  33692. * Playback volume.
  33693. */
  33694. volume: number;
  33695. private _onended;
  33696. /**
  33697. * Suspend playback
  33698. */
  33699. pause(): void;
  33700. /**
  33701. * Stop playback
  33702. */
  33703. stop(): void;
  33704. /**
  33705. * Start playback.
  33706. * @param startOffset Position the clip head at a specific time in seconds.
  33707. */
  33708. play(startOffset?: number): void;
  33709. }
  33710. }
  33711. declare module BABYLON {
  33712. /**
  33713. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33714. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33715. */
  33716. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33717. /**
  33718. * Gets the name of the behavior.
  33719. */
  33720. readonly name: string;
  33721. /**
  33722. * The easing function used by animations
  33723. */
  33724. static EasingFunction: BackEase;
  33725. /**
  33726. * The easing mode used by animations
  33727. */
  33728. static EasingMode: number;
  33729. /**
  33730. * The duration of the animation, in milliseconds
  33731. */
  33732. transitionDuration: number;
  33733. /**
  33734. * Length of the distance animated by the transition when lower radius is reached
  33735. */
  33736. lowerRadiusTransitionRange: number;
  33737. /**
  33738. * Length of the distance animated by the transition when upper radius is reached
  33739. */
  33740. upperRadiusTransitionRange: number;
  33741. private _autoTransitionRange;
  33742. /**
  33743. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33744. */
  33745. /**
  33746. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33747. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33748. */
  33749. autoTransitionRange: boolean;
  33750. private _attachedCamera;
  33751. private _onAfterCheckInputsObserver;
  33752. private _onMeshTargetChangedObserver;
  33753. /**
  33754. * Initializes the behavior.
  33755. */
  33756. init(): void;
  33757. /**
  33758. * Attaches the behavior to its arc rotate camera.
  33759. * @param camera Defines the camera to attach the behavior to
  33760. */
  33761. attach(camera: ArcRotateCamera): void;
  33762. /**
  33763. * Detaches the behavior from its current arc rotate camera.
  33764. */
  33765. detach(): void;
  33766. private _radiusIsAnimating;
  33767. private _radiusBounceTransition;
  33768. private _animatables;
  33769. private _cachedWheelPrecision;
  33770. /**
  33771. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33772. * @param radiusLimit The limit to check against.
  33773. * @return Bool to indicate if at limit.
  33774. */
  33775. private _isRadiusAtLimit;
  33776. /**
  33777. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33778. * @param radiusDelta The delta by which to animate to. Can be negative.
  33779. */
  33780. private _applyBoundRadiusAnimation;
  33781. /**
  33782. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33783. */
  33784. protected _clearAnimationLocks(): void;
  33785. /**
  33786. * Stops and removes all animations that have been applied to the camera
  33787. */
  33788. stopAllAnimations(): void;
  33789. }
  33790. }
  33791. declare module BABYLON {
  33792. /**
  33793. * 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.
  33794. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33795. */
  33796. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33797. /**
  33798. * Gets the name of the behavior.
  33799. */
  33800. readonly name: string;
  33801. private _mode;
  33802. private _radiusScale;
  33803. private _positionScale;
  33804. private _defaultElevation;
  33805. private _elevationReturnTime;
  33806. private _elevationReturnWaitTime;
  33807. private _zoomStopsAnimation;
  33808. private _framingTime;
  33809. /**
  33810. * The easing function used by animations
  33811. */
  33812. static EasingFunction: ExponentialEase;
  33813. /**
  33814. * The easing mode used by animations
  33815. */
  33816. static EasingMode: number;
  33817. /**
  33818. * Sets the current mode used by the behavior
  33819. */
  33820. /**
  33821. * Gets current mode used by the behavior.
  33822. */
  33823. mode: number;
  33824. /**
  33825. * Sets the scale applied to the radius (1 by default)
  33826. */
  33827. /**
  33828. * Gets the scale applied to the radius
  33829. */
  33830. radiusScale: number;
  33831. /**
  33832. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33833. */
  33834. /**
  33835. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33836. */
  33837. positionScale: number;
  33838. /**
  33839. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33840. * behaviour is triggered, in radians.
  33841. */
  33842. /**
  33843. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33844. * behaviour is triggered, in radians.
  33845. */
  33846. defaultElevation: number;
  33847. /**
  33848. * Sets the time (in milliseconds) taken to return to the default beta position.
  33849. * Negative value indicates camera should not return to default.
  33850. */
  33851. /**
  33852. * Gets the time (in milliseconds) taken to return to the default beta position.
  33853. * Negative value indicates camera should not return to default.
  33854. */
  33855. elevationReturnTime: number;
  33856. /**
  33857. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33858. */
  33859. /**
  33860. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33861. */
  33862. elevationReturnWaitTime: number;
  33863. /**
  33864. * Sets the flag that indicates if user zooming should stop animation.
  33865. */
  33866. /**
  33867. * Gets the flag that indicates if user zooming should stop animation.
  33868. */
  33869. zoomStopsAnimation: boolean;
  33870. /**
  33871. * Sets the transition time when framing the mesh, in milliseconds
  33872. */
  33873. /**
  33874. * Gets the transition time when framing the mesh, in milliseconds
  33875. */
  33876. framingTime: number;
  33877. /**
  33878. * Define if the behavior should automatically change the configured
  33879. * camera limits and sensibilities.
  33880. */
  33881. autoCorrectCameraLimitsAndSensibility: boolean;
  33882. private _onPrePointerObservableObserver;
  33883. private _onAfterCheckInputsObserver;
  33884. private _onMeshTargetChangedObserver;
  33885. private _attachedCamera;
  33886. private _isPointerDown;
  33887. private _lastInteractionTime;
  33888. /**
  33889. * Initializes the behavior.
  33890. */
  33891. init(): void;
  33892. /**
  33893. * Attaches the behavior to its arc rotate camera.
  33894. * @param camera Defines the camera to attach the behavior to
  33895. */
  33896. attach(camera: ArcRotateCamera): void;
  33897. /**
  33898. * Detaches the behavior from its current arc rotate camera.
  33899. */
  33900. detach(): void;
  33901. private _animatables;
  33902. private _betaIsAnimating;
  33903. private _betaTransition;
  33904. private _radiusTransition;
  33905. private _vectorTransition;
  33906. /**
  33907. * Targets the given mesh and updates zoom level accordingly.
  33908. * @param mesh The mesh to target.
  33909. * @param radius Optional. If a cached radius position already exists, overrides default.
  33910. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33911. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33912. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33913. */
  33914. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33915. /**
  33916. * Targets the given mesh with its children and updates zoom level accordingly.
  33917. * @param mesh The mesh to target.
  33918. * @param radius Optional. If a cached radius position already exists, overrides default.
  33919. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33920. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33921. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33922. */
  33923. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33924. /**
  33925. * Targets the given meshes with their children and updates zoom level accordingly.
  33926. * @param meshes The mesh to target.
  33927. * @param radius Optional. If a cached radius position already exists, overrides default.
  33928. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33929. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33930. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33931. */
  33932. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33933. /**
  33934. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33935. * @param minimumWorld Determines the smaller position of the bounding box extend
  33936. * @param maximumWorld Determines the bigger position of the bounding box extend
  33937. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33938. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33939. */
  33940. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33941. /**
  33942. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33943. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33944. * frustum width.
  33945. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33946. * to fully enclose the mesh in the viewing frustum.
  33947. */
  33948. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33949. /**
  33950. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33951. * is automatically returned to its default position (expected to be above ground plane).
  33952. */
  33953. private _maintainCameraAboveGround;
  33954. /**
  33955. * Returns the frustum slope based on the canvas ratio and camera FOV
  33956. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33957. */
  33958. private _getFrustumSlope;
  33959. /**
  33960. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33961. */
  33962. private _clearAnimationLocks;
  33963. /**
  33964. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33965. */
  33966. private _applyUserInteraction;
  33967. /**
  33968. * Stops and removes all animations that have been applied to the camera
  33969. */
  33970. stopAllAnimations(): void;
  33971. /**
  33972. * Gets a value indicating if the user is moving the camera
  33973. */
  33974. readonly isUserIsMoving: boolean;
  33975. /**
  33976. * The camera can move all the way towards the mesh.
  33977. */
  33978. static IgnoreBoundsSizeMode: number;
  33979. /**
  33980. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33981. */
  33982. static FitFrustumSidesMode: number;
  33983. }
  33984. }
  33985. declare module BABYLON {
  33986. /**
  33987. * Base class for Camera Pointer Inputs.
  33988. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33989. * for example usage.
  33990. */
  33991. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33992. /**
  33993. * Defines the camera the input is attached to.
  33994. */
  33995. abstract camera: Camera;
  33996. /**
  33997. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33998. */
  33999. protected _altKey: boolean;
  34000. protected _ctrlKey: boolean;
  34001. protected _metaKey: boolean;
  34002. protected _shiftKey: boolean;
  34003. /**
  34004. * Which mouse buttons were pressed at time of last mouse event.
  34005. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34006. */
  34007. protected _buttonsPressed: number;
  34008. /**
  34009. * Defines the buttons associated with the input to handle camera move.
  34010. */
  34011. buttons: number[];
  34012. /**
  34013. * Attach the input controls to a specific dom element to get the input from.
  34014. * @param element Defines the element the controls should be listened from
  34015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34016. */
  34017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34018. /**
  34019. * Detach the current controls from the specified dom element.
  34020. * @param element Defines the element to stop listening the inputs from
  34021. */
  34022. detachControl(element: Nullable<HTMLElement>): void;
  34023. /**
  34024. * Gets the class name of the current input.
  34025. * @returns the class name
  34026. */
  34027. getClassName(): string;
  34028. /**
  34029. * Get the friendly name associated with the input class.
  34030. * @returns the input friendly name
  34031. */
  34032. getSimpleName(): string;
  34033. /**
  34034. * Called on pointer POINTERDOUBLETAP event.
  34035. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34036. */
  34037. protected onDoubleTap(type: string): void;
  34038. /**
  34039. * Called on pointer POINTERMOVE event if only a single touch is active.
  34040. * Override this method to provide functionality.
  34041. */
  34042. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34043. /**
  34044. * Called on pointer POINTERMOVE event if multiple touches are active.
  34045. * Override this method to provide functionality.
  34046. */
  34047. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34048. /**
  34049. * Called on JS contextmenu event.
  34050. * Override this method to provide functionality.
  34051. */
  34052. protected onContextMenu(evt: PointerEvent): void;
  34053. /**
  34054. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34055. * press.
  34056. * Override this method to provide functionality.
  34057. */
  34058. protected onButtonDown(evt: PointerEvent): void;
  34059. /**
  34060. * Called each time a new POINTERUP event occurs. Ie, for each button
  34061. * release.
  34062. * Override this method to provide functionality.
  34063. */
  34064. protected onButtonUp(evt: PointerEvent): void;
  34065. /**
  34066. * Called when window becomes inactive.
  34067. * Override this method to provide functionality.
  34068. */
  34069. protected onLostFocus(): void;
  34070. private _pointerInput;
  34071. private _observer;
  34072. private _onLostFocus;
  34073. private pointA;
  34074. private pointB;
  34075. }
  34076. }
  34077. declare module BABYLON {
  34078. /**
  34079. * Manage the pointers inputs to control an arc rotate camera.
  34080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34081. */
  34082. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34083. /**
  34084. * Defines the camera the input is attached to.
  34085. */
  34086. camera: ArcRotateCamera;
  34087. /**
  34088. * Gets the class name of the current input.
  34089. * @returns the class name
  34090. */
  34091. getClassName(): string;
  34092. /**
  34093. * Defines the buttons associated with the input to handle camera move.
  34094. */
  34095. buttons: number[];
  34096. /**
  34097. * Defines the pointer angular sensibility along the X axis or how fast is
  34098. * the camera rotating.
  34099. */
  34100. angularSensibilityX: number;
  34101. /**
  34102. * Defines the pointer angular sensibility along the Y axis or how fast is
  34103. * the camera rotating.
  34104. */
  34105. angularSensibilityY: number;
  34106. /**
  34107. * Defines the pointer pinch precision or how fast is the camera zooming.
  34108. */
  34109. pinchPrecision: number;
  34110. /**
  34111. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34112. * from 0.
  34113. * It defines the percentage of current camera.radius to use as delta when
  34114. * pinch zoom is used.
  34115. */
  34116. pinchDeltaPercentage: number;
  34117. /**
  34118. * Defines the pointer panning sensibility or how fast is the camera moving.
  34119. */
  34120. panningSensibility: number;
  34121. /**
  34122. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34123. */
  34124. multiTouchPanning: boolean;
  34125. /**
  34126. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34127. * zoom (pinch) through multitouch.
  34128. */
  34129. multiTouchPanAndZoom: boolean;
  34130. /**
  34131. * Revers pinch action direction.
  34132. */
  34133. pinchInwards: boolean;
  34134. private _isPanClick;
  34135. private _twoFingerActivityCount;
  34136. private _isPinching;
  34137. /**
  34138. * Called on pointer POINTERMOVE event if only a single touch is active.
  34139. */
  34140. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34141. /**
  34142. * Called on pointer POINTERDOUBLETAP event.
  34143. */
  34144. protected onDoubleTap(type: string): void;
  34145. /**
  34146. * Called on pointer POINTERMOVE event if multiple touches are active.
  34147. */
  34148. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34149. /**
  34150. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34151. * press.
  34152. */
  34153. protected onButtonDown(evt: PointerEvent): void;
  34154. /**
  34155. * Called each time a new POINTERUP event occurs. Ie, for each button
  34156. * release.
  34157. */
  34158. protected onButtonUp(evt: PointerEvent): void;
  34159. /**
  34160. * Called when window becomes inactive.
  34161. */
  34162. protected onLostFocus(): void;
  34163. }
  34164. }
  34165. declare module BABYLON {
  34166. /**
  34167. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34169. */
  34170. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34171. /**
  34172. * Defines the camera the input is attached to.
  34173. */
  34174. camera: ArcRotateCamera;
  34175. /**
  34176. * Defines the list of key codes associated with the up action (increase alpha)
  34177. */
  34178. keysUp: number[];
  34179. /**
  34180. * Defines the list of key codes associated with the down action (decrease alpha)
  34181. */
  34182. keysDown: number[];
  34183. /**
  34184. * Defines the list of key codes associated with the left action (increase beta)
  34185. */
  34186. keysLeft: number[];
  34187. /**
  34188. * Defines the list of key codes associated with the right action (decrease beta)
  34189. */
  34190. keysRight: number[];
  34191. /**
  34192. * Defines the list of key codes associated with the reset action.
  34193. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34194. */
  34195. keysReset: number[];
  34196. /**
  34197. * Defines the panning sensibility of the inputs.
  34198. * (How fast is the camera paning)
  34199. */
  34200. panningSensibility: number;
  34201. /**
  34202. * Defines the zooming sensibility of the inputs.
  34203. * (How fast is the camera zooming)
  34204. */
  34205. zoomingSensibility: number;
  34206. /**
  34207. * Defines wether maintaining the alt key down switch the movement mode from
  34208. * orientation to zoom.
  34209. */
  34210. useAltToZoom: boolean;
  34211. /**
  34212. * Rotation speed of the camera
  34213. */
  34214. angularSpeed: number;
  34215. private _keys;
  34216. private _ctrlPressed;
  34217. private _altPressed;
  34218. private _onCanvasBlurObserver;
  34219. private _onKeyboardObserver;
  34220. private _engine;
  34221. private _scene;
  34222. /**
  34223. * Attach the input controls to a specific dom element to get the input from.
  34224. * @param element Defines the element the controls should be listened from
  34225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34226. */
  34227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34228. /**
  34229. * Detach the current controls from the specified dom element.
  34230. * @param element Defines the element to stop listening the inputs from
  34231. */
  34232. detachControl(element: Nullable<HTMLElement>): void;
  34233. /**
  34234. * Update the current camera state depending on the inputs that have been used this frame.
  34235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34236. */
  34237. checkInputs(): void;
  34238. /**
  34239. * Gets the class name of the current intput.
  34240. * @returns the class name
  34241. */
  34242. getClassName(): string;
  34243. /**
  34244. * Get the friendly name associated with the input class.
  34245. * @returns the input friendly name
  34246. */
  34247. getSimpleName(): string;
  34248. }
  34249. }
  34250. declare module BABYLON {
  34251. /**
  34252. * Manage the mouse wheel inputs to control an arc rotate camera.
  34253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34254. */
  34255. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34256. /**
  34257. * Defines the camera the input is attached to.
  34258. */
  34259. camera: ArcRotateCamera;
  34260. /**
  34261. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34262. */
  34263. wheelPrecision: number;
  34264. /**
  34265. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34266. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34267. */
  34268. wheelDeltaPercentage: number;
  34269. private _wheel;
  34270. private _observer;
  34271. /**
  34272. * Attach the input controls to a specific dom element to get the input from.
  34273. * @param element Defines the element the controls should be listened from
  34274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34275. */
  34276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34277. /**
  34278. * Detach the current controls from the specified dom element.
  34279. * @param element Defines the element to stop listening the inputs from
  34280. */
  34281. detachControl(element: Nullable<HTMLElement>): void;
  34282. /**
  34283. * Gets the class name of the current intput.
  34284. * @returns the class name
  34285. */
  34286. getClassName(): string;
  34287. /**
  34288. * Get the friendly name associated with the input class.
  34289. * @returns the input friendly name
  34290. */
  34291. getSimpleName(): string;
  34292. }
  34293. }
  34294. declare module BABYLON {
  34295. /**
  34296. * Default Inputs manager for the ArcRotateCamera.
  34297. * It groups all the default supported inputs for ease of use.
  34298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34299. */
  34300. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34301. /**
  34302. * Instantiates a new ArcRotateCameraInputsManager.
  34303. * @param camera Defines the camera the inputs belong to
  34304. */
  34305. constructor(camera: ArcRotateCamera);
  34306. /**
  34307. * Add mouse wheel input support to the input manager.
  34308. * @returns the current input manager
  34309. */
  34310. addMouseWheel(): ArcRotateCameraInputsManager;
  34311. /**
  34312. * Add pointers input support to the input manager.
  34313. * @returns the current input manager
  34314. */
  34315. addPointers(): ArcRotateCameraInputsManager;
  34316. /**
  34317. * Add keyboard input support to the input manager.
  34318. * @returns the current input manager
  34319. */
  34320. addKeyboard(): ArcRotateCameraInputsManager;
  34321. }
  34322. }
  34323. declare module BABYLON {
  34324. /**
  34325. * This represents an orbital type of camera.
  34326. *
  34327. * 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.
  34328. * 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.
  34329. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34330. */
  34331. export class ArcRotateCamera extends TargetCamera {
  34332. /**
  34333. * Defines the rotation angle of the camera along the longitudinal axis.
  34334. */
  34335. alpha: number;
  34336. /**
  34337. * Defines the rotation angle of the camera along the latitudinal axis.
  34338. */
  34339. beta: number;
  34340. /**
  34341. * Defines the radius of the camera from it s target point.
  34342. */
  34343. radius: number;
  34344. protected _target: Vector3;
  34345. protected _targetHost: Nullable<AbstractMesh>;
  34346. /**
  34347. * Defines the target point of the camera.
  34348. * The camera looks towards it form the radius distance.
  34349. */
  34350. target: Vector3;
  34351. /**
  34352. * Define the current local position of the camera in the scene
  34353. */
  34354. position: Vector3;
  34355. protected _upVector: Vector3;
  34356. protected _upToYMatrix: Matrix;
  34357. protected _YToUpMatrix: Matrix;
  34358. /**
  34359. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34360. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34361. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34362. */
  34363. upVector: Vector3;
  34364. /**
  34365. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34366. */
  34367. setMatUp(): void;
  34368. /**
  34369. * Current inertia value on the longitudinal axis.
  34370. * The bigger this number the longer it will take for the camera to stop.
  34371. */
  34372. inertialAlphaOffset: number;
  34373. /**
  34374. * Current inertia value on the latitudinal axis.
  34375. * The bigger this number the longer it will take for the camera to stop.
  34376. */
  34377. inertialBetaOffset: number;
  34378. /**
  34379. * Current inertia value on the radius axis.
  34380. * The bigger this number the longer it will take for the camera to stop.
  34381. */
  34382. inertialRadiusOffset: number;
  34383. /**
  34384. * Minimum allowed angle on the longitudinal axis.
  34385. * This can help limiting how the Camera is able to move in the scene.
  34386. */
  34387. lowerAlphaLimit: Nullable<number>;
  34388. /**
  34389. * Maximum allowed angle on the longitudinal axis.
  34390. * This can help limiting how the Camera is able to move in the scene.
  34391. */
  34392. upperAlphaLimit: Nullable<number>;
  34393. /**
  34394. * Minimum allowed angle on the latitudinal axis.
  34395. * This can help limiting how the Camera is able to move in the scene.
  34396. */
  34397. lowerBetaLimit: number;
  34398. /**
  34399. * Maximum allowed angle on the latitudinal axis.
  34400. * This can help limiting how the Camera is able to move in the scene.
  34401. */
  34402. upperBetaLimit: number;
  34403. /**
  34404. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34405. * This can help limiting how the Camera is able to move in the scene.
  34406. */
  34407. lowerRadiusLimit: Nullable<number>;
  34408. /**
  34409. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34410. * This can help limiting how the Camera is able to move in the scene.
  34411. */
  34412. upperRadiusLimit: Nullable<number>;
  34413. /**
  34414. * Defines the current inertia value used during panning of the camera along the X axis.
  34415. */
  34416. inertialPanningX: number;
  34417. /**
  34418. * Defines the current inertia value used during panning of the camera along the Y axis.
  34419. */
  34420. inertialPanningY: number;
  34421. /**
  34422. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34423. * Basically if your fingers moves away from more than this distance you will be considered
  34424. * in pinch mode.
  34425. */
  34426. pinchToPanMaxDistance: number;
  34427. /**
  34428. * Defines the maximum distance the camera can pan.
  34429. * This could help keeping the cammera always in your scene.
  34430. */
  34431. panningDistanceLimit: Nullable<number>;
  34432. /**
  34433. * Defines the target of the camera before paning.
  34434. */
  34435. panningOriginTarget: Vector3;
  34436. /**
  34437. * Defines the value of the inertia used during panning.
  34438. * 0 would mean stop inertia and one would mean no decelleration at all.
  34439. */
  34440. panningInertia: number;
  34441. /**
  34442. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34443. */
  34444. angularSensibilityX: number;
  34445. /**
  34446. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34447. */
  34448. angularSensibilityY: number;
  34449. /**
  34450. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34451. */
  34452. pinchPrecision: number;
  34453. /**
  34454. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34455. * It will be used instead of pinchDeltaPrecision if different from 0.
  34456. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34457. */
  34458. pinchDeltaPercentage: number;
  34459. /**
  34460. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34461. */
  34462. panningSensibility: number;
  34463. /**
  34464. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34465. */
  34466. keysUp: number[];
  34467. /**
  34468. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34469. */
  34470. keysDown: number[];
  34471. /**
  34472. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34473. */
  34474. keysLeft: number[];
  34475. /**
  34476. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34477. */
  34478. keysRight: number[];
  34479. /**
  34480. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34481. */
  34482. wheelPrecision: number;
  34483. /**
  34484. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34485. * It will be used instead of pinchDeltaPrecision if different from 0.
  34486. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34487. */
  34488. wheelDeltaPercentage: number;
  34489. /**
  34490. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34491. */
  34492. zoomOnFactor: number;
  34493. /**
  34494. * Defines a screen offset for the camera position.
  34495. */
  34496. targetScreenOffset: Vector2;
  34497. /**
  34498. * Allows the camera to be completely reversed.
  34499. * If false the camera can not arrive upside down.
  34500. */
  34501. allowUpsideDown: boolean;
  34502. /**
  34503. * Define if double tap/click is used to restore the previously saved state of the camera.
  34504. */
  34505. useInputToRestoreState: boolean;
  34506. /** @hidden */ viewMatrix: Matrix;
  34507. /** @hidden */ useCtrlForPanning: boolean;
  34508. /** @hidden */ panningMouseButton: number;
  34509. /**
  34510. * Defines the input associated to the camera.
  34511. */
  34512. inputs: ArcRotateCameraInputsManager;
  34513. /** @hidden */ reset: () => void;
  34514. /**
  34515. * Defines the allowed panning axis.
  34516. */
  34517. panningAxis: Vector3;
  34518. protected _localDirection: Vector3;
  34519. protected _transformedDirection: Vector3;
  34520. private _bouncingBehavior;
  34521. /**
  34522. * Gets the bouncing behavior of the camera if it has been enabled.
  34523. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34524. */
  34525. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34526. /**
  34527. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34528. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34529. */
  34530. useBouncingBehavior: boolean;
  34531. private _framingBehavior;
  34532. /**
  34533. * Gets the framing behavior of the camera if it has been enabled.
  34534. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34535. */
  34536. readonly framingBehavior: Nullable<FramingBehavior>;
  34537. /**
  34538. * Defines if the framing behavior of the camera is enabled on the camera.
  34539. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34540. */
  34541. useFramingBehavior: boolean;
  34542. private _autoRotationBehavior;
  34543. /**
  34544. * Gets the auto rotation behavior of the camera if it has been enabled.
  34545. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34546. */
  34547. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34548. /**
  34549. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34551. */
  34552. useAutoRotationBehavior: boolean;
  34553. /**
  34554. * Observable triggered when the mesh target has been changed on the camera.
  34555. */
  34556. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34557. /**
  34558. * Event raised when the camera is colliding with a mesh.
  34559. */
  34560. onCollide: (collidedMesh: AbstractMesh) => void;
  34561. /**
  34562. * Defines whether the camera should check collision with the objects oh the scene.
  34563. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34564. */
  34565. checkCollisions: boolean;
  34566. /**
  34567. * Defines the collision radius of the camera.
  34568. * This simulates a sphere around the camera.
  34569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34570. */
  34571. collisionRadius: Vector3;
  34572. protected _collider: Collider;
  34573. protected _previousPosition: Vector3;
  34574. protected _collisionVelocity: Vector3;
  34575. protected _newPosition: Vector3;
  34576. protected _previousAlpha: number;
  34577. protected _previousBeta: number;
  34578. protected _previousRadius: number;
  34579. protected _collisionTriggered: boolean;
  34580. protected _targetBoundingCenter: Nullable<Vector3>;
  34581. private _computationVector;
  34582. /**
  34583. * Instantiates a new ArcRotateCamera in a given scene
  34584. * @param name Defines the name of the camera
  34585. * @param alpha Defines the camera rotation along the logitudinal axis
  34586. * @param beta Defines the camera rotation along the latitudinal axis
  34587. * @param radius Defines the camera distance from its target
  34588. * @param target Defines the camera target
  34589. * @param scene Defines the scene the camera belongs to
  34590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34591. */
  34592. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34593. /** @hidden */ initCache(): void;
  34594. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34595. protected _getTargetPosition(): Vector3;
  34596. private _storedAlpha;
  34597. private _storedBeta;
  34598. private _storedRadius;
  34599. private _storedTarget;
  34600. /**
  34601. * Stores the current state of the camera (alpha, beta, radius and target)
  34602. * @returns the camera itself
  34603. */
  34604. storeState(): Camera;
  34605. /**
  34606. * @hidden
  34607. * Restored camera state. You must call storeState() first
  34608. */ restoreStateValues(): boolean;
  34609. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34610. /**
  34611. * Attached controls to the current camera.
  34612. * @param element Defines the element the controls should be listened from
  34613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34614. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34615. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34616. */
  34617. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34618. /**
  34619. * Detach the current controls from the camera.
  34620. * The camera will stop reacting to inputs.
  34621. * @param element Defines the element to stop listening the inputs from
  34622. */
  34623. detachControl(element: HTMLElement): void;
  34624. /** @hidden */ checkInputs(): void;
  34625. protected _checkLimits(): void;
  34626. /**
  34627. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34628. */
  34629. rebuildAnglesAndRadius(): void;
  34630. /**
  34631. * Use a position to define the current camera related information like aplha, beta and radius
  34632. * @param position Defines the position to set the camera at
  34633. */
  34634. setPosition(position: Vector3): void;
  34635. /**
  34636. * Defines the target the camera should look at.
  34637. * This will automatically adapt alpha beta and radius to fit within the new target.
  34638. * @param target Defines the new target as a Vector or a mesh
  34639. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34640. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34641. */
  34642. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34643. /** @hidden */ getViewMatrix(): Matrix;
  34644. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34645. /**
  34646. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34647. * @param meshes Defines the mesh to zoom on
  34648. * @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)
  34649. */
  34650. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34651. /**
  34652. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34653. * The target will be changed but the radius
  34654. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34655. * @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)
  34656. */
  34657. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34658. min: Vector3;
  34659. max: Vector3;
  34660. distance: number;
  34661. }, doNotUpdateMaxZ?: boolean): void;
  34662. /**
  34663. * @override
  34664. * Override Camera.createRigCamera
  34665. */
  34666. createRigCamera(name: string, cameraIndex: number): Camera;
  34667. /**
  34668. * @hidden
  34669. * @override
  34670. * Override Camera._updateRigCameras
  34671. */ updateRigCameras(): void;
  34672. /**
  34673. * Destroy the camera and release the current resources hold by it.
  34674. */
  34675. dispose(): void;
  34676. /**
  34677. * Gets the current object class name.
  34678. * @return the class name
  34679. */
  34680. getClassName(): string;
  34681. }
  34682. }
  34683. declare module BABYLON {
  34684. /**
  34685. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34687. */
  34688. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34689. /**
  34690. * Gets the name of the behavior.
  34691. */
  34692. readonly name: string;
  34693. private _zoomStopsAnimation;
  34694. private _idleRotationSpeed;
  34695. private _idleRotationWaitTime;
  34696. private _idleRotationSpinupTime;
  34697. /**
  34698. * Sets the flag that indicates if user zooming should stop animation.
  34699. */
  34700. /**
  34701. * Gets the flag that indicates if user zooming should stop animation.
  34702. */
  34703. zoomStopsAnimation: boolean;
  34704. /**
  34705. * Sets the default speed at which the camera rotates around the model.
  34706. */
  34707. /**
  34708. * Gets the default speed at which the camera rotates around the model.
  34709. */
  34710. idleRotationSpeed: number;
  34711. /**
  34712. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34713. */
  34714. /**
  34715. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34716. */
  34717. idleRotationWaitTime: number;
  34718. /**
  34719. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34720. */
  34721. /**
  34722. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34723. */
  34724. idleRotationSpinupTime: number;
  34725. /**
  34726. * Gets a value indicating if the camera is currently rotating because of this behavior
  34727. */
  34728. readonly rotationInProgress: boolean;
  34729. private _onPrePointerObservableObserver;
  34730. private _onAfterCheckInputsObserver;
  34731. private _attachedCamera;
  34732. private _isPointerDown;
  34733. private _lastFrameTime;
  34734. private _lastInteractionTime;
  34735. private _cameraRotationSpeed;
  34736. /**
  34737. * Initializes the behavior.
  34738. */
  34739. init(): void;
  34740. /**
  34741. * Attaches the behavior to its arc rotate camera.
  34742. * @param camera Defines the camera to attach the behavior to
  34743. */
  34744. attach(camera: ArcRotateCamera): void;
  34745. /**
  34746. * Detaches the behavior from its current arc rotate camera.
  34747. */
  34748. detach(): void;
  34749. /**
  34750. * Returns true if user is scrolling.
  34751. * @return true if user is scrolling.
  34752. */
  34753. private _userIsZooming;
  34754. private _lastFrameRadius;
  34755. private _shouldAnimationStopForInteraction;
  34756. /**
  34757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34758. */
  34759. private _applyUserInteraction;
  34760. private _userIsMoving;
  34761. }
  34762. }
  34763. declare module BABYLON {
  34764. /**
  34765. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34766. */
  34767. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34768. private ui;
  34769. /**
  34770. * The name of the behavior
  34771. */
  34772. name: string;
  34773. /**
  34774. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34775. */
  34776. distanceAwayFromFace: number;
  34777. /**
  34778. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34779. */
  34780. distanceAwayFromBottomOfFace: number;
  34781. private _faceVectors;
  34782. private _target;
  34783. private _scene;
  34784. private _onRenderObserver;
  34785. private _tmpMatrix;
  34786. private _tmpVector;
  34787. /**
  34788. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34789. * @param ui The transform node that should be attched to the mesh
  34790. */
  34791. constructor(ui: TransformNode);
  34792. /**
  34793. * Initializes the behavior
  34794. */
  34795. init(): void;
  34796. private _closestFace;
  34797. private _zeroVector;
  34798. private _lookAtTmpMatrix;
  34799. private _lookAtToRef;
  34800. /**
  34801. * Attaches the AttachToBoxBehavior to the passed in mesh
  34802. * @param target The mesh that the specified node will be attached to
  34803. */
  34804. attach(target: Mesh): void;
  34805. /**
  34806. * Detaches the behavior from the mesh
  34807. */
  34808. detach(): void;
  34809. }
  34810. }
  34811. declare module BABYLON {
  34812. /**
  34813. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34814. */
  34815. export class FadeInOutBehavior implements Behavior<Mesh> {
  34816. /**
  34817. * Time in milliseconds to delay before fading in (Default: 0)
  34818. */
  34819. delay: number;
  34820. /**
  34821. * Time in milliseconds for the mesh to fade in (Default: 300)
  34822. */
  34823. fadeInTime: number;
  34824. private _millisecondsPerFrame;
  34825. private _hovered;
  34826. private _hoverValue;
  34827. private _ownerNode;
  34828. /**
  34829. * Instatiates the FadeInOutBehavior
  34830. */
  34831. constructor();
  34832. /**
  34833. * The name of the behavior
  34834. */
  34835. readonly name: string;
  34836. /**
  34837. * Initializes the behavior
  34838. */
  34839. init(): void;
  34840. /**
  34841. * Attaches the fade behavior on the passed in mesh
  34842. * @param ownerNode The mesh that will be faded in/out once attached
  34843. */
  34844. attach(ownerNode: Mesh): void;
  34845. /**
  34846. * Detaches the behavior from the mesh
  34847. */
  34848. detach(): void;
  34849. /**
  34850. * Triggers the mesh to begin fading in or out
  34851. * @param value if the object should fade in or out (true to fade in)
  34852. */
  34853. fadeIn(value: boolean): void;
  34854. private _update;
  34855. private _setAllVisibility;
  34856. }
  34857. }
  34858. declare module BABYLON {
  34859. /**
  34860. * Class containing a set of static utilities functions for managing Pivots
  34861. * @hidden
  34862. */
  34863. export class PivotTools {
  34864. private static _PivotCached;
  34865. private static _OldPivotPoint;
  34866. private static _PivotTranslation;
  34867. private static _PivotTmpVector;
  34868. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34869. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. * Class containing static functions to help procedurally build meshes
  34875. */
  34876. export class PlaneBuilder {
  34877. /**
  34878. * Creates a plane mesh
  34879. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34880. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34881. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34883. * * 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
  34884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34885. * @param name defines the name of the mesh
  34886. * @param options defines the options used to create the mesh
  34887. * @param scene defines the hosting scene
  34888. * @returns the plane mesh
  34889. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34890. */
  34891. static CreatePlane(name: string, options: {
  34892. size?: number;
  34893. width?: number;
  34894. height?: number;
  34895. sideOrientation?: number;
  34896. frontUVs?: Vector4;
  34897. backUVs?: Vector4;
  34898. updatable?: boolean;
  34899. sourcePlane?: Plane;
  34900. }, scene?: Nullable<Scene>): Mesh;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. /**
  34905. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34906. */
  34907. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34908. private static _AnyMouseID;
  34909. private _attachedNode;
  34910. private _dragPlane;
  34911. private _scene;
  34912. private _pointerObserver;
  34913. private _beforeRenderObserver;
  34914. private static _planeScene;
  34915. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34916. /**
  34917. * 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)
  34918. */
  34919. maxDragAngle: number;
  34920. /**
  34921. * @hidden
  34922. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34923. /**
  34924. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34925. */
  34926. currentDraggingPointerID: number;
  34927. /**
  34928. * The last position where the pointer hit the drag plane in world space
  34929. */
  34930. lastDragPosition: Vector3;
  34931. /**
  34932. * If the behavior is currently in a dragging state
  34933. */
  34934. dragging: boolean;
  34935. /**
  34936. * 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)
  34937. */
  34938. dragDeltaRatio: number;
  34939. /**
  34940. * If the drag plane orientation should be updated during the dragging (Default: true)
  34941. */
  34942. updateDragPlane: boolean;
  34943. private _debugMode;
  34944. private _moving;
  34945. /**
  34946. * Fires each time the attached mesh is dragged with the pointer
  34947. * * delta between last drag position and current drag position in world space
  34948. * * dragDistance along the drag axis
  34949. * * dragPlaneNormal normal of the current drag plane used during the drag
  34950. * * dragPlanePoint in world space where the drag intersects the drag plane
  34951. */
  34952. onDragObservable: Observable<{
  34953. delta: Vector3;
  34954. dragPlanePoint: Vector3;
  34955. dragPlaneNormal: Vector3;
  34956. dragDistance: number;
  34957. pointerId: number;
  34958. }>;
  34959. /**
  34960. * Fires each time a drag begins (eg. mouse down on mesh)
  34961. */
  34962. onDragStartObservable: Observable<{
  34963. dragPlanePoint: Vector3;
  34964. pointerId: number;
  34965. }>;
  34966. /**
  34967. * Fires each time a drag ends (eg. mouse release after drag)
  34968. */
  34969. onDragEndObservable: Observable<{
  34970. dragPlanePoint: Vector3;
  34971. pointerId: number;
  34972. }>;
  34973. /**
  34974. * If the attached mesh should be moved when dragged
  34975. */
  34976. moveAttached: boolean;
  34977. /**
  34978. * If the drag behavior will react to drag events (Default: true)
  34979. */
  34980. enabled: boolean;
  34981. /**
  34982. * If camera controls should be detached during the drag
  34983. */
  34984. detachCameraControls: boolean;
  34985. /**
  34986. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34987. */
  34988. useObjectOrienationForDragging: boolean;
  34989. private _options;
  34990. /**
  34991. * Creates a pointer drag behavior that can be attached to a mesh
  34992. * @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)
  34993. */
  34994. constructor(options?: {
  34995. dragAxis?: Vector3;
  34996. dragPlaneNormal?: Vector3;
  34997. });
  34998. /**
  34999. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35000. */
  35001. validateDrag: (targetPosition: Vector3) => boolean;
  35002. /**
  35003. * The name of the behavior
  35004. */
  35005. readonly name: string;
  35006. /**
  35007. * Initializes the behavior
  35008. */
  35009. init(): void;
  35010. private _tmpVector;
  35011. private _alternatePickedPoint;
  35012. private _worldDragAxis;
  35013. private _targetPosition;
  35014. private _attachedElement;
  35015. /**
  35016. * Attaches the drag behavior the passed in mesh
  35017. * @param ownerNode The mesh that will be dragged around once attached
  35018. */
  35019. attach(ownerNode: AbstractMesh): void;
  35020. /**
  35021. * Force relase the drag action by code.
  35022. */
  35023. releaseDrag(): void;
  35024. private _startDragRay;
  35025. private _lastPointerRay;
  35026. /**
  35027. * Simulates the start of a pointer drag event on the behavior
  35028. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35029. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35030. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35031. */
  35032. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35033. private _startDrag;
  35034. private _dragDelta;
  35035. private _moveDrag;
  35036. private _pickWithRayOnDragPlane;
  35037. private _pointA;
  35038. private _pointB;
  35039. private _pointC;
  35040. private _lineA;
  35041. private _lineB;
  35042. private _localAxis;
  35043. private _lookAt;
  35044. private _updateDragPlanePosition;
  35045. /**
  35046. * Detaches the behavior from the mesh
  35047. */
  35048. detach(): void;
  35049. }
  35050. }
  35051. declare module BABYLON {
  35052. /**
  35053. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35054. */
  35055. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35056. private _dragBehaviorA;
  35057. private _dragBehaviorB;
  35058. private _startDistance;
  35059. private _initialScale;
  35060. private _targetScale;
  35061. private _ownerNode;
  35062. private _sceneRenderObserver;
  35063. /**
  35064. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35065. */
  35066. constructor();
  35067. /**
  35068. * The name of the behavior
  35069. */
  35070. readonly name: string;
  35071. /**
  35072. * Initializes the behavior
  35073. */
  35074. init(): void;
  35075. private _getCurrentDistance;
  35076. /**
  35077. * Attaches the scale behavior the passed in mesh
  35078. * @param ownerNode The mesh that will be scaled around once attached
  35079. */
  35080. attach(ownerNode: Mesh): void;
  35081. /**
  35082. * Detaches the behavior from the mesh
  35083. */
  35084. detach(): void;
  35085. }
  35086. }
  35087. declare module BABYLON {
  35088. /**
  35089. * 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
  35090. */
  35091. export class SixDofDragBehavior implements Behavior<Mesh> {
  35092. private static _virtualScene;
  35093. private _ownerNode;
  35094. private _sceneRenderObserver;
  35095. private _scene;
  35096. private _targetPosition;
  35097. private _virtualOriginMesh;
  35098. private _virtualDragMesh;
  35099. private _pointerObserver;
  35100. private _moving;
  35101. private _startingOrientation;
  35102. /**
  35103. * 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)
  35104. */
  35105. private zDragFactor;
  35106. /**
  35107. * If the object should rotate to face the drag origin
  35108. */
  35109. rotateDraggedObject: boolean;
  35110. /**
  35111. * If the behavior is currently in a dragging state
  35112. */
  35113. dragging: boolean;
  35114. /**
  35115. * 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)
  35116. */
  35117. dragDeltaRatio: number;
  35118. /**
  35119. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35120. */
  35121. currentDraggingPointerID: number;
  35122. /**
  35123. * If camera controls should be detached during the drag
  35124. */
  35125. detachCameraControls: boolean;
  35126. /**
  35127. * Fires each time a drag starts
  35128. */
  35129. onDragStartObservable: Observable<{}>;
  35130. /**
  35131. * Fires each time a drag ends (eg. mouse release after drag)
  35132. */
  35133. onDragEndObservable: Observable<{}>;
  35134. /**
  35135. * 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
  35136. */
  35137. constructor();
  35138. /**
  35139. * The name of the behavior
  35140. */
  35141. readonly name: string;
  35142. /**
  35143. * Initializes the behavior
  35144. */
  35145. init(): void;
  35146. /**
  35147. * Attaches the scale behavior the passed in mesh
  35148. * @param ownerNode The mesh that will be scaled around once attached
  35149. */
  35150. attach(ownerNode: Mesh): void;
  35151. /**
  35152. * Detaches the behavior from the mesh
  35153. */
  35154. detach(): void;
  35155. }
  35156. }
  35157. declare module BABYLON {
  35158. /**
  35159. * Class used to apply inverse kinematics to bones
  35160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35161. */
  35162. export class BoneIKController {
  35163. private static _tmpVecs;
  35164. private static _tmpQuat;
  35165. private static _tmpMats;
  35166. /**
  35167. * Gets or sets the target mesh
  35168. */
  35169. targetMesh: AbstractMesh;
  35170. /** Gets or sets the mesh used as pole */
  35171. poleTargetMesh: AbstractMesh;
  35172. /**
  35173. * Gets or sets the bone used as pole
  35174. */
  35175. poleTargetBone: Nullable<Bone>;
  35176. /**
  35177. * Gets or sets the target position
  35178. */
  35179. targetPosition: Vector3;
  35180. /**
  35181. * Gets or sets the pole target position
  35182. */
  35183. poleTargetPosition: Vector3;
  35184. /**
  35185. * Gets or sets the pole target local offset
  35186. */
  35187. poleTargetLocalOffset: Vector3;
  35188. /**
  35189. * Gets or sets the pole angle
  35190. */
  35191. poleAngle: number;
  35192. /**
  35193. * Gets or sets the mesh associated with the controller
  35194. */
  35195. mesh: AbstractMesh;
  35196. /**
  35197. * 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)
  35198. */
  35199. slerpAmount: number;
  35200. private _bone1Quat;
  35201. private _bone1Mat;
  35202. private _bone2Ang;
  35203. private _bone1;
  35204. private _bone2;
  35205. private _bone1Length;
  35206. private _bone2Length;
  35207. private _maxAngle;
  35208. private _maxReach;
  35209. private _rightHandedSystem;
  35210. private _bendAxis;
  35211. private _slerping;
  35212. private _adjustRoll;
  35213. /**
  35214. * Gets or sets maximum allowed angle
  35215. */
  35216. maxAngle: number;
  35217. /**
  35218. * Creates a new BoneIKController
  35219. * @param mesh defines the mesh to control
  35220. * @param bone defines the bone to control
  35221. * @param options defines options to set up the controller
  35222. */
  35223. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35224. targetMesh?: AbstractMesh;
  35225. poleTargetMesh?: AbstractMesh;
  35226. poleTargetBone?: Bone;
  35227. poleTargetLocalOffset?: Vector3;
  35228. poleAngle?: number;
  35229. bendAxis?: Vector3;
  35230. maxAngle?: number;
  35231. slerpAmount?: number;
  35232. });
  35233. private _setMaxAngle;
  35234. /**
  35235. * Force the controller to update the bones
  35236. */
  35237. update(): void;
  35238. }
  35239. }
  35240. declare module BABYLON {
  35241. /**
  35242. * Class used to make a bone look toward a point in space
  35243. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35244. */
  35245. export class BoneLookController {
  35246. private static _tmpVecs;
  35247. private static _tmpQuat;
  35248. private static _tmpMats;
  35249. /**
  35250. * The target Vector3 that the bone will look at
  35251. */
  35252. target: Vector3;
  35253. /**
  35254. * The mesh that the bone is attached to
  35255. */
  35256. mesh: AbstractMesh;
  35257. /**
  35258. * The bone that will be looking to the target
  35259. */
  35260. bone: Bone;
  35261. /**
  35262. * The up axis of the coordinate system that is used when the bone is rotated
  35263. */
  35264. upAxis: Vector3;
  35265. /**
  35266. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35267. */
  35268. upAxisSpace: Space;
  35269. /**
  35270. * Used to make an adjustment to the yaw of the bone
  35271. */
  35272. adjustYaw: number;
  35273. /**
  35274. * Used to make an adjustment to the pitch of the bone
  35275. */
  35276. adjustPitch: number;
  35277. /**
  35278. * Used to make an adjustment to the roll of the bone
  35279. */
  35280. adjustRoll: number;
  35281. /**
  35282. * 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)
  35283. */
  35284. slerpAmount: number;
  35285. private _minYaw;
  35286. private _maxYaw;
  35287. private _minPitch;
  35288. private _maxPitch;
  35289. private _minYawSin;
  35290. private _minYawCos;
  35291. private _maxYawSin;
  35292. private _maxYawCos;
  35293. private _midYawConstraint;
  35294. private _minPitchTan;
  35295. private _maxPitchTan;
  35296. private _boneQuat;
  35297. private _slerping;
  35298. private _transformYawPitch;
  35299. private _transformYawPitchInv;
  35300. private _firstFrameSkipped;
  35301. private _yawRange;
  35302. private _fowardAxis;
  35303. /**
  35304. * Gets or sets the minimum yaw angle that the bone can look to
  35305. */
  35306. minYaw: number;
  35307. /**
  35308. * Gets or sets the maximum yaw angle that the bone can look to
  35309. */
  35310. maxYaw: number;
  35311. /**
  35312. * Gets or sets the minimum pitch angle that the bone can look to
  35313. */
  35314. minPitch: number;
  35315. /**
  35316. * Gets or sets the maximum pitch angle that the bone can look to
  35317. */
  35318. maxPitch: number;
  35319. /**
  35320. * Create a BoneLookController
  35321. * @param mesh the mesh that the bone belongs to
  35322. * @param bone the bone that will be looking to the target
  35323. * @param target the target Vector3 to look at
  35324. * @param options optional settings:
  35325. * * maxYaw: the maximum angle the bone will yaw to
  35326. * * minYaw: the minimum angle the bone will yaw to
  35327. * * maxPitch: the maximum angle the bone will pitch to
  35328. * * minPitch: the minimum angle the bone will yaw to
  35329. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35330. * * upAxis: the up axis of the coordinate system
  35331. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35332. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35333. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35334. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35335. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35336. * * adjustRoll: used to make an adjustment to the roll of the bone
  35337. **/
  35338. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35339. maxYaw?: number;
  35340. minYaw?: number;
  35341. maxPitch?: number;
  35342. minPitch?: number;
  35343. slerpAmount?: number;
  35344. upAxis?: Vector3;
  35345. upAxisSpace?: Space;
  35346. yawAxis?: Vector3;
  35347. pitchAxis?: Vector3;
  35348. adjustYaw?: number;
  35349. adjustPitch?: number;
  35350. adjustRoll?: number;
  35351. });
  35352. /**
  35353. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35354. */
  35355. update(): void;
  35356. private _getAngleDiff;
  35357. private _getAngleBetween;
  35358. private _isAngleBetween;
  35359. }
  35360. }
  35361. declare module BABYLON {
  35362. /**
  35363. * Manage the gamepad inputs to control an arc rotate camera.
  35364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35365. */
  35366. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35367. /**
  35368. * Defines the camera the input is attached to.
  35369. */
  35370. camera: ArcRotateCamera;
  35371. /**
  35372. * Defines the gamepad the input is gathering event from.
  35373. */
  35374. gamepad: Nullable<Gamepad>;
  35375. /**
  35376. * Defines the gamepad rotation sensiblity.
  35377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35378. */
  35379. gamepadRotationSensibility: number;
  35380. /**
  35381. * Defines the gamepad move sensiblity.
  35382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35383. */
  35384. gamepadMoveSensibility: number;
  35385. private _onGamepadConnectedObserver;
  35386. private _onGamepadDisconnectedObserver;
  35387. /**
  35388. * Attach the input controls to a specific dom element to get the input from.
  35389. * @param element Defines the element the controls should be listened from
  35390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35391. */
  35392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35393. /**
  35394. * Detach the current controls from the specified dom element.
  35395. * @param element Defines the element to stop listening the inputs from
  35396. */
  35397. detachControl(element: Nullable<HTMLElement>): void;
  35398. /**
  35399. * Update the current camera state depending on the inputs that have been used this frame.
  35400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35401. */
  35402. checkInputs(): void;
  35403. /**
  35404. * Gets the class name of the current intput.
  35405. * @returns the class name
  35406. */
  35407. getClassName(): string;
  35408. /**
  35409. * Get the friendly name associated with the input class.
  35410. * @returns the input friendly name
  35411. */
  35412. getSimpleName(): string;
  35413. }
  35414. }
  35415. declare module BABYLON {
  35416. interface ArcRotateCameraInputsManager {
  35417. /**
  35418. * Add orientation input support to the input manager.
  35419. * @returns the current input manager
  35420. */
  35421. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35422. }
  35423. /**
  35424. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35426. */
  35427. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35428. /**
  35429. * Defines the camera the input is attached to.
  35430. */
  35431. camera: ArcRotateCamera;
  35432. /**
  35433. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35434. */
  35435. alphaCorrection: number;
  35436. /**
  35437. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35438. */
  35439. gammaCorrection: number;
  35440. private _alpha;
  35441. private _gamma;
  35442. private _dirty;
  35443. private _deviceOrientationHandler;
  35444. /**
  35445. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35446. */
  35447. constructor();
  35448. /**
  35449. * Attach the input controls to a specific dom element to get the input from.
  35450. * @param element Defines the element the controls should be listened from
  35451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35452. */
  35453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35454. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35455. /**
  35456. * Update the current camera state depending on the inputs that have been used this frame.
  35457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35458. */
  35459. checkInputs(): void;
  35460. /**
  35461. * Detach the current controls from the specified dom element.
  35462. * @param element Defines the element to stop listening the inputs from
  35463. */
  35464. detachControl(element: Nullable<HTMLElement>): void;
  35465. /**
  35466. * Gets the class name of the current intput.
  35467. * @returns the class name
  35468. */
  35469. getClassName(): string;
  35470. /**
  35471. * Get the friendly name associated with the input class.
  35472. * @returns the input friendly name
  35473. */
  35474. getSimpleName(): string;
  35475. }
  35476. }
  35477. declare module BABYLON {
  35478. /**
  35479. * Listen to mouse events to control the camera.
  35480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35481. */
  35482. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35483. /**
  35484. * Defines the camera the input is attached to.
  35485. */
  35486. camera: FlyCamera;
  35487. /**
  35488. * Defines if touch is enabled. (Default is true.)
  35489. */
  35490. touchEnabled: boolean;
  35491. /**
  35492. * Defines the buttons associated with the input to handle camera rotation.
  35493. */
  35494. buttons: number[];
  35495. /**
  35496. * Assign buttons for Yaw control.
  35497. */
  35498. buttonsYaw: number[];
  35499. /**
  35500. * Assign buttons for Pitch control.
  35501. */
  35502. buttonsPitch: number[];
  35503. /**
  35504. * Assign buttons for Roll control.
  35505. */
  35506. buttonsRoll: number[];
  35507. /**
  35508. * Detect if any button is being pressed while mouse is moved.
  35509. * -1 = Mouse locked.
  35510. * 0 = Left button.
  35511. * 1 = Middle Button.
  35512. * 2 = Right Button.
  35513. */
  35514. activeButton: number;
  35515. /**
  35516. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35517. * Higher values reduce its sensitivity.
  35518. */
  35519. angularSensibility: number;
  35520. private _mousemoveCallback;
  35521. private _observer;
  35522. private _rollObserver;
  35523. private previousPosition;
  35524. private noPreventDefault;
  35525. private element;
  35526. /**
  35527. * Listen to mouse events to control the camera.
  35528. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35530. */
  35531. constructor(touchEnabled?: boolean);
  35532. /**
  35533. * Attach the mouse control to the HTML DOM element.
  35534. * @param element Defines the element that listens to the input events.
  35535. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35536. */
  35537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35538. /**
  35539. * Detach the current controls from the specified dom element.
  35540. * @param element Defines the element to stop listening the inputs from
  35541. */
  35542. detachControl(element: Nullable<HTMLElement>): void;
  35543. /**
  35544. * Gets the class name of the current input.
  35545. * @returns the class name.
  35546. */
  35547. getClassName(): string;
  35548. /**
  35549. * Get the friendly name associated with the input class.
  35550. * @returns the input's friendly name.
  35551. */
  35552. getSimpleName(): string;
  35553. private _pointerInput;
  35554. private _onMouseMove;
  35555. /**
  35556. * Rotate camera by mouse offset.
  35557. */
  35558. private rotateCamera;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. /**
  35563. * Default Inputs manager for the FlyCamera.
  35564. * It groups all the default supported inputs for ease of use.
  35565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35566. */
  35567. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35568. /**
  35569. * Instantiates a new FlyCameraInputsManager.
  35570. * @param camera Defines the camera the inputs belong to.
  35571. */
  35572. constructor(camera: FlyCamera);
  35573. /**
  35574. * Add keyboard input support to the input manager.
  35575. * @returns the new FlyCameraKeyboardMoveInput().
  35576. */
  35577. addKeyboard(): FlyCameraInputsManager;
  35578. /**
  35579. * Add mouse input support to the input manager.
  35580. * @param touchEnabled Enable touch screen support.
  35581. * @returns the new FlyCameraMouseInput().
  35582. */
  35583. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35584. }
  35585. }
  35586. declare module BABYLON {
  35587. /**
  35588. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35589. * such as in a 3D Space Shooter or a Flight Simulator.
  35590. */
  35591. export class FlyCamera extends TargetCamera {
  35592. /**
  35593. * Define the collision ellipsoid of the camera.
  35594. * This is helpful for simulating a camera body, like a player's body.
  35595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35596. */
  35597. ellipsoid: Vector3;
  35598. /**
  35599. * Define an offset for the position of the ellipsoid around the camera.
  35600. * This can be helpful if the camera is attached away from the player's body center,
  35601. * such as at its head.
  35602. */
  35603. ellipsoidOffset: Vector3;
  35604. /**
  35605. * Enable or disable collisions of the camera with the rest of the scene objects.
  35606. */
  35607. checkCollisions: boolean;
  35608. /**
  35609. * Enable or disable gravity on the camera.
  35610. */
  35611. applyGravity: boolean;
  35612. /**
  35613. * Define the current direction the camera is moving to.
  35614. */
  35615. cameraDirection: Vector3;
  35616. /**
  35617. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35618. * This overrides and empties cameraRotation.
  35619. */
  35620. rotationQuaternion: Quaternion;
  35621. /**
  35622. * Track Roll to maintain the wanted Rolling when looking around.
  35623. */ trackRoll: number;
  35624. /**
  35625. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35626. */
  35627. rollCorrect: number;
  35628. /**
  35629. * Mimic a banked turn, Rolling the camera when Yawing.
  35630. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35631. */
  35632. bankedTurn: boolean;
  35633. /**
  35634. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35635. */
  35636. bankedTurnLimit: number;
  35637. /**
  35638. * Value of 0 disables the banked Roll.
  35639. * Value of 1 is equal to the Yaw angle in radians.
  35640. */
  35641. bankedTurnMultiplier: number;
  35642. /**
  35643. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35644. */
  35645. inputs: FlyCameraInputsManager;
  35646. /**
  35647. * Gets the input sensibility for mouse input.
  35648. * Higher values reduce sensitivity.
  35649. */
  35650. /**
  35651. * Sets the input sensibility for a mouse input.
  35652. * Higher values reduce sensitivity.
  35653. */
  35654. angularSensibility: number;
  35655. /**
  35656. * Get the keys for camera movement forward.
  35657. */
  35658. /**
  35659. * Set the keys for camera movement forward.
  35660. */
  35661. keysForward: number[];
  35662. /**
  35663. * Get the keys for camera movement backward.
  35664. */
  35665. keysBackward: number[];
  35666. /**
  35667. * Get the keys for camera movement up.
  35668. */
  35669. /**
  35670. * Set the keys for camera movement up.
  35671. */
  35672. keysUp: number[];
  35673. /**
  35674. * Get the keys for camera movement down.
  35675. */
  35676. /**
  35677. * Set the keys for camera movement down.
  35678. */
  35679. keysDown: number[];
  35680. /**
  35681. * Get the keys for camera movement left.
  35682. */
  35683. /**
  35684. * Set the keys for camera movement left.
  35685. */
  35686. keysLeft: number[];
  35687. /**
  35688. * Set the keys for camera movement right.
  35689. */
  35690. /**
  35691. * Set the keys for camera movement right.
  35692. */
  35693. keysRight: number[];
  35694. /**
  35695. * Event raised when the camera collides with a mesh in the scene.
  35696. */
  35697. onCollide: (collidedMesh: AbstractMesh) => void;
  35698. private _collider;
  35699. private _needMoveForGravity;
  35700. private _oldPosition;
  35701. private _diffPosition;
  35702. private _newPosition;
  35703. /** @hidden */ localDirection: Vector3;
  35704. /** @hidden */ transformedDirection: Vector3;
  35705. /**
  35706. * Instantiates a FlyCamera.
  35707. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35708. * such as in a 3D Space Shooter or a Flight Simulator.
  35709. * @param name Define the name of the camera in the scene.
  35710. * @param position Define the starting position of the camera in the scene.
  35711. * @param scene Define the scene the camera belongs to.
  35712. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35713. */
  35714. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35715. /**
  35716. * Attach a control to the HTML DOM element.
  35717. * @param element Defines the element that listens to the input events.
  35718. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35719. */
  35720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35721. /**
  35722. * Detach a control from the HTML DOM element.
  35723. * The camera will stop reacting to that input.
  35724. * @param element Defines the element that listens to the input events.
  35725. */
  35726. detachControl(element: HTMLElement): void;
  35727. private _collisionMask;
  35728. /**
  35729. * Get the mask that the camera ignores in collision events.
  35730. */
  35731. /**
  35732. * Set the mask that the camera ignores in collision events.
  35733. */
  35734. collisionMask: number;
  35735. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35736. /** @hidden */
  35737. private _onCollisionPositionChange;
  35738. /** @hidden */ checkInputs(): void;
  35739. /** @hidden */ decideIfNeedsToMove(): boolean;
  35740. /** @hidden */ updatePosition(): void;
  35741. /**
  35742. * Restore the Roll to its target value at the rate specified.
  35743. * @param rate - Higher means slower restoring.
  35744. * @hidden
  35745. */
  35746. restoreRoll(rate: number): void;
  35747. /**
  35748. * Destroy the camera and release the current resources held by it.
  35749. */
  35750. dispose(): void;
  35751. /**
  35752. * Get the current object class name.
  35753. * @returns the class name.
  35754. */
  35755. getClassName(): string;
  35756. }
  35757. }
  35758. declare module BABYLON {
  35759. /**
  35760. * Listen to keyboard events to control the camera.
  35761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35762. */
  35763. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35764. /**
  35765. * Defines the camera the input is attached to.
  35766. */
  35767. camera: FlyCamera;
  35768. /**
  35769. * The list of keyboard keys used to control the forward move of the camera.
  35770. */
  35771. keysForward: number[];
  35772. /**
  35773. * The list of keyboard keys used to control the backward move of the camera.
  35774. */
  35775. keysBackward: number[];
  35776. /**
  35777. * The list of keyboard keys used to control the forward move of the camera.
  35778. */
  35779. keysUp: number[];
  35780. /**
  35781. * The list of keyboard keys used to control the backward move of the camera.
  35782. */
  35783. keysDown: number[];
  35784. /**
  35785. * The list of keyboard keys used to control the right strafe move of the camera.
  35786. */
  35787. keysRight: number[];
  35788. /**
  35789. * The list of keyboard keys used to control the left strafe move of the camera.
  35790. */
  35791. keysLeft: number[];
  35792. private _keys;
  35793. private _onCanvasBlurObserver;
  35794. private _onKeyboardObserver;
  35795. private _engine;
  35796. private _scene;
  35797. /**
  35798. * Attach the input controls to a specific dom element to get the input from.
  35799. * @param element Defines the element the controls should be listened from
  35800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35801. */
  35802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35803. /**
  35804. * Detach the current controls from the specified dom element.
  35805. * @param element Defines the element to stop listening the inputs from
  35806. */
  35807. detachControl(element: Nullable<HTMLElement>): void;
  35808. /**
  35809. * Gets the class name of the current intput.
  35810. * @returns the class name
  35811. */
  35812. getClassName(): string;
  35813. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35814. /**
  35815. * Get the friendly name associated with the input class.
  35816. * @returns the input friendly name
  35817. */
  35818. getSimpleName(): string;
  35819. /**
  35820. * Update the current camera state depending on the inputs that have been used this frame.
  35821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35822. */
  35823. checkInputs(): void;
  35824. }
  35825. }
  35826. declare module BABYLON {
  35827. /**
  35828. * Manage the mouse wheel inputs to control a follow camera.
  35829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35830. */
  35831. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35832. /**
  35833. * Defines the camera the input is attached to.
  35834. */
  35835. camera: FollowCamera;
  35836. /**
  35837. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35838. */
  35839. axisControlRadius: boolean;
  35840. /**
  35841. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35842. */
  35843. axisControlHeight: boolean;
  35844. /**
  35845. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35846. */
  35847. axisControlRotation: boolean;
  35848. /**
  35849. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35850. * relation to mouseWheel events.
  35851. */
  35852. wheelPrecision: number;
  35853. /**
  35854. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35855. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35856. */
  35857. wheelDeltaPercentage: number;
  35858. private _wheel;
  35859. private _observer;
  35860. /**
  35861. * Attach the input controls to a specific dom element to get the input from.
  35862. * @param element Defines the element the controls should be listened from
  35863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35864. */
  35865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35866. /**
  35867. * Detach the current controls from the specified dom element.
  35868. * @param element Defines the element to stop listening the inputs from
  35869. */
  35870. detachControl(element: Nullable<HTMLElement>): void;
  35871. /**
  35872. * Gets the class name of the current intput.
  35873. * @returns the class name
  35874. */
  35875. getClassName(): string;
  35876. /**
  35877. * Get the friendly name associated with the input class.
  35878. * @returns the input friendly name
  35879. */
  35880. getSimpleName(): string;
  35881. }
  35882. }
  35883. declare module BABYLON {
  35884. /**
  35885. * Manage the pointers inputs to control an follow camera.
  35886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35887. */
  35888. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35889. /**
  35890. * Defines the camera the input is attached to.
  35891. */
  35892. camera: FollowCamera;
  35893. /**
  35894. * Gets the class name of the current input.
  35895. * @returns the class name
  35896. */
  35897. getClassName(): string;
  35898. /**
  35899. * Defines the pointer angular sensibility along the X axis or how fast is
  35900. * the camera rotating.
  35901. * A negative number will reverse the axis direction.
  35902. */
  35903. angularSensibilityX: number;
  35904. /**
  35905. * Defines the pointer angular sensibility along the Y axis or how fast is
  35906. * the camera rotating.
  35907. * A negative number will reverse the axis direction.
  35908. */
  35909. angularSensibilityY: number;
  35910. /**
  35911. * Defines the pointer pinch precision or how fast is the camera zooming.
  35912. * A negative number will reverse the axis direction.
  35913. */
  35914. pinchPrecision: number;
  35915. /**
  35916. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35917. * from 0.
  35918. * It defines the percentage of current camera.radius to use as delta when
  35919. * pinch zoom is used.
  35920. */
  35921. pinchDeltaPercentage: number;
  35922. /**
  35923. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35924. */
  35925. axisXControlRadius: boolean;
  35926. /**
  35927. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35928. */
  35929. axisXControlHeight: boolean;
  35930. /**
  35931. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35932. */
  35933. axisXControlRotation: boolean;
  35934. /**
  35935. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35936. */
  35937. axisYControlRadius: boolean;
  35938. /**
  35939. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35940. */
  35941. axisYControlHeight: boolean;
  35942. /**
  35943. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35944. */
  35945. axisYControlRotation: boolean;
  35946. /**
  35947. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35948. */
  35949. axisPinchControlRadius: boolean;
  35950. /**
  35951. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35952. */
  35953. axisPinchControlHeight: boolean;
  35954. /**
  35955. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35956. */
  35957. axisPinchControlRotation: boolean;
  35958. /**
  35959. * Log error messages if basic misconfiguration has occurred.
  35960. */
  35961. warningEnable: boolean;
  35962. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35963. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35964. private _warningCounter;
  35965. private _warning;
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. /**
  35970. * Default Inputs manager for the FollowCamera.
  35971. * It groups all the default supported inputs for ease of use.
  35972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35973. */
  35974. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35975. /**
  35976. * Instantiates a new FollowCameraInputsManager.
  35977. * @param camera Defines the camera the inputs belong to
  35978. */
  35979. constructor(camera: FollowCamera);
  35980. /**
  35981. * Add keyboard input support to the input manager.
  35982. * @returns the current input manager
  35983. */
  35984. addKeyboard(): FollowCameraInputsManager;
  35985. /**
  35986. * Add mouse wheel input support to the input manager.
  35987. * @returns the current input manager
  35988. */
  35989. addMouseWheel(): FollowCameraInputsManager;
  35990. /**
  35991. * Add pointers input support to the input manager.
  35992. * @returns the current input manager
  35993. */
  35994. addPointers(): FollowCameraInputsManager;
  35995. /**
  35996. * Add orientation input support to the input manager.
  35997. * @returns the current input manager
  35998. */
  35999. addVRDeviceOrientation(): FollowCameraInputsManager;
  36000. }
  36001. }
  36002. declare module BABYLON {
  36003. /**
  36004. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36005. * an arc rotate version arcFollowCamera are available.
  36006. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36007. */
  36008. export class FollowCamera extends TargetCamera {
  36009. /**
  36010. * Distance the follow camera should follow an object at
  36011. */
  36012. radius: number;
  36013. /**
  36014. * Minimum allowed distance of the camera to the axis of rotation
  36015. * (The camera can not get closer).
  36016. * This can help limiting how the Camera is able to move in the scene.
  36017. */
  36018. lowerRadiusLimit: Nullable<number>;
  36019. /**
  36020. * Maximum allowed distance of the camera to the axis of rotation
  36021. * (The camera can not get further).
  36022. * This can help limiting how the Camera is able to move in the scene.
  36023. */
  36024. upperRadiusLimit: Nullable<number>;
  36025. /**
  36026. * Define a rotation offset between the camera and the object it follows
  36027. */
  36028. rotationOffset: number;
  36029. /**
  36030. * Minimum allowed angle to camera position relative to target object.
  36031. * This can help limiting how the Camera is able to move in the scene.
  36032. */
  36033. lowerRotationOffsetLimit: Nullable<number>;
  36034. /**
  36035. * Maximum allowed angle to camera position relative to target object.
  36036. * This can help limiting how the Camera is able to move in the scene.
  36037. */
  36038. upperRotationOffsetLimit: Nullable<number>;
  36039. /**
  36040. * Define a height offset between the camera and the object it follows.
  36041. * It can help following an object from the top (like a car chaing a plane)
  36042. */
  36043. heightOffset: number;
  36044. /**
  36045. * Minimum allowed height of camera position relative to target object.
  36046. * This can help limiting how the Camera is able to move in the scene.
  36047. */
  36048. lowerHeightOffsetLimit: Nullable<number>;
  36049. /**
  36050. * Maximum allowed height of camera position relative to target object.
  36051. * This can help limiting how the Camera is able to move in the scene.
  36052. */
  36053. upperHeightOffsetLimit: Nullable<number>;
  36054. /**
  36055. * Define how fast the camera can accelerate to follow it s target.
  36056. */
  36057. cameraAcceleration: number;
  36058. /**
  36059. * Define the speed limit of the camera following an object.
  36060. */
  36061. maxCameraSpeed: number;
  36062. /**
  36063. * Define the target of the camera.
  36064. */
  36065. lockedTarget: Nullable<AbstractMesh>;
  36066. /**
  36067. * Defines the input associated with the camera.
  36068. */
  36069. inputs: FollowCameraInputsManager;
  36070. /**
  36071. * Instantiates the follow camera.
  36072. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36073. * @param name Define the name of the camera in the scene
  36074. * @param position Define the position of the camera
  36075. * @param scene Define the scene the camera belong to
  36076. * @param lockedTarget Define the target of the camera
  36077. */
  36078. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36079. private _follow;
  36080. /**
  36081. * Attached controls to the current camera.
  36082. * @param element Defines the element the controls should be listened from
  36083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36084. */
  36085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36086. /**
  36087. * Detach the current controls from the camera.
  36088. * The camera will stop reacting to inputs.
  36089. * @param element Defines the element to stop listening the inputs from
  36090. */
  36091. detachControl(element: HTMLElement): void;
  36092. /** @hidden */ checkInputs(): void;
  36093. private _checkLimits;
  36094. /**
  36095. * Gets the camera class name.
  36096. * @returns the class name
  36097. */
  36098. getClassName(): string;
  36099. }
  36100. /**
  36101. * Arc Rotate version of the follow camera.
  36102. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36103. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36104. */
  36105. export class ArcFollowCamera extends TargetCamera {
  36106. /** The longitudinal angle of the camera */
  36107. alpha: number;
  36108. /** The latitudinal angle of the camera */
  36109. beta: number;
  36110. /** The radius of the camera from its target */
  36111. radius: number;
  36112. /** Define the camera target (the messh it should follow) */
  36113. target: Nullable<AbstractMesh>;
  36114. private _cartesianCoordinates;
  36115. /**
  36116. * Instantiates a new ArcFollowCamera
  36117. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36118. * @param name Define the name of the camera
  36119. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36120. * @param beta Define the rotation angle of the camera around the elevation axis
  36121. * @param radius Define the radius of the camera from its target point
  36122. * @param target Define the target of the camera
  36123. * @param scene Define the scene the camera belongs to
  36124. */
  36125. constructor(name: string,
  36126. /** The longitudinal angle of the camera */
  36127. alpha: number,
  36128. /** The latitudinal angle of the camera */
  36129. beta: number,
  36130. /** The radius of the camera from its target */
  36131. radius: number,
  36132. /** Define the camera target (the messh it should follow) */
  36133. target: Nullable<AbstractMesh>, scene: Scene);
  36134. private _follow;
  36135. /** @hidden */ checkInputs(): void;
  36136. /**
  36137. * Returns the class name of the object.
  36138. * It is mostly used internally for serialization purposes.
  36139. */
  36140. getClassName(): string;
  36141. }
  36142. }
  36143. declare module BABYLON {
  36144. /**
  36145. * Manage the keyboard inputs to control the movement of a follow camera.
  36146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36147. */
  36148. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36149. /**
  36150. * Defines the camera the input is attached to.
  36151. */
  36152. camera: FollowCamera;
  36153. /**
  36154. * Defines the list of key codes associated with the up action (increase heightOffset)
  36155. */
  36156. keysHeightOffsetIncr: number[];
  36157. /**
  36158. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36159. */
  36160. keysHeightOffsetDecr: number[];
  36161. /**
  36162. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36163. */
  36164. keysHeightOffsetModifierAlt: boolean;
  36165. /**
  36166. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36167. */
  36168. keysHeightOffsetModifierCtrl: boolean;
  36169. /**
  36170. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36171. */
  36172. keysHeightOffsetModifierShift: boolean;
  36173. /**
  36174. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36175. */
  36176. keysRotationOffsetIncr: number[];
  36177. /**
  36178. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36179. */
  36180. keysRotationOffsetDecr: number[];
  36181. /**
  36182. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36183. */
  36184. keysRotationOffsetModifierAlt: boolean;
  36185. /**
  36186. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36187. */
  36188. keysRotationOffsetModifierCtrl: boolean;
  36189. /**
  36190. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36191. */
  36192. keysRotationOffsetModifierShift: boolean;
  36193. /**
  36194. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36195. */
  36196. keysRadiusIncr: number[];
  36197. /**
  36198. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36199. */
  36200. keysRadiusDecr: number[];
  36201. /**
  36202. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36203. */
  36204. keysRadiusModifierAlt: boolean;
  36205. /**
  36206. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36207. */
  36208. keysRadiusModifierCtrl: boolean;
  36209. /**
  36210. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36211. */
  36212. keysRadiusModifierShift: boolean;
  36213. /**
  36214. * Defines the rate of change of heightOffset.
  36215. */
  36216. heightSensibility: number;
  36217. /**
  36218. * Defines the rate of change of rotationOffset.
  36219. */
  36220. rotationSensibility: number;
  36221. /**
  36222. * Defines the rate of change of radius.
  36223. */
  36224. radiusSensibility: number;
  36225. private _keys;
  36226. private _ctrlPressed;
  36227. private _altPressed;
  36228. private _shiftPressed;
  36229. private _onCanvasBlurObserver;
  36230. private _onKeyboardObserver;
  36231. private _engine;
  36232. private _scene;
  36233. /**
  36234. * Attach the input controls to a specific dom element to get the input from.
  36235. * @param element Defines the element the controls should be listened from
  36236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36237. */
  36238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36239. /**
  36240. * Detach the current controls from the specified dom element.
  36241. * @param element Defines the element to stop listening the inputs from
  36242. */
  36243. detachControl(element: Nullable<HTMLElement>): void;
  36244. /**
  36245. * Update the current camera state depending on the inputs that have been used this frame.
  36246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36247. */
  36248. checkInputs(): void;
  36249. /**
  36250. * Gets the class name of the current input.
  36251. * @returns the class name
  36252. */
  36253. getClassName(): string;
  36254. /**
  36255. * Get the friendly name associated with the input class.
  36256. * @returns the input friendly name
  36257. */
  36258. getSimpleName(): string;
  36259. /**
  36260. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36261. * allow modification of the heightOffset value.
  36262. */
  36263. private _modifierHeightOffset;
  36264. /**
  36265. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36266. * allow modification of the rotationOffset value.
  36267. */
  36268. private _modifierRotationOffset;
  36269. /**
  36270. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36271. * allow modification of the radius value.
  36272. */
  36273. private _modifierRadius;
  36274. }
  36275. }
  36276. declare module BABYLON {
  36277. interface FreeCameraInputsManager {
  36278. /**
  36279. * @hidden
  36280. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36281. /**
  36282. * Add orientation input support to the input manager.
  36283. * @returns the current input manager
  36284. */
  36285. addDeviceOrientation(): FreeCameraInputsManager;
  36286. }
  36287. /**
  36288. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36289. * Screen rotation is taken into account.
  36290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36291. */
  36292. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36293. private _camera;
  36294. private _screenOrientationAngle;
  36295. private _constantTranform;
  36296. private _screenQuaternion;
  36297. private _alpha;
  36298. private _beta;
  36299. private _gamma;
  36300. /**
  36301. * @hidden
  36302. */ onDeviceOrientationChangedObservable: Observable<void>;
  36303. /**
  36304. * Instantiates a new input
  36305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36306. */
  36307. constructor();
  36308. /**
  36309. * Define the camera controlled by the input.
  36310. */
  36311. camera: FreeCamera;
  36312. /**
  36313. * Attach the input controls to a specific dom element to get the input from.
  36314. * @param element Defines the element the controls should be listened from
  36315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36316. */
  36317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36318. private _orientationChanged;
  36319. private _deviceOrientation;
  36320. /**
  36321. * Detach the current controls from the specified dom element.
  36322. * @param element Defines the element to stop listening the inputs from
  36323. */
  36324. detachControl(element: Nullable<HTMLElement>): void;
  36325. /**
  36326. * Update the current camera state depending on the inputs that have been used this frame.
  36327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36328. */
  36329. checkInputs(): void;
  36330. /**
  36331. * Gets the class name of the current intput.
  36332. * @returns the class name
  36333. */
  36334. getClassName(): string;
  36335. /**
  36336. * Get the friendly name associated with the input class.
  36337. * @returns the input friendly name
  36338. */
  36339. getSimpleName(): string;
  36340. }
  36341. }
  36342. declare module BABYLON {
  36343. /**
  36344. * Manage the gamepad inputs to control a free camera.
  36345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36346. */
  36347. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36348. /**
  36349. * Define the camera the input is attached to.
  36350. */
  36351. camera: FreeCamera;
  36352. /**
  36353. * Define the Gamepad controlling the input
  36354. */
  36355. gamepad: Nullable<Gamepad>;
  36356. /**
  36357. * Defines the gamepad rotation sensiblity.
  36358. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36359. */
  36360. gamepadAngularSensibility: number;
  36361. /**
  36362. * Defines the gamepad move sensiblity.
  36363. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36364. */
  36365. gamepadMoveSensibility: number;
  36366. private _onGamepadConnectedObserver;
  36367. private _onGamepadDisconnectedObserver;
  36368. private _cameraTransform;
  36369. private _deltaTransform;
  36370. private _vector3;
  36371. private _vector2;
  36372. /**
  36373. * Attach the input controls to a specific dom element to get the input from.
  36374. * @param element Defines the element the controls should be listened from
  36375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36376. */
  36377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36378. /**
  36379. * Detach the current controls from the specified dom element.
  36380. * @param element Defines the element to stop listening the inputs from
  36381. */
  36382. detachControl(element: Nullable<HTMLElement>): void;
  36383. /**
  36384. * Update the current camera state depending on the inputs that have been used this frame.
  36385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36386. */
  36387. checkInputs(): void;
  36388. /**
  36389. * Gets the class name of the current intput.
  36390. * @returns the class name
  36391. */
  36392. getClassName(): string;
  36393. /**
  36394. * Get the friendly name associated with the input class.
  36395. * @returns the input friendly name
  36396. */
  36397. getSimpleName(): string;
  36398. }
  36399. }
  36400. declare module BABYLON {
  36401. /**
  36402. * Defines the potential axis of a Joystick
  36403. */
  36404. export enum JoystickAxis {
  36405. /** X axis */
  36406. X = 0,
  36407. /** Y axis */
  36408. Y = 1,
  36409. /** Z axis */
  36410. Z = 2
  36411. }
  36412. /**
  36413. * Class used to define virtual joystick (used in touch mode)
  36414. */
  36415. export class VirtualJoystick {
  36416. /**
  36417. * Gets or sets a boolean indicating that left and right values must be inverted
  36418. */
  36419. reverseLeftRight: boolean;
  36420. /**
  36421. * Gets or sets a boolean indicating that up and down values must be inverted
  36422. */
  36423. reverseUpDown: boolean;
  36424. /**
  36425. * Gets the offset value for the position (ie. the change of the position value)
  36426. */
  36427. deltaPosition: Vector3;
  36428. /**
  36429. * Gets a boolean indicating if the virtual joystick was pressed
  36430. */
  36431. pressed: boolean;
  36432. /**
  36433. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36434. */
  36435. static Canvas: Nullable<HTMLCanvasElement>;
  36436. private static _globalJoystickIndex;
  36437. private static vjCanvasContext;
  36438. private static vjCanvasWidth;
  36439. private static vjCanvasHeight;
  36440. private static halfWidth;
  36441. private _action;
  36442. private _axisTargetedByLeftAndRight;
  36443. private _axisTargetedByUpAndDown;
  36444. private _joystickSensibility;
  36445. private _inversedSensibility;
  36446. private _joystickPointerID;
  36447. private _joystickColor;
  36448. private _joystickPointerPos;
  36449. private _joystickPreviousPointerPos;
  36450. private _joystickPointerStartPos;
  36451. private _deltaJoystickVector;
  36452. private _leftJoystick;
  36453. private _touches;
  36454. private _onPointerDownHandlerRef;
  36455. private _onPointerMoveHandlerRef;
  36456. private _onPointerUpHandlerRef;
  36457. private _onResize;
  36458. /**
  36459. * Creates a new virtual joystick
  36460. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36461. */
  36462. constructor(leftJoystick?: boolean);
  36463. /**
  36464. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36465. * @param newJoystickSensibility defines the new sensibility
  36466. */
  36467. setJoystickSensibility(newJoystickSensibility: number): void;
  36468. private _onPointerDown;
  36469. private _onPointerMove;
  36470. private _onPointerUp;
  36471. /**
  36472. * Change the color of the virtual joystick
  36473. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36474. */
  36475. setJoystickColor(newColor: string): void;
  36476. /**
  36477. * Defines a callback to call when the joystick is touched
  36478. * @param action defines the callback
  36479. */
  36480. setActionOnTouch(action: () => any): void;
  36481. /**
  36482. * Defines which axis you'd like to control for left & right
  36483. * @param axis defines the axis to use
  36484. */
  36485. setAxisForLeftRight(axis: JoystickAxis): void;
  36486. /**
  36487. * Defines which axis you'd like to control for up & down
  36488. * @param axis defines the axis to use
  36489. */
  36490. setAxisForUpDown(axis: JoystickAxis): void;
  36491. private _drawVirtualJoystick;
  36492. /**
  36493. * Release internal HTML canvas
  36494. */
  36495. releaseCanvas(): void;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. interface FreeCameraInputsManager {
  36500. /**
  36501. * Add virtual joystick input support to the input manager.
  36502. * @returns the current input manager
  36503. */
  36504. addVirtualJoystick(): FreeCameraInputsManager;
  36505. }
  36506. /**
  36507. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36509. */
  36510. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36511. /**
  36512. * Defines the camera the input is attached to.
  36513. */
  36514. camera: FreeCamera;
  36515. private _leftjoystick;
  36516. private _rightjoystick;
  36517. /**
  36518. * Gets the left stick of the virtual joystick.
  36519. * @returns The virtual Joystick
  36520. */
  36521. getLeftJoystick(): VirtualJoystick;
  36522. /**
  36523. * Gets the right stick of the virtual joystick.
  36524. * @returns The virtual Joystick
  36525. */
  36526. getRightJoystick(): VirtualJoystick;
  36527. /**
  36528. * Update the current camera state depending on the inputs that have been used this frame.
  36529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36530. */
  36531. checkInputs(): void;
  36532. /**
  36533. * Attach the input controls to a specific dom element to get the input from.
  36534. * @param element Defines the element the controls should be listened from
  36535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36536. */
  36537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36538. /**
  36539. * Detach the current controls from the specified dom element.
  36540. * @param element Defines the element to stop listening the inputs from
  36541. */
  36542. detachControl(element: Nullable<HTMLElement>): void;
  36543. /**
  36544. * Gets the class name of the current intput.
  36545. * @returns the class name
  36546. */
  36547. getClassName(): string;
  36548. /**
  36549. * Get the friendly name associated with the input class.
  36550. * @returns the input friendly name
  36551. */
  36552. getSimpleName(): string;
  36553. }
  36554. }
  36555. declare module BABYLON {
  36556. /**
  36557. * This represents a FPS type of camera controlled by touch.
  36558. * This is like a universal camera minus the Gamepad controls.
  36559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36560. */
  36561. export class TouchCamera extends FreeCamera {
  36562. /**
  36563. * Defines the touch sensibility for rotation.
  36564. * The higher the faster.
  36565. */
  36566. touchAngularSensibility: number;
  36567. /**
  36568. * Defines the touch sensibility for move.
  36569. * The higher the faster.
  36570. */
  36571. touchMoveSensibility: number;
  36572. /**
  36573. * Instantiates a new touch camera.
  36574. * This represents a FPS type of camera controlled by touch.
  36575. * This is like a universal camera minus the Gamepad controls.
  36576. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36577. * @param name Define the name of the camera in the scene
  36578. * @param position Define the start position of the camera in the scene
  36579. * @param scene Define the scene the camera belongs to
  36580. */
  36581. constructor(name: string, position: Vector3, scene: Scene);
  36582. /**
  36583. * Gets the current object class name.
  36584. * @return the class name
  36585. */
  36586. getClassName(): string;
  36587. /** @hidden */ setupInputs(): void;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36593. * being tilted forward or back and left or right.
  36594. */
  36595. export class DeviceOrientationCamera extends FreeCamera {
  36596. private _initialQuaternion;
  36597. private _quaternionCache;
  36598. private _tmpDragQuaternion;
  36599. /**
  36600. * Creates a new device orientation camera
  36601. * @param name The name of the camera
  36602. * @param position The start position camera
  36603. * @param scene The scene the camera belongs to
  36604. */
  36605. constructor(name: string, position: Vector3, scene: Scene);
  36606. /**
  36607. * @hidden
  36608. * Disabled pointer input on first orientation sensor update (Default: true)
  36609. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36610. private _dragFactor;
  36611. /**
  36612. * Enabled turning on the y axis when the orientation sensor is active
  36613. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36614. */
  36615. enableHorizontalDragging(dragFactor?: number): void;
  36616. /**
  36617. * Gets the current instance class name ("DeviceOrientationCamera").
  36618. * This helps avoiding instanceof at run time.
  36619. * @returns the class name
  36620. */
  36621. getClassName(): string;
  36622. /**
  36623. * @hidden
  36624. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36625. */ checkInputs(): void;
  36626. /**
  36627. * Reset the camera to its default orientation on the specified axis only.
  36628. * @param axis The axis to reset
  36629. */
  36630. resetToCurrentRotation(axis?: Axis): void;
  36631. }
  36632. }
  36633. declare module BABYLON {
  36634. /**
  36635. * 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,
  36636. * which still works and will still be found in many Playgrounds.
  36637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36638. */
  36639. export class UniversalCamera extends TouchCamera {
  36640. /**
  36641. * Defines the gamepad rotation sensiblity.
  36642. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36643. */
  36644. gamepadAngularSensibility: number;
  36645. /**
  36646. * Defines the gamepad move sensiblity.
  36647. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36648. */
  36649. gamepadMoveSensibility: number;
  36650. /**
  36651. * 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,
  36652. * which still works and will still be found in many Playgrounds.
  36653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36654. * @param name Define the name of the camera in the scene
  36655. * @param position Define the start position of the camera in the scene
  36656. * @param scene Define the scene the camera belongs to
  36657. */
  36658. constructor(name: string, position: Vector3, scene: Scene);
  36659. /**
  36660. * Gets the current object class name.
  36661. * @return the class name
  36662. */
  36663. getClassName(): string;
  36664. }
  36665. }
  36666. declare module BABYLON {
  36667. /**
  36668. * This represents a FPS type of camera. This is only here for back compat purpose.
  36669. * Please use the UniversalCamera instead as both are identical.
  36670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36671. */
  36672. export class GamepadCamera extends UniversalCamera {
  36673. /**
  36674. * Instantiates a new Gamepad Camera
  36675. * This represents a FPS type of camera. This is only here for back compat purpose.
  36676. * Please use the UniversalCamera instead as both are identical.
  36677. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36678. * @param name Define the name of the camera in the scene
  36679. * @param position Define the start position of the camera in the scene
  36680. * @param scene Define the scene the camera belongs to
  36681. */
  36682. constructor(name: string, position: Vector3, scene: Scene);
  36683. /**
  36684. * Gets the current object class name.
  36685. * @return the class name
  36686. */
  36687. getClassName(): string;
  36688. }
  36689. }
  36690. declare module BABYLON {
  36691. /** @hidden */
  36692. export var passPixelShader: {
  36693. name: string;
  36694. shader: string;
  36695. };
  36696. }
  36697. declare module BABYLON {
  36698. /** @hidden */
  36699. export var passCubePixelShader: {
  36700. name: string;
  36701. shader: string;
  36702. };
  36703. }
  36704. declare module BABYLON {
  36705. /**
  36706. * PassPostProcess which produces an output the same as it's input
  36707. */
  36708. export class PassPostProcess extends PostProcess {
  36709. /**
  36710. * Creates the PassPostProcess
  36711. * @param name The name of the effect.
  36712. * @param options The required width/height ratio to downsize to before computing the render pass.
  36713. * @param camera The camera to apply the render pass to.
  36714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36715. * @param engine The engine which the post process will be applied. (default: current engine)
  36716. * @param reusable If the post process can be reused on the same frame. (default: false)
  36717. * @param textureType The type of texture to be used when performing the post processing.
  36718. * @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)
  36719. */
  36720. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36721. }
  36722. /**
  36723. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36724. */
  36725. export class PassCubePostProcess extends PostProcess {
  36726. private _face;
  36727. /**
  36728. * Gets or sets the cube face to display.
  36729. * * 0 is +X
  36730. * * 1 is -X
  36731. * * 2 is +Y
  36732. * * 3 is -Y
  36733. * * 4 is +Z
  36734. * * 5 is -Z
  36735. */
  36736. face: number;
  36737. /**
  36738. * Creates the PassCubePostProcess
  36739. * @param name The name of the effect.
  36740. * @param options The required width/height ratio to downsize to before computing the render pass.
  36741. * @param camera The camera to apply the render pass to.
  36742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36743. * @param engine The engine which the post process will be applied. (default: current engine)
  36744. * @param reusable If the post process can be reused on the same frame. (default: false)
  36745. * @param textureType The type of texture to be used when performing the post processing.
  36746. * @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)
  36747. */
  36748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36749. }
  36750. }
  36751. declare module BABYLON {
  36752. /** @hidden */
  36753. export var anaglyphPixelShader: {
  36754. name: string;
  36755. shader: string;
  36756. };
  36757. }
  36758. declare module BABYLON {
  36759. /**
  36760. * Postprocess used to generate anaglyphic rendering
  36761. */
  36762. export class AnaglyphPostProcess extends PostProcess {
  36763. private _passedProcess;
  36764. /**
  36765. * Creates a new AnaglyphPostProcess
  36766. * @param name defines postprocess name
  36767. * @param options defines creation options or target ratio scale
  36768. * @param rigCameras defines cameras using this postprocess
  36769. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36770. * @param engine defines hosting engine
  36771. * @param reusable defines if the postprocess will be reused multiple times per frame
  36772. */
  36773. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36774. }
  36775. }
  36776. declare module BABYLON {
  36777. /**
  36778. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36780. */
  36781. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36782. /**
  36783. * Creates a new AnaglyphArcRotateCamera
  36784. * @param name defines camera name
  36785. * @param alpha defines alpha angle (in radians)
  36786. * @param beta defines beta angle (in radians)
  36787. * @param radius defines radius
  36788. * @param target defines camera target
  36789. * @param interaxialDistance defines distance between each color axis
  36790. * @param scene defines the hosting scene
  36791. */
  36792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36793. /**
  36794. * Gets camera class name
  36795. * @returns AnaglyphArcRotateCamera
  36796. */
  36797. getClassName(): string;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36804. */
  36805. export class AnaglyphFreeCamera extends FreeCamera {
  36806. /**
  36807. * Creates a new AnaglyphFreeCamera
  36808. * @param name defines camera name
  36809. * @param position defines initial position
  36810. * @param interaxialDistance defines distance between each color axis
  36811. * @param scene defines the hosting scene
  36812. */
  36813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36814. /**
  36815. * Gets camera class name
  36816. * @returns AnaglyphFreeCamera
  36817. */
  36818. getClassName(): string;
  36819. }
  36820. }
  36821. declare module BABYLON {
  36822. /**
  36823. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36824. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36825. */
  36826. export class AnaglyphGamepadCamera extends GamepadCamera {
  36827. /**
  36828. * Creates a new AnaglyphGamepadCamera
  36829. * @param name defines camera name
  36830. * @param position defines initial position
  36831. * @param interaxialDistance defines distance between each color axis
  36832. * @param scene defines the hosting scene
  36833. */
  36834. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36835. /**
  36836. * Gets camera class name
  36837. * @returns AnaglyphGamepadCamera
  36838. */
  36839. getClassName(): string;
  36840. }
  36841. }
  36842. declare module BABYLON {
  36843. /**
  36844. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36845. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36846. */
  36847. export class AnaglyphUniversalCamera extends UniversalCamera {
  36848. /**
  36849. * Creates a new AnaglyphUniversalCamera
  36850. * @param name defines camera name
  36851. * @param position defines initial position
  36852. * @param interaxialDistance defines distance between each color axis
  36853. * @param scene defines the hosting scene
  36854. */
  36855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36856. /**
  36857. * Gets camera class name
  36858. * @returns AnaglyphUniversalCamera
  36859. */
  36860. getClassName(): string;
  36861. }
  36862. }
  36863. declare module BABYLON {
  36864. /** @hidden */
  36865. export var stereoscopicInterlacePixelShader: {
  36866. name: string;
  36867. shader: string;
  36868. };
  36869. }
  36870. declare module BABYLON {
  36871. /**
  36872. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36873. */
  36874. export class StereoscopicInterlacePostProcess extends PostProcess {
  36875. private _stepSize;
  36876. private _passedProcess;
  36877. /**
  36878. * Initializes a StereoscopicInterlacePostProcess
  36879. * @param name The name of the effect.
  36880. * @param rigCameras The rig cameras to be appled to the post process
  36881. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36883. * @param engine The engine which the post process will be applied. (default: current engine)
  36884. * @param reusable If the post process can be reused on the same frame. (default: false)
  36885. */
  36886. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36887. }
  36888. }
  36889. declare module BABYLON {
  36890. /**
  36891. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36892. * @see http://doc.babylonjs.com/features/cameras
  36893. */
  36894. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36895. /**
  36896. * Creates a new StereoscopicArcRotateCamera
  36897. * @param name defines camera name
  36898. * @param alpha defines alpha angle (in radians)
  36899. * @param beta defines beta angle (in radians)
  36900. * @param radius defines radius
  36901. * @param target defines camera target
  36902. * @param interaxialDistance defines distance between each color axis
  36903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36904. * @param scene defines the hosting scene
  36905. */
  36906. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36907. /**
  36908. * Gets camera class name
  36909. * @returns StereoscopicArcRotateCamera
  36910. */
  36911. getClassName(): string;
  36912. }
  36913. }
  36914. declare module BABYLON {
  36915. /**
  36916. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36917. * @see http://doc.babylonjs.com/features/cameras
  36918. */
  36919. export class StereoscopicFreeCamera extends FreeCamera {
  36920. /**
  36921. * Creates a new StereoscopicFreeCamera
  36922. * @param name defines camera name
  36923. * @param position defines initial position
  36924. * @param interaxialDistance defines distance between each color axis
  36925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36926. * @param scene defines the hosting scene
  36927. */
  36928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36929. /**
  36930. * Gets camera class name
  36931. * @returns StereoscopicFreeCamera
  36932. */
  36933. getClassName(): string;
  36934. }
  36935. }
  36936. declare module BABYLON {
  36937. /**
  36938. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36939. * @see http://doc.babylonjs.com/features/cameras
  36940. */
  36941. export class StereoscopicGamepadCamera extends GamepadCamera {
  36942. /**
  36943. * Creates a new StereoscopicGamepadCamera
  36944. * @param name defines camera name
  36945. * @param position defines initial position
  36946. * @param interaxialDistance defines distance between each color axis
  36947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36948. * @param scene defines the hosting scene
  36949. */
  36950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36951. /**
  36952. * Gets camera class name
  36953. * @returns StereoscopicGamepadCamera
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36961. * @see http://doc.babylonjs.com/features/cameras
  36962. */
  36963. export class StereoscopicUniversalCamera extends UniversalCamera {
  36964. /**
  36965. * Creates a new StereoscopicUniversalCamera
  36966. * @param name defines camera name
  36967. * @param position defines initial position
  36968. * @param interaxialDistance defines distance between each color axis
  36969. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36970. * @param scene defines the hosting scene
  36971. */
  36972. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36973. /**
  36974. * Gets camera class name
  36975. * @returns StereoscopicUniversalCamera
  36976. */
  36977. getClassName(): string;
  36978. }
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36985. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36986. */
  36987. export class VirtualJoysticksCamera extends FreeCamera {
  36988. /**
  36989. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36990. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36991. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36992. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36993. * @param name Define the name of the camera in the scene
  36994. * @param position Define the start position of the camera in the scene
  36995. * @param scene Define the scene the camera belongs to
  36996. */
  36997. constructor(name: string, position: Vector3, scene: Scene);
  36998. /**
  36999. * Gets the current object class name.
  37000. * @return the class name
  37001. */
  37002. getClassName(): string;
  37003. }
  37004. }
  37005. declare module BABYLON {
  37006. /**
  37007. * This represents all the required metrics to create a VR camera.
  37008. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37009. */
  37010. export class VRCameraMetrics {
  37011. /**
  37012. * Define the horizontal resolution off the screen.
  37013. */
  37014. hResolution: number;
  37015. /**
  37016. * Define the vertical resolution off the screen.
  37017. */
  37018. vResolution: number;
  37019. /**
  37020. * Define the horizontal screen size.
  37021. */
  37022. hScreenSize: number;
  37023. /**
  37024. * Define the vertical screen size.
  37025. */
  37026. vScreenSize: number;
  37027. /**
  37028. * Define the vertical screen center position.
  37029. */
  37030. vScreenCenter: number;
  37031. /**
  37032. * Define the distance of the eyes to the screen.
  37033. */
  37034. eyeToScreenDistance: number;
  37035. /**
  37036. * Define the distance between both lenses
  37037. */
  37038. lensSeparationDistance: number;
  37039. /**
  37040. * Define the distance between both viewer's eyes.
  37041. */
  37042. interpupillaryDistance: number;
  37043. /**
  37044. * Define the distortion factor of the VR postprocess.
  37045. * Please, touch with care.
  37046. */
  37047. distortionK: number[];
  37048. /**
  37049. * Define the chromatic aberration correction factors for the VR post process.
  37050. */
  37051. chromaAbCorrection: number[];
  37052. /**
  37053. * Define the scale factor of the post process.
  37054. * The smaller the better but the slower.
  37055. */
  37056. postProcessScaleFactor: number;
  37057. /**
  37058. * Define an offset for the lens center.
  37059. */
  37060. lensCenterOffset: number;
  37061. /**
  37062. * Define if the current vr camera should compensate the distortion of the lense or not.
  37063. */
  37064. compensateDistortion: boolean;
  37065. /**
  37066. * Defines if multiview should be enabled when rendering (Default: false)
  37067. */
  37068. multiviewEnabled: boolean;
  37069. /**
  37070. * Gets the rendering aspect ratio based on the provided resolutions.
  37071. */
  37072. readonly aspectRatio: number;
  37073. /**
  37074. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37075. */
  37076. readonly aspectRatioFov: number;
  37077. /**
  37078. * @hidden
  37079. */
  37080. readonly leftHMatrix: Matrix;
  37081. /**
  37082. * @hidden
  37083. */
  37084. readonly rightHMatrix: Matrix;
  37085. /**
  37086. * @hidden
  37087. */
  37088. readonly leftPreViewMatrix: Matrix;
  37089. /**
  37090. * @hidden
  37091. */
  37092. readonly rightPreViewMatrix: Matrix;
  37093. /**
  37094. * Get the default VRMetrics based on the most generic setup.
  37095. * @returns the default vr metrics
  37096. */
  37097. static GetDefault(): VRCameraMetrics;
  37098. }
  37099. }
  37100. declare module BABYLON {
  37101. /** @hidden */
  37102. export var vrDistortionCorrectionPixelShader: {
  37103. name: string;
  37104. shader: string;
  37105. };
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * VRDistortionCorrectionPostProcess used for mobile VR
  37110. */
  37111. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37112. private _isRightEye;
  37113. private _distortionFactors;
  37114. private _postProcessScaleFactor;
  37115. private _lensCenterOffset;
  37116. private _scaleIn;
  37117. private _scaleFactor;
  37118. private _lensCenter;
  37119. /**
  37120. * Initializes the VRDistortionCorrectionPostProcess
  37121. * @param name The name of the effect.
  37122. * @param camera The camera to apply the render pass to.
  37123. * @param isRightEye If this is for the right eye distortion
  37124. * @param vrMetrics All the required metrics for the VR camera
  37125. */
  37126. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37127. }
  37128. }
  37129. declare module BABYLON {
  37130. /**
  37131. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37132. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37133. */
  37134. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37135. /**
  37136. * Creates a new VRDeviceOrientationArcRotateCamera
  37137. * @param name defines camera name
  37138. * @param alpha defines the camera rotation along the logitudinal axis
  37139. * @param beta defines the camera rotation along the latitudinal axis
  37140. * @param radius defines the camera distance from its target
  37141. * @param target defines the camera target
  37142. * @param scene defines the scene the camera belongs to
  37143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37145. */
  37146. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37147. /**
  37148. * Gets camera class name
  37149. * @returns VRDeviceOrientationArcRotateCamera
  37150. */
  37151. getClassName(): string;
  37152. }
  37153. }
  37154. declare module BABYLON {
  37155. /**
  37156. * Camera used to simulate VR rendering (based on FreeCamera)
  37157. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37158. */
  37159. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37160. /**
  37161. * Creates a new VRDeviceOrientationFreeCamera
  37162. * @param name defines camera name
  37163. * @param position defines the start position of the camera
  37164. * @param scene defines the scene the camera belongs to
  37165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37167. */
  37168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37169. /**
  37170. * Gets camera class name
  37171. * @returns VRDeviceOrientationFreeCamera
  37172. */
  37173. getClassName(): string;
  37174. }
  37175. }
  37176. declare module BABYLON {
  37177. /**
  37178. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37180. */
  37181. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37182. /**
  37183. * Creates a new VRDeviceOrientationGamepadCamera
  37184. * @param name defines camera name
  37185. * @param position defines the start position of the camera
  37186. * @param scene defines the scene the camera belongs to
  37187. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37188. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37189. */
  37190. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37191. /**
  37192. * Gets camera class name
  37193. * @returns VRDeviceOrientationGamepadCamera
  37194. */
  37195. getClassName(): string;
  37196. }
  37197. }
  37198. declare module BABYLON {
  37199. /**
  37200. * Defines supported buttons for XBox360 compatible gamepads
  37201. */
  37202. export enum Xbox360Button {
  37203. /** A */
  37204. A = 0,
  37205. /** B */
  37206. B = 1,
  37207. /** X */
  37208. X = 2,
  37209. /** Y */
  37210. Y = 3,
  37211. /** Start */
  37212. Start = 4,
  37213. /** Back */
  37214. Back = 5,
  37215. /** Left button */
  37216. LB = 6,
  37217. /** Right button */
  37218. RB = 7,
  37219. /** Left stick */
  37220. LeftStick = 8,
  37221. /** Right stick */
  37222. RightStick = 9
  37223. }
  37224. /** Defines values for XBox360 DPad */
  37225. export enum Xbox360Dpad {
  37226. /** Up */
  37227. Up = 0,
  37228. /** Down */
  37229. Down = 1,
  37230. /** Left */
  37231. Left = 2,
  37232. /** Right */
  37233. Right = 3
  37234. }
  37235. /**
  37236. * Defines a XBox360 gamepad
  37237. */
  37238. export class Xbox360Pad extends Gamepad {
  37239. private _leftTrigger;
  37240. private _rightTrigger;
  37241. private _onlefttriggerchanged;
  37242. private _onrighttriggerchanged;
  37243. private _onbuttondown;
  37244. private _onbuttonup;
  37245. private _ondpaddown;
  37246. private _ondpadup;
  37247. /** Observable raised when a button is pressed */
  37248. onButtonDownObservable: Observable<Xbox360Button>;
  37249. /** Observable raised when a button is released */
  37250. onButtonUpObservable: Observable<Xbox360Button>;
  37251. /** Observable raised when a pad is pressed */
  37252. onPadDownObservable: Observable<Xbox360Dpad>;
  37253. /** Observable raised when a pad is released */
  37254. onPadUpObservable: Observable<Xbox360Dpad>;
  37255. private _buttonA;
  37256. private _buttonB;
  37257. private _buttonX;
  37258. private _buttonY;
  37259. private _buttonBack;
  37260. private _buttonStart;
  37261. private _buttonLB;
  37262. private _buttonRB;
  37263. private _buttonLeftStick;
  37264. private _buttonRightStick;
  37265. private _dPadUp;
  37266. private _dPadDown;
  37267. private _dPadLeft;
  37268. private _dPadRight;
  37269. private _isXboxOnePad;
  37270. /**
  37271. * Creates a new XBox360 gamepad object
  37272. * @param id defines the id of this gamepad
  37273. * @param index defines its index
  37274. * @param gamepad defines the internal HTML gamepad object
  37275. * @param xboxOne defines if it is a XBox One gamepad
  37276. */
  37277. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37278. /**
  37279. * Defines the callback to call when left trigger is pressed
  37280. * @param callback defines the callback to use
  37281. */
  37282. onlefttriggerchanged(callback: (value: number) => void): void;
  37283. /**
  37284. * Defines the callback to call when right trigger is pressed
  37285. * @param callback defines the callback to use
  37286. */
  37287. onrighttriggerchanged(callback: (value: number) => void): void;
  37288. /**
  37289. * Gets the left trigger value
  37290. */
  37291. /**
  37292. * Sets the left trigger value
  37293. */
  37294. leftTrigger: number;
  37295. /**
  37296. * Gets the right trigger value
  37297. */
  37298. /**
  37299. * Sets the right trigger value
  37300. */
  37301. rightTrigger: number;
  37302. /**
  37303. * Defines the callback to call when a button is pressed
  37304. * @param callback defines the callback to use
  37305. */
  37306. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37307. /**
  37308. * Defines the callback to call when a button is released
  37309. * @param callback defines the callback to use
  37310. */
  37311. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37312. /**
  37313. * Defines the callback to call when a pad is pressed
  37314. * @param callback defines the callback to use
  37315. */
  37316. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37317. /**
  37318. * Defines the callback to call when a pad is released
  37319. * @param callback defines the callback to use
  37320. */
  37321. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37322. private _setButtonValue;
  37323. private _setDPadValue;
  37324. /**
  37325. * Gets the value of the `A` button
  37326. */
  37327. /**
  37328. * Sets the value of the `A` button
  37329. */
  37330. buttonA: number;
  37331. /**
  37332. * Gets the value of the `B` button
  37333. */
  37334. /**
  37335. * Sets the value of the `B` button
  37336. */
  37337. buttonB: number;
  37338. /**
  37339. * Gets the value of the `X` button
  37340. */
  37341. /**
  37342. * Sets the value of the `X` button
  37343. */
  37344. buttonX: number;
  37345. /**
  37346. * Gets the value of the `Y` button
  37347. */
  37348. /**
  37349. * Sets the value of the `Y` button
  37350. */
  37351. buttonY: number;
  37352. /**
  37353. * Gets the value of the `Start` button
  37354. */
  37355. /**
  37356. * Sets the value of the `Start` button
  37357. */
  37358. buttonStart: number;
  37359. /**
  37360. * Gets the value of the `Back` button
  37361. */
  37362. /**
  37363. * Sets the value of the `Back` button
  37364. */
  37365. buttonBack: number;
  37366. /**
  37367. * Gets the value of the `Left` button
  37368. */
  37369. /**
  37370. * Sets the value of the `Left` button
  37371. */
  37372. buttonLB: number;
  37373. /**
  37374. * Gets the value of the `Right` button
  37375. */
  37376. /**
  37377. * Sets the value of the `Right` button
  37378. */
  37379. buttonRB: number;
  37380. /**
  37381. * Gets the value of the Left joystick
  37382. */
  37383. /**
  37384. * Sets the value of the Left joystick
  37385. */
  37386. buttonLeftStick: number;
  37387. /**
  37388. * Gets the value of the Right joystick
  37389. */
  37390. /**
  37391. * Sets the value of the Right joystick
  37392. */
  37393. buttonRightStick: number;
  37394. /**
  37395. * Gets the value of D-pad up
  37396. */
  37397. /**
  37398. * Sets the value of D-pad up
  37399. */
  37400. dPadUp: number;
  37401. /**
  37402. * Gets the value of D-pad down
  37403. */
  37404. /**
  37405. * Sets the value of D-pad down
  37406. */
  37407. dPadDown: number;
  37408. /**
  37409. * Gets the value of D-pad left
  37410. */
  37411. /**
  37412. * Sets the value of D-pad left
  37413. */
  37414. dPadLeft: number;
  37415. /**
  37416. * Gets the value of D-pad right
  37417. */
  37418. /**
  37419. * Sets the value of D-pad right
  37420. */
  37421. dPadRight: number;
  37422. /**
  37423. * Force the gamepad to synchronize with device values
  37424. */
  37425. update(): void;
  37426. /**
  37427. * Disposes the gamepad
  37428. */
  37429. dispose(): void;
  37430. }
  37431. }
  37432. declare module BABYLON {
  37433. /**
  37434. * Base class of materials working in push mode in babylon JS
  37435. * @hidden
  37436. */
  37437. export class PushMaterial extends Material {
  37438. protected _activeEffect: Effect;
  37439. protected _normalMatrix: Matrix;
  37440. /**
  37441. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37442. * This means that the material can keep using a previous shader while a new one is being compiled.
  37443. * This is mostly used when shader parallel compilation is supported (true by default)
  37444. */
  37445. allowShaderHotSwapping: boolean;
  37446. constructor(name: string, scene: Scene);
  37447. getEffect(): Effect;
  37448. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37449. /**
  37450. * Binds the given world matrix to the active effect
  37451. *
  37452. * @param world the matrix to bind
  37453. */
  37454. bindOnlyWorldMatrix(world: Matrix): void;
  37455. /**
  37456. * Binds the given normal matrix to the active effect
  37457. *
  37458. * @param normalMatrix the matrix to bind
  37459. */
  37460. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37461. bind(world: Matrix, mesh?: Mesh): void;
  37462. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37463. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37464. }
  37465. }
  37466. declare module BABYLON {
  37467. /**
  37468. * This groups all the flags used to control the materials channel.
  37469. */
  37470. export class MaterialFlags {
  37471. private static _DiffuseTextureEnabled;
  37472. /**
  37473. * Are diffuse textures enabled in the application.
  37474. */
  37475. static DiffuseTextureEnabled: boolean;
  37476. private static _AmbientTextureEnabled;
  37477. /**
  37478. * Are ambient textures enabled in the application.
  37479. */
  37480. static AmbientTextureEnabled: boolean;
  37481. private static _OpacityTextureEnabled;
  37482. /**
  37483. * Are opacity textures enabled in the application.
  37484. */
  37485. static OpacityTextureEnabled: boolean;
  37486. private static _ReflectionTextureEnabled;
  37487. /**
  37488. * Are reflection textures enabled in the application.
  37489. */
  37490. static ReflectionTextureEnabled: boolean;
  37491. private static _EmissiveTextureEnabled;
  37492. /**
  37493. * Are emissive textures enabled in the application.
  37494. */
  37495. static EmissiveTextureEnabled: boolean;
  37496. private static _SpecularTextureEnabled;
  37497. /**
  37498. * Are specular textures enabled in the application.
  37499. */
  37500. static SpecularTextureEnabled: boolean;
  37501. private static _BumpTextureEnabled;
  37502. /**
  37503. * Are bump textures enabled in the application.
  37504. */
  37505. static BumpTextureEnabled: boolean;
  37506. private static _LightmapTextureEnabled;
  37507. /**
  37508. * Are lightmap textures enabled in the application.
  37509. */
  37510. static LightmapTextureEnabled: boolean;
  37511. private static _RefractionTextureEnabled;
  37512. /**
  37513. * Are refraction textures enabled in the application.
  37514. */
  37515. static RefractionTextureEnabled: boolean;
  37516. private static _ColorGradingTextureEnabled;
  37517. /**
  37518. * Are color grading textures enabled in the application.
  37519. */
  37520. static ColorGradingTextureEnabled: boolean;
  37521. private static _FresnelEnabled;
  37522. /**
  37523. * Are fresnels enabled in the application.
  37524. */
  37525. static FresnelEnabled: boolean;
  37526. private static _ClearCoatTextureEnabled;
  37527. /**
  37528. * Are clear coat textures enabled in the application.
  37529. */
  37530. static ClearCoatTextureEnabled: boolean;
  37531. private static _ClearCoatBumpTextureEnabled;
  37532. /**
  37533. * Are clear coat bump textures enabled in the application.
  37534. */
  37535. static ClearCoatBumpTextureEnabled: boolean;
  37536. private static _ClearCoatTintTextureEnabled;
  37537. /**
  37538. * Are clear coat tint textures enabled in the application.
  37539. */
  37540. static ClearCoatTintTextureEnabled: boolean;
  37541. private static _SheenTextureEnabled;
  37542. /**
  37543. * Are sheen textures enabled in the application.
  37544. */
  37545. static SheenTextureEnabled: boolean;
  37546. private static _AnisotropicTextureEnabled;
  37547. /**
  37548. * Are anisotropic textures enabled in the application.
  37549. */
  37550. static AnisotropicTextureEnabled: boolean;
  37551. private static _ThicknessTextureEnabled;
  37552. /**
  37553. * Are thickness textures enabled in the application.
  37554. */
  37555. static ThicknessTextureEnabled: boolean;
  37556. }
  37557. }
  37558. declare module BABYLON {
  37559. /** @hidden */
  37560. export var defaultFragmentDeclaration: {
  37561. name: string;
  37562. shader: string;
  37563. };
  37564. }
  37565. declare module BABYLON {
  37566. /** @hidden */
  37567. export var defaultUboDeclaration: {
  37568. name: string;
  37569. shader: string;
  37570. };
  37571. }
  37572. declare module BABYLON {
  37573. /** @hidden */
  37574. export var lightFragmentDeclaration: {
  37575. name: string;
  37576. shader: string;
  37577. };
  37578. }
  37579. declare module BABYLON {
  37580. /** @hidden */
  37581. export var lightUboDeclaration: {
  37582. name: string;
  37583. shader: string;
  37584. };
  37585. }
  37586. declare module BABYLON {
  37587. /** @hidden */
  37588. export var lightsFragmentFunctions: {
  37589. name: string;
  37590. shader: string;
  37591. };
  37592. }
  37593. declare module BABYLON {
  37594. /** @hidden */
  37595. export var shadowsFragmentFunctions: {
  37596. name: string;
  37597. shader: string;
  37598. };
  37599. }
  37600. declare module BABYLON {
  37601. /** @hidden */
  37602. export var fresnelFunction: {
  37603. name: string;
  37604. shader: string;
  37605. };
  37606. }
  37607. declare module BABYLON {
  37608. /** @hidden */
  37609. export var reflectionFunction: {
  37610. name: string;
  37611. shader: string;
  37612. };
  37613. }
  37614. declare module BABYLON {
  37615. /** @hidden */
  37616. export var bumpFragmentFunctions: {
  37617. name: string;
  37618. shader: string;
  37619. };
  37620. }
  37621. declare module BABYLON {
  37622. /** @hidden */
  37623. export var logDepthDeclaration: {
  37624. name: string;
  37625. shader: string;
  37626. };
  37627. }
  37628. declare module BABYLON {
  37629. /** @hidden */
  37630. export var bumpFragment: {
  37631. name: string;
  37632. shader: string;
  37633. };
  37634. }
  37635. declare module BABYLON {
  37636. /** @hidden */
  37637. export var depthPrePass: {
  37638. name: string;
  37639. shader: string;
  37640. };
  37641. }
  37642. declare module BABYLON {
  37643. /** @hidden */
  37644. export var lightFragment: {
  37645. name: string;
  37646. shader: string;
  37647. };
  37648. }
  37649. declare module BABYLON {
  37650. /** @hidden */
  37651. export var logDepthFragment: {
  37652. name: string;
  37653. shader: string;
  37654. };
  37655. }
  37656. declare module BABYLON {
  37657. /** @hidden */
  37658. export var defaultPixelShader: {
  37659. name: string;
  37660. shader: string;
  37661. };
  37662. }
  37663. declare module BABYLON {
  37664. /** @hidden */
  37665. export var defaultVertexDeclaration: {
  37666. name: string;
  37667. shader: string;
  37668. };
  37669. }
  37670. declare module BABYLON {
  37671. /** @hidden */
  37672. export var bumpVertexDeclaration: {
  37673. name: string;
  37674. shader: string;
  37675. };
  37676. }
  37677. declare module BABYLON {
  37678. /** @hidden */
  37679. export var bumpVertex: {
  37680. name: string;
  37681. shader: string;
  37682. };
  37683. }
  37684. declare module BABYLON {
  37685. /** @hidden */
  37686. export var fogVertex: {
  37687. name: string;
  37688. shader: string;
  37689. };
  37690. }
  37691. declare module BABYLON {
  37692. /** @hidden */
  37693. export var shadowsVertex: {
  37694. name: string;
  37695. shader: string;
  37696. };
  37697. }
  37698. declare module BABYLON {
  37699. /** @hidden */
  37700. export var pointCloudVertex: {
  37701. name: string;
  37702. shader: string;
  37703. };
  37704. }
  37705. declare module BABYLON {
  37706. /** @hidden */
  37707. export var logDepthVertex: {
  37708. name: string;
  37709. shader: string;
  37710. };
  37711. }
  37712. declare module BABYLON {
  37713. /** @hidden */
  37714. export var defaultVertexShader: {
  37715. name: string;
  37716. shader: string;
  37717. };
  37718. }
  37719. declare module BABYLON {
  37720. /** @hidden */
  37721. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37722. MAINUV1: boolean;
  37723. MAINUV2: boolean;
  37724. DIFFUSE: boolean;
  37725. DIFFUSEDIRECTUV: number;
  37726. AMBIENT: boolean;
  37727. AMBIENTDIRECTUV: number;
  37728. OPACITY: boolean;
  37729. OPACITYDIRECTUV: number;
  37730. OPACITYRGB: boolean;
  37731. REFLECTION: boolean;
  37732. EMISSIVE: boolean;
  37733. EMISSIVEDIRECTUV: number;
  37734. SPECULAR: boolean;
  37735. SPECULARDIRECTUV: number;
  37736. BUMP: boolean;
  37737. BUMPDIRECTUV: number;
  37738. PARALLAX: boolean;
  37739. PARALLAXOCCLUSION: boolean;
  37740. SPECULAROVERALPHA: boolean;
  37741. CLIPPLANE: boolean;
  37742. CLIPPLANE2: boolean;
  37743. CLIPPLANE3: boolean;
  37744. CLIPPLANE4: boolean;
  37745. ALPHATEST: boolean;
  37746. DEPTHPREPASS: boolean;
  37747. ALPHAFROMDIFFUSE: boolean;
  37748. POINTSIZE: boolean;
  37749. FOG: boolean;
  37750. SPECULARTERM: boolean;
  37751. DIFFUSEFRESNEL: boolean;
  37752. OPACITYFRESNEL: boolean;
  37753. REFLECTIONFRESNEL: boolean;
  37754. REFRACTIONFRESNEL: boolean;
  37755. EMISSIVEFRESNEL: boolean;
  37756. FRESNEL: boolean;
  37757. NORMAL: boolean;
  37758. UV1: boolean;
  37759. UV2: boolean;
  37760. VERTEXCOLOR: boolean;
  37761. VERTEXALPHA: boolean;
  37762. NUM_BONE_INFLUENCERS: number;
  37763. BonesPerMesh: number;
  37764. BONETEXTURE: boolean;
  37765. INSTANCES: boolean;
  37766. GLOSSINESS: boolean;
  37767. ROUGHNESS: boolean;
  37768. EMISSIVEASILLUMINATION: boolean;
  37769. LINKEMISSIVEWITHDIFFUSE: boolean;
  37770. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37771. LIGHTMAP: boolean;
  37772. LIGHTMAPDIRECTUV: number;
  37773. OBJECTSPACE_NORMALMAP: boolean;
  37774. USELIGHTMAPASSHADOWMAP: boolean;
  37775. REFLECTIONMAP_3D: boolean;
  37776. REFLECTIONMAP_SPHERICAL: boolean;
  37777. REFLECTIONMAP_PLANAR: boolean;
  37778. REFLECTIONMAP_CUBIC: boolean;
  37779. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37780. REFLECTIONMAP_PROJECTION: boolean;
  37781. REFLECTIONMAP_SKYBOX: boolean;
  37782. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37783. REFLECTIONMAP_EXPLICIT: boolean;
  37784. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37785. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37786. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37787. INVERTCUBICMAP: boolean;
  37788. LOGARITHMICDEPTH: boolean;
  37789. REFRACTION: boolean;
  37790. REFRACTIONMAP_3D: boolean;
  37791. REFLECTIONOVERALPHA: boolean;
  37792. TWOSIDEDLIGHTING: boolean;
  37793. SHADOWFLOAT: boolean;
  37794. MORPHTARGETS: boolean;
  37795. MORPHTARGETS_NORMAL: boolean;
  37796. MORPHTARGETS_TANGENT: boolean;
  37797. NUM_MORPH_INFLUENCERS: number;
  37798. NONUNIFORMSCALING: boolean;
  37799. PREMULTIPLYALPHA: boolean;
  37800. IMAGEPROCESSING: boolean;
  37801. VIGNETTE: boolean;
  37802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37803. VIGNETTEBLENDMODEOPAQUE: boolean;
  37804. TONEMAPPING: boolean;
  37805. TONEMAPPING_ACES: boolean;
  37806. CONTRAST: boolean;
  37807. COLORCURVES: boolean;
  37808. COLORGRADING: boolean;
  37809. COLORGRADING3D: boolean;
  37810. SAMPLER3DGREENDEPTH: boolean;
  37811. SAMPLER3DBGRMAP: boolean;
  37812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37813. MULTIVIEW: boolean;
  37814. /**
  37815. * If the reflection texture on this material is in linear color space
  37816. * @hidden
  37817. */
  37818. IS_REFLECTION_LINEAR: boolean;
  37819. /**
  37820. * If the refraction texture on this material is in linear color space
  37821. * @hidden
  37822. */
  37823. IS_REFRACTION_LINEAR: boolean;
  37824. EXPOSURE: boolean;
  37825. constructor();
  37826. setReflectionMode(modeToEnable: string): void;
  37827. }
  37828. /**
  37829. * This is the default material used in Babylon. It is the best trade off between quality
  37830. * and performances.
  37831. * @see http://doc.babylonjs.com/babylon101/materials
  37832. */
  37833. export class StandardMaterial extends PushMaterial {
  37834. private _diffuseTexture;
  37835. /**
  37836. * The basic texture of the material as viewed under a light.
  37837. */
  37838. diffuseTexture: Nullable<BaseTexture>;
  37839. private _ambientTexture;
  37840. /**
  37841. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37842. */
  37843. ambientTexture: Nullable<BaseTexture>;
  37844. private _opacityTexture;
  37845. /**
  37846. * Define the transparency of the material from a texture.
  37847. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37848. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37849. */
  37850. opacityTexture: Nullable<BaseTexture>;
  37851. private _reflectionTexture;
  37852. /**
  37853. * Define the texture used to display the reflection.
  37854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37855. */
  37856. reflectionTexture: Nullable<BaseTexture>;
  37857. private _emissiveTexture;
  37858. /**
  37859. * Define texture of the material as if self lit.
  37860. * This will be mixed in the final result even in the absence of light.
  37861. */
  37862. emissiveTexture: Nullable<BaseTexture>;
  37863. private _specularTexture;
  37864. /**
  37865. * Define how the color and intensity of the highlight given by the light in the material.
  37866. */
  37867. specularTexture: Nullable<BaseTexture>;
  37868. private _bumpTexture;
  37869. /**
  37870. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37871. * 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.
  37872. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37873. */
  37874. bumpTexture: Nullable<BaseTexture>;
  37875. private _lightmapTexture;
  37876. /**
  37877. * Complex lighting can be computationally expensive to compute at runtime.
  37878. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37879. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37880. */
  37881. lightmapTexture: Nullable<BaseTexture>;
  37882. private _refractionTexture;
  37883. /**
  37884. * Define the texture used to display the refraction.
  37885. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37886. */
  37887. refractionTexture: Nullable<BaseTexture>;
  37888. /**
  37889. * The color of the material lit by the environmental background lighting.
  37890. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37891. */
  37892. ambientColor: Color3;
  37893. /**
  37894. * The basic color of the material as viewed under a light.
  37895. */
  37896. diffuseColor: Color3;
  37897. /**
  37898. * Define how the color and intensity of the highlight given by the light in the material.
  37899. */
  37900. specularColor: Color3;
  37901. /**
  37902. * Define the color of the material as if self lit.
  37903. * This will be mixed in the final result even in the absence of light.
  37904. */
  37905. emissiveColor: Color3;
  37906. /**
  37907. * Defines how sharp are the highlights in the material.
  37908. * The bigger the value the sharper giving a more glossy feeling to the result.
  37909. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37910. */
  37911. specularPower: number;
  37912. private _useAlphaFromDiffuseTexture;
  37913. /**
  37914. * Does the transparency come from the diffuse texture alpha channel.
  37915. */
  37916. useAlphaFromDiffuseTexture: boolean;
  37917. private _useEmissiveAsIllumination;
  37918. /**
  37919. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37920. */
  37921. useEmissiveAsIllumination: boolean;
  37922. private _linkEmissiveWithDiffuse;
  37923. /**
  37924. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37925. * the emissive level when the final color is close to one.
  37926. */
  37927. linkEmissiveWithDiffuse: boolean;
  37928. private _useSpecularOverAlpha;
  37929. /**
  37930. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37931. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37932. */
  37933. useSpecularOverAlpha: boolean;
  37934. private _useReflectionOverAlpha;
  37935. /**
  37936. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37937. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37938. */
  37939. useReflectionOverAlpha: boolean;
  37940. private _disableLighting;
  37941. /**
  37942. * Does lights from the scene impacts this material.
  37943. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37944. */
  37945. disableLighting: boolean;
  37946. private _useObjectSpaceNormalMap;
  37947. /**
  37948. * Allows using an object space normal map (instead of tangent space).
  37949. */
  37950. useObjectSpaceNormalMap: boolean;
  37951. private _useParallax;
  37952. /**
  37953. * Is parallax enabled or not.
  37954. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37955. */
  37956. useParallax: boolean;
  37957. private _useParallaxOcclusion;
  37958. /**
  37959. * Is parallax occlusion enabled or not.
  37960. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37961. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37962. */
  37963. useParallaxOcclusion: boolean;
  37964. /**
  37965. * 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.
  37966. */
  37967. parallaxScaleBias: number;
  37968. private _roughness;
  37969. /**
  37970. * Helps to define how blurry the reflections should appears in the material.
  37971. */
  37972. roughness: number;
  37973. /**
  37974. * In case of refraction, define the value of the indice of refraction.
  37975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37976. */
  37977. indexOfRefraction: number;
  37978. /**
  37979. * Invert the refraction texture alongside the y axis.
  37980. * It can be useful with procedural textures or probe for instance.
  37981. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37982. */
  37983. invertRefractionY: boolean;
  37984. /**
  37985. * Defines the alpha limits in alpha test mode.
  37986. */
  37987. alphaCutOff: number;
  37988. private _useLightmapAsShadowmap;
  37989. /**
  37990. * In case of light mapping, define whether the map contains light or shadow informations.
  37991. */
  37992. useLightmapAsShadowmap: boolean;
  37993. private _diffuseFresnelParameters;
  37994. /**
  37995. * Define the diffuse fresnel parameters of the material.
  37996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37997. */
  37998. diffuseFresnelParameters: FresnelParameters;
  37999. private _opacityFresnelParameters;
  38000. /**
  38001. * Define the opacity fresnel parameters of the material.
  38002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38003. */
  38004. opacityFresnelParameters: FresnelParameters;
  38005. private _reflectionFresnelParameters;
  38006. /**
  38007. * Define the reflection fresnel parameters of the material.
  38008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38009. */
  38010. reflectionFresnelParameters: FresnelParameters;
  38011. private _refractionFresnelParameters;
  38012. /**
  38013. * Define the refraction fresnel parameters of the material.
  38014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38015. */
  38016. refractionFresnelParameters: FresnelParameters;
  38017. private _emissiveFresnelParameters;
  38018. /**
  38019. * Define the emissive fresnel parameters of the material.
  38020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38021. */
  38022. emissiveFresnelParameters: FresnelParameters;
  38023. private _useReflectionFresnelFromSpecular;
  38024. /**
  38025. * If true automatically deducts the fresnels values from the material specularity.
  38026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38027. */
  38028. useReflectionFresnelFromSpecular: boolean;
  38029. private _useGlossinessFromSpecularMapAlpha;
  38030. /**
  38031. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38032. */
  38033. useGlossinessFromSpecularMapAlpha: boolean;
  38034. private _maxSimultaneousLights;
  38035. /**
  38036. * Defines the maximum number of lights that can be used in the material
  38037. */
  38038. maxSimultaneousLights: number;
  38039. private _invertNormalMapX;
  38040. /**
  38041. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38042. */
  38043. invertNormalMapX: boolean;
  38044. private _invertNormalMapY;
  38045. /**
  38046. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38047. */
  38048. invertNormalMapY: boolean;
  38049. private _twoSidedLighting;
  38050. /**
  38051. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38052. */
  38053. twoSidedLighting: boolean;
  38054. /**
  38055. * Default configuration related to image processing available in the standard Material.
  38056. */
  38057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38058. /**
  38059. * Gets the image processing configuration used either in this material.
  38060. */
  38061. /**
  38062. * Sets the Default image processing configuration used either in the this material.
  38063. *
  38064. * If sets to null, the scene one is in use.
  38065. */
  38066. imageProcessingConfiguration: ImageProcessingConfiguration;
  38067. /**
  38068. * Keep track of the image processing observer to allow dispose and replace.
  38069. */
  38070. private _imageProcessingObserver;
  38071. /**
  38072. * Attaches a new image processing configuration to the Standard Material.
  38073. * @param configuration
  38074. */
  38075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38076. /**
  38077. * Gets wether the color curves effect is enabled.
  38078. */
  38079. /**
  38080. * Sets wether the color curves effect is enabled.
  38081. */
  38082. cameraColorCurvesEnabled: boolean;
  38083. /**
  38084. * Gets wether the color grading effect is enabled.
  38085. */
  38086. /**
  38087. * Gets wether the color grading effect is enabled.
  38088. */
  38089. cameraColorGradingEnabled: boolean;
  38090. /**
  38091. * Gets wether tonemapping is enabled or not.
  38092. */
  38093. /**
  38094. * Sets wether tonemapping is enabled or not
  38095. */
  38096. cameraToneMappingEnabled: boolean;
  38097. /**
  38098. * The camera exposure used on this material.
  38099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38100. * This corresponds to a photographic exposure.
  38101. */
  38102. /**
  38103. * The camera exposure used on this material.
  38104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38105. * This corresponds to a photographic exposure.
  38106. */
  38107. cameraExposure: number;
  38108. /**
  38109. * Gets The camera contrast used on this material.
  38110. */
  38111. /**
  38112. * Sets The camera contrast used on this material.
  38113. */
  38114. cameraContrast: number;
  38115. /**
  38116. * Gets the Color Grading 2D Lookup Texture.
  38117. */
  38118. /**
  38119. * Sets the Color Grading 2D Lookup Texture.
  38120. */
  38121. cameraColorGradingTexture: Nullable<BaseTexture>;
  38122. /**
  38123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38125. * 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;
  38126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38127. */
  38128. /**
  38129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38131. * 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;
  38132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38133. */
  38134. cameraColorCurves: Nullable<ColorCurves>;
  38135. /**
  38136. * Custom callback helping to override the default shader used in the material.
  38137. */
  38138. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38139. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38140. protected _worldViewProjectionMatrix: Matrix;
  38141. protected _globalAmbientColor: Color3;
  38142. protected _useLogarithmicDepth: boolean;
  38143. /**
  38144. * Instantiates a new standard material.
  38145. * This is the default material used in Babylon. It is the best trade off between quality
  38146. * and performances.
  38147. * @see http://doc.babylonjs.com/babylon101/materials
  38148. * @param name Define the name of the material in the scene
  38149. * @param scene Define the scene the material belong to
  38150. */
  38151. constructor(name: string, scene: Scene);
  38152. /**
  38153. * Gets a boolean indicating that current material needs to register RTT
  38154. */
  38155. readonly hasRenderTargetTextures: boolean;
  38156. /**
  38157. * Gets the current class name of the material e.g. "StandardMaterial"
  38158. * Mainly use in serialization.
  38159. * @returns the class name
  38160. */
  38161. getClassName(): string;
  38162. /**
  38163. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38164. * You can try switching to logarithmic depth.
  38165. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38166. */
  38167. useLogarithmicDepth: boolean;
  38168. /**
  38169. * Specifies if the material will require alpha blending
  38170. * @returns a boolean specifying if alpha blending is needed
  38171. */
  38172. needAlphaBlending(): boolean;
  38173. /**
  38174. * Specifies if this material should be rendered in alpha test mode
  38175. * @returns a boolean specifying if an alpha test is needed.
  38176. */
  38177. needAlphaTesting(): boolean;
  38178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38179. /**
  38180. * Get the texture used for alpha test purpose.
  38181. * @returns the diffuse texture in case of the standard material.
  38182. */
  38183. getAlphaTestTexture(): Nullable<BaseTexture>;
  38184. /**
  38185. * Get if the submesh is ready to be used and all its information available.
  38186. * Child classes can use it to update shaders
  38187. * @param mesh defines the mesh to check
  38188. * @param subMesh defines which submesh to check
  38189. * @param useInstances specifies that instances should be used
  38190. * @returns a boolean indicating that the submesh is ready or not
  38191. */
  38192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38193. /**
  38194. * Builds the material UBO layouts.
  38195. * Used internally during the effect preparation.
  38196. */
  38197. buildUniformLayout(): void;
  38198. /**
  38199. * Unbinds the material from the mesh
  38200. */
  38201. unbind(): void;
  38202. /**
  38203. * Binds the submesh to this material by preparing the effect and shader to draw
  38204. * @param world defines the world transformation matrix
  38205. * @param mesh defines the mesh containing the submesh
  38206. * @param subMesh defines the submesh to bind the material to
  38207. */
  38208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38209. /**
  38210. * Get the list of animatables in the material.
  38211. * @returns the list of animatables object used in the material
  38212. */
  38213. getAnimatables(): IAnimatable[];
  38214. /**
  38215. * Gets the active textures from the material
  38216. * @returns an array of textures
  38217. */
  38218. getActiveTextures(): BaseTexture[];
  38219. /**
  38220. * Specifies if the material uses a texture
  38221. * @param texture defines the texture to check against the material
  38222. * @returns a boolean specifying if the material uses the texture
  38223. */
  38224. hasTexture(texture: BaseTexture): boolean;
  38225. /**
  38226. * Disposes the material
  38227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38229. */
  38230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38231. /**
  38232. * Makes a duplicate of the material, and gives it a new name
  38233. * @param name defines the new name for the duplicated material
  38234. * @returns the cloned material
  38235. */
  38236. clone(name: string): StandardMaterial;
  38237. /**
  38238. * Serializes this material in a JSON representation
  38239. * @returns the serialized material object
  38240. */
  38241. serialize(): any;
  38242. /**
  38243. * Creates a standard material from parsed material data
  38244. * @param source defines the JSON representation of the material
  38245. * @param scene defines the hosting scene
  38246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38247. * @returns a new standard material
  38248. */
  38249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38250. /**
  38251. * Are diffuse textures enabled in the application.
  38252. */
  38253. static DiffuseTextureEnabled: boolean;
  38254. /**
  38255. * Are ambient textures enabled in the application.
  38256. */
  38257. static AmbientTextureEnabled: boolean;
  38258. /**
  38259. * Are opacity textures enabled in the application.
  38260. */
  38261. static OpacityTextureEnabled: boolean;
  38262. /**
  38263. * Are reflection textures enabled in the application.
  38264. */
  38265. static ReflectionTextureEnabled: boolean;
  38266. /**
  38267. * Are emissive textures enabled in the application.
  38268. */
  38269. static EmissiveTextureEnabled: boolean;
  38270. /**
  38271. * Are specular textures enabled in the application.
  38272. */
  38273. static SpecularTextureEnabled: boolean;
  38274. /**
  38275. * Are bump textures enabled in the application.
  38276. */
  38277. static BumpTextureEnabled: boolean;
  38278. /**
  38279. * Are lightmap textures enabled in the application.
  38280. */
  38281. static LightmapTextureEnabled: boolean;
  38282. /**
  38283. * Are refraction textures enabled in the application.
  38284. */
  38285. static RefractionTextureEnabled: boolean;
  38286. /**
  38287. * Are color grading textures enabled in the application.
  38288. */
  38289. static ColorGradingTextureEnabled: boolean;
  38290. /**
  38291. * Are fresnels enabled in the application.
  38292. */
  38293. static FresnelEnabled: boolean;
  38294. }
  38295. }
  38296. declare module BABYLON {
  38297. /**
  38298. * A class extending Texture allowing drawing on a texture
  38299. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38300. */
  38301. export class DynamicTexture extends Texture {
  38302. private _generateMipMaps;
  38303. private _canvas;
  38304. private _context;
  38305. private _engine;
  38306. /**
  38307. * Creates a DynamicTexture
  38308. * @param name defines the name of the texture
  38309. * @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
  38310. * @param scene defines the scene where you want the texture
  38311. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38312. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38313. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38314. */
  38315. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38316. /**
  38317. * Get the current class name of the texture useful for serialization or dynamic coding.
  38318. * @returns "DynamicTexture"
  38319. */
  38320. getClassName(): string;
  38321. /**
  38322. * Gets the current state of canRescale
  38323. */
  38324. readonly canRescale: boolean;
  38325. private _recreate;
  38326. /**
  38327. * Scales the texture
  38328. * @param ratio the scale factor to apply to both width and height
  38329. */
  38330. scale(ratio: number): void;
  38331. /**
  38332. * Resizes the texture
  38333. * @param width the new width
  38334. * @param height the new height
  38335. */
  38336. scaleTo(width: number, height: number): void;
  38337. /**
  38338. * Gets the context of the canvas used by the texture
  38339. * @returns the canvas context of the dynamic texture
  38340. */
  38341. getContext(): CanvasRenderingContext2D;
  38342. /**
  38343. * Clears the texture
  38344. */
  38345. clear(): void;
  38346. /**
  38347. * Updates the texture
  38348. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38349. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38350. */
  38351. update(invertY?: boolean, premulAlpha?: boolean): void;
  38352. /**
  38353. * Draws text onto the texture
  38354. * @param text defines the text to be drawn
  38355. * @param x defines the placement of the text from the left
  38356. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38357. * @param font defines the font to be used with font-style, font-size, font-name
  38358. * @param color defines the color used for the text
  38359. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38360. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38361. * @param update defines whether texture is immediately update (default is true)
  38362. */
  38363. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38364. /**
  38365. * Clones the texture
  38366. * @returns the clone of the texture.
  38367. */
  38368. clone(): DynamicTexture;
  38369. /**
  38370. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38371. * @returns a serialized dynamic texture object
  38372. */
  38373. serialize(): any;
  38374. /** @hidden */ rebuild(): void;
  38375. }
  38376. }
  38377. declare module BABYLON {
  38378. /** @hidden */
  38379. export var imageProcessingPixelShader: {
  38380. name: string;
  38381. shader: string;
  38382. };
  38383. }
  38384. declare module BABYLON {
  38385. /**
  38386. * ImageProcessingPostProcess
  38387. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38388. */
  38389. export class ImageProcessingPostProcess extends PostProcess {
  38390. /**
  38391. * Default configuration related to image processing available in the PBR Material.
  38392. */
  38393. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38394. /**
  38395. * Gets the image processing configuration used either in this material.
  38396. */
  38397. /**
  38398. * Sets the Default image processing configuration used either in the this material.
  38399. *
  38400. * If sets to null, the scene one is in use.
  38401. */
  38402. imageProcessingConfiguration: ImageProcessingConfiguration;
  38403. /**
  38404. * Keep track of the image processing observer to allow dispose and replace.
  38405. */
  38406. private _imageProcessingObserver;
  38407. /**
  38408. * Attaches a new image processing configuration to the PBR Material.
  38409. * @param configuration
  38410. */
  38411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38412. /**
  38413. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38414. */
  38415. /**
  38416. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38417. */
  38418. colorCurves: Nullable<ColorCurves>;
  38419. /**
  38420. * Gets wether the color curves effect is enabled.
  38421. */
  38422. /**
  38423. * Sets wether the color curves effect is enabled.
  38424. */
  38425. colorCurvesEnabled: boolean;
  38426. /**
  38427. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38428. */
  38429. /**
  38430. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38431. */
  38432. colorGradingTexture: Nullable<BaseTexture>;
  38433. /**
  38434. * Gets wether the color grading effect is enabled.
  38435. */
  38436. /**
  38437. * Gets wether the color grading effect is enabled.
  38438. */
  38439. colorGradingEnabled: boolean;
  38440. /**
  38441. * Gets exposure used in the effect.
  38442. */
  38443. /**
  38444. * Sets exposure used in the effect.
  38445. */
  38446. exposure: number;
  38447. /**
  38448. * Gets wether tonemapping is enabled or not.
  38449. */
  38450. /**
  38451. * Sets wether tonemapping is enabled or not
  38452. */
  38453. toneMappingEnabled: boolean;
  38454. /**
  38455. * Gets the type of tone mapping effect.
  38456. */
  38457. /**
  38458. * Sets the type of tone mapping effect.
  38459. */
  38460. toneMappingType: number;
  38461. /**
  38462. * Gets contrast used in the effect.
  38463. */
  38464. /**
  38465. * Sets contrast used in the effect.
  38466. */
  38467. contrast: number;
  38468. /**
  38469. * Gets Vignette stretch size.
  38470. */
  38471. /**
  38472. * Sets Vignette stretch size.
  38473. */
  38474. vignetteStretch: number;
  38475. /**
  38476. * Gets Vignette centre X Offset.
  38477. */
  38478. /**
  38479. * Sets Vignette centre X Offset.
  38480. */
  38481. vignetteCentreX: number;
  38482. /**
  38483. * Gets Vignette centre Y Offset.
  38484. */
  38485. /**
  38486. * Sets Vignette centre Y Offset.
  38487. */
  38488. vignetteCentreY: number;
  38489. /**
  38490. * Gets Vignette weight or intensity of the vignette effect.
  38491. */
  38492. /**
  38493. * Sets Vignette weight or intensity of the vignette effect.
  38494. */
  38495. vignetteWeight: number;
  38496. /**
  38497. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38498. * if vignetteEnabled is set to true.
  38499. */
  38500. /**
  38501. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38502. * if vignetteEnabled is set to true.
  38503. */
  38504. vignetteColor: Color4;
  38505. /**
  38506. * Gets Camera field of view used by the Vignette effect.
  38507. */
  38508. /**
  38509. * Sets Camera field of view used by the Vignette effect.
  38510. */
  38511. vignetteCameraFov: number;
  38512. /**
  38513. * Gets the vignette blend mode allowing different kind of effect.
  38514. */
  38515. /**
  38516. * Sets the vignette blend mode allowing different kind of effect.
  38517. */
  38518. vignetteBlendMode: number;
  38519. /**
  38520. * Gets wether the vignette effect is enabled.
  38521. */
  38522. /**
  38523. * Sets wether the vignette effect is enabled.
  38524. */
  38525. vignetteEnabled: boolean;
  38526. private _fromLinearSpace;
  38527. /**
  38528. * Gets wether the input of the processing is in Gamma or Linear Space.
  38529. */
  38530. /**
  38531. * Sets wether the input of the processing is in Gamma or Linear Space.
  38532. */
  38533. fromLinearSpace: boolean;
  38534. /**
  38535. * Defines cache preventing GC.
  38536. */
  38537. private _defines;
  38538. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38539. /**
  38540. * "ImageProcessingPostProcess"
  38541. * @returns "ImageProcessingPostProcess"
  38542. */
  38543. getClassName(): string;
  38544. protected _updateParameters(): void;
  38545. dispose(camera?: Camera): void;
  38546. }
  38547. }
  38548. declare module BABYLON {
  38549. /**
  38550. * Class containing static functions to help procedurally build meshes
  38551. */
  38552. export class GroundBuilder {
  38553. /**
  38554. * Creates a ground mesh
  38555. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38556. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38558. * @param name defines the name of the mesh
  38559. * @param options defines the options used to create the mesh
  38560. * @param scene defines the hosting scene
  38561. * @returns the ground mesh
  38562. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38563. */
  38564. static CreateGround(name: string, options: {
  38565. width?: number;
  38566. height?: number;
  38567. subdivisions?: number;
  38568. subdivisionsX?: number;
  38569. subdivisionsY?: number;
  38570. updatable?: boolean;
  38571. }, scene: any): Mesh;
  38572. /**
  38573. * Creates a tiled ground mesh
  38574. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38575. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38576. * * 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
  38577. * * 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
  38578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38579. * @param name defines the name of the mesh
  38580. * @param options defines the options used to create the mesh
  38581. * @param scene defines the hosting scene
  38582. * @returns the tiled ground mesh
  38583. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38584. */
  38585. static CreateTiledGround(name: string, options: {
  38586. xmin: number;
  38587. zmin: number;
  38588. xmax: number;
  38589. zmax: number;
  38590. subdivisions?: {
  38591. w: number;
  38592. h: number;
  38593. };
  38594. precision?: {
  38595. w: number;
  38596. h: number;
  38597. };
  38598. updatable?: boolean;
  38599. }, scene?: Nullable<Scene>): Mesh;
  38600. /**
  38601. * Creates a ground mesh from a height map
  38602. * * The parameter `url` sets the URL of the height map image resource.
  38603. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38604. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38605. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38606. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38607. * * 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.
  38608. * * 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).
  38609. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38611. * @param name defines the name of the mesh
  38612. * @param url defines the url to the height map
  38613. * @param options defines the options used to create the mesh
  38614. * @param scene defines the hosting scene
  38615. * @returns the ground mesh
  38616. * @see https://doc.babylonjs.com/babylon101/height_map
  38617. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38618. */
  38619. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38620. width?: number;
  38621. height?: number;
  38622. subdivisions?: number;
  38623. minHeight?: number;
  38624. maxHeight?: number;
  38625. colorFilter?: Color3;
  38626. alphaFilter?: number;
  38627. updatable?: boolean;
  38628. onReady?: (mesh: GroundMesh) => void;
  38629. }, scene?: Nullable<Scene>): GroundMesh;
  38630. }
  38631. }
  38632. declare module BABYLON {
  38633. /**
  38634. * Class containing static functions to help procedurally build meshes
  38635. */
  38636. export class TorusBuilder {
  38637. /**
  38638. * Creates a torus mesh
  38639. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38640. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38641. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38643. * * 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
  38644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38645. * @param name defines the name of the mesh
  38646. * @param options defines the options used to create the mesh
  38647. * @param scene defines the hosting scene
  38648. * @returns the torus mesh
  38649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38650. */
  38651. static CreateTorus(name: string, options: {
  38652. diameter?: number;
  38653. thickness?: number;
  38654. tessellation?: number;
  38655. updatable?: boolean;
  38656. sideOrientation?: number;
  38657. frontUVs?: Vector4;
  38658. backUVs?: Vector4;
  38659. }, scene: any): Mesh;
  38660. }
  38661. }
  38662. declare module BABYLON {
  38663. /**
  38664. * Class containing static functions to help procedurally build meshes
  38665. */
  38666. export class CylinderBuilder {
  38667. /**
  38668. * Creates a cylinder or a cone mesh
  38669. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38670. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38671. * * 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.
  38672. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38673. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38674. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38675. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38676. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38677. * * 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).
  38678. * * 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
  38679. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38680. * * 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
  38681. * * 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.
  38682. * * If `enclose` is false, a ring surface is one element.
  38683. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38684. * * 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
  38685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38686. * * 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
  38687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38688. * @param name defines the name of the mesh
  38689. * @param options defines the options used to create the mesh
  38690. * @param scene defines the hosting scene
  38691. * @returns the cylinder mesh
  38692. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38693. */
  38694. static CreateCylinder(name: string, options: {
  38695. height?: number;
  38696. diameterTop?: number;
  38697. diameterBottom?: number;
  38698. diameter?: number;
  38699. tessellation?: number;
  38700. subdivisions?: number;
  38701. arc?: number;
  38702. faceColors?: Color4[];
  38703. faceUV?: Vector4[];
  38704. updatable?: boolean;
  38705. hasRings?: boolean;
  38706. enclose?: boolean;
  38707. sideOrientation?: number;
  38708. frontUVs?: Vector4;
  38709. backUVs?: Vector4;
  38710. }, scene: any): Mesh;
  38711. }
  38712. }
  38713. declare module BABYLON {
  38714. /**
  38715. * Manager for handling gamepads
  38716. */
  38717. export class GamepadManager {
  38718. private _scene?;
  38719. private _babylonGamepads;
  38720. private _oneGamepadConnected;
  38721. /** @hidden */ isMonitoring: boolean;
  38722. private _gamepadEventSupported;
  38723. private _gamepadSupport;
  38724. /**
  38725. * observable to be triggered when the gamepad controller has been connected
  38726. */
  38727. onGamepadConnectedObservable: Observable<Gamepad>;
  38728. /**
  38729. * observable to be triggered when the gamepad controller has been disconnected
  38730. */
  38731. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38732. private _onGamepadConnectedEvent;
  38733. private _onGamepadDisconnectedEvent;
  38734. /**
  38735. * Initializes the gamepad manager
  38736. * @param _scene BabylonJS scene
  38737. */
  38738. constructor(_scene?: Scene | undefined);
  38739. /**
  38740. * The gamepads in the game pad manager
  38741. */
  38742. readonly gamepads: Gamepad[];
  38743. /**
  38744. * Get the gamepad controllers based on type
  38745. * @param type The type of gamepad controller
  38746. * @returns Nullable gamepad
  38747. */
  38748. getGamepadByType(type?: number): Nullable<Gamepad>;
  38749. /**
  38750. * Disposes the gamepad manager
  38751. */
  38752. dispose(): void;
  38753. private _addNewGamepad;
  38754. private _startMonitoringGamepads;
  38755. private _stopMonitoringGamepads;
  38756. /** @hidden */ checkGamepadsStatus(): void;
  38757. private _updateGamepadObjects;
  38758. }
  38759. }
  38760. declare module BABYLON {
  38761. interface Scene {
  38762. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38763. /**
  38764. * Gets the gamepad manager associated with the scene
  38765. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38766. */
  38767. gamepadManager: GamepadManager;
  38768. }
  38769. /**
  38770. * Interface representing a free camera inputs manager
  38771. */
  38772. interface FreeCameraInputsManager {
  38773. /**
  38774. * Adds gamepad input support to the FreeCameraInputsManager.
  38775. * @returns the FreeCameraInputsManager
  38776. */
  38777. addGamepad(): FreeCameraInputsManager;
  38778. }
  38779. /**
  38780. * Interface representing an arc rotate camera inputs manager
  38781. */
  38782. interface ArcRotateCameraInputsManager {
  38783. /**
  38784. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38785. * @returns the camera inputs manager
  38786. */
  38787. addGamepad(): ArcRotateCameraInputsManager;
  38788. }
  38789. /**
  38790. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38791. */
  38792. export class GamepadSystemSceneComponent implements ISceneComponent {
  38793. /**
  38794. * The component name helpfull to identify the component in the list of scene components.
  38795. */
  38796. readonly name: string;
  38797. /**
  38798. * The scene the component belongs to.
  38799. */
  38800. scene: Scene;
  38801. /**
  38802. * Creates a new instance of the component for the given scene
  38803. * @param scene Defines the scene to register the component in
  38804. */
  38805. constructor(scene: Scene);
  38806. /**
  38807. * Registers the component in a given scene
  38808. */
  38809. register(): void;
  38810. /**
  38811. * Rebuilds the elements related to this component in case of
  38812. * context lost for instance.
  38813. */
  38814. rebuild(): void;
  38815. /**
  38816. * Disposes the component and the associated ressources
  38817. */
  38818. dispose(): void;
  38819. private _beforeCameraUpdate;
  38820. }
  38821. }
  38822. declare module BABYLON {
  38823. /**
  38824. * Options to modify the vr teleportation behavior.
  38825. */
  38826. export interface VRTeleportationOptions {
  38827. /**
  38828. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38829. */
  38830. floorMeshName?: string;
  38831. /**
  38832. * A list of meshes to be used as the teleportation floor. (default: empty)
  38833. */
  38834. floorMeshes?: Mesh[];
  38835. }
  38836. /**
  38837. * Options to modify the vr experience helper's behavior.
  38838. */
  38839. export interface VRExperienceHelperOptions extends WebVROptions {
  38840. /**
  38841. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38842. */
  38843. createDeviceOrientationCamera?: boolean;
  38844. /**
  38845. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38846. */
  38847. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38848. /**
  38849. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38850. */
  38851. laserToggle?: boolean;
  38852. /**
  38853. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38854. */
  38855. floorMeshes?: Mesh[];
  38856. /**
  38857. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38858. */
  38859. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38860. }
  38861. /**
  38862. * Event containing information after VR has been entered
  38863. */
  38864. export class OnAfterEnteringVRObservableEvent {
  38865. /**
  38866. * If entering vr was successful
  38867. */
  38868. success: boolean;
  38869. }
  38870. /**
  38871. * Helps to quickly add VR support to an existing scene.
  38872. * See http://doc.babylonjs.com/how_to/webvr_helper
  38873. */
  38874. export class VRExperienceHelper {
  38875. /** Options to modify the vr experience helper's behavior. */
  38876. webVROptions: VRExperienceHelperOptions;
  38877. private _scene;
  38878. private _position;
  38879. private _btnVR;
  38880. private _btnVRDisplayed;
  38881. private _webVRsupported;
  38882. private _webVRready;
  38883. private _webVRrequesting;
  38884. private _webVRpresenting;
  38885. private _hasEnteredVR;
  38886. private _fullscreenVRpresenting;
  38887. private _canvas;
  38888. private _webVRCamera;
  38889. private _vrDeviceOrientationCamera;
  38890. private _deviceOrientationCamera;
  38891. private _existingCamera;
  38892. private _onKeyDown;
  38893. private _onVrDisplayPresentChange;
  38894. private _onVRDisplayChanged;
  38895. private _onVRRequestPresentStart;
  38896. private _onVRRequestPresentComplete;
  38897. /**
  38898. * Observable raised right before entering VR.
  38899. */
  38900. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38901. /**
  38902. * Observable raised when entering VR has completed.
  38903. */
  38904. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38905. /**
  38906. * Observable raised when exiting VR.
  38907. */
  38908. onExitingVRObservable: Observable<VRExperienceHelper>;
  38909. /**
  38910. * Observable raised when controller mesh is loaded.
  38911. */
  38912. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38913. /** Return this.onEnteringVRObservable
  38914. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38915. */
  38916. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38917. /** Return this.onExitingVRObservable
  38918. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38919. */
  38920. readonly onExitingVR: Observable<VRExperienceHelper>;
  38921. /** Return this.onControllerMeshLoadedObservable
  38922. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38923. */
  38924. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38925. private _rayLength;
  38926. private _useCustomVRButton;
  38927. private _teleportationRequested;
  38928. private _teleportActive;
  38929. private _floorMeshName;
  38930. private _floorMeshesCollection;
  38931. private _rotationAllowed;
  38932. private _teleportBackwardsVector;
  38933. private _teleportationTarget;
  38934. private _isDefaultTeleportationTarget;
  38935. private _postProcessMove;
  38936. private _teleportationFillColor;
  38937. private _teleportationBorderColor;
  38938. private _rotationAngle;
  38939. private _haloCenter;
  38940. private _cameraGazer;
  38941. private _padSensibilityUp;
  38942. private _padSensibilityDown;
  38943. private _leftController;
  38944. private _rightController;
  38945. /**
  38946. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38947. */
  38948. onNewMeshSelected: Observable<AbstractMesh>;
  38949. /**
  38950. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38951. */
  38952. onNewMeshPicked: Observable<PickingInfo>;
  38953. private _circleEase;
  38954. /**
  38955. * Observable raised before camera teleportation
  38956. */
  38957. onBeforeCameraTeleport: Observable<Vector3>;
  38958. /**
  38959. * Observable raised after camera teleportation
  38960. */
  38961. onAfterCameraTeleport: Observable<Vector3>;
  38962. /**
  38963. * Observable raised when current selected mesh gets unselected
  38964. */
  38965. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38966. private _raySelectionPredicate;
  38967. /**
  38968. * To be optionaly changed by user to define custom ray selection
  38969. */
  38970. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38971. /**
  38972. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38973. */
  38974. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38975. /**
  38976. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38977. */
  38978. teleportationEnabled: boolean;
  38979. private _defaultHeight;
  38980. private _teleportationInitialized;
  38981. private _interactionsEnabled;
  38982. private _interactionsRequested;
  38983. private _displayGaze;
  38984. private _displayLaserPointer;
  38985. /**
  38986. * The mesh used to display where the user is going to teleport.
  38987. */
  38988. /**
  38989. * Sets the mesh to be used to display where the user is going to teleport.
  38990. */
  38991. teleportationTarget: Mesh;
  38992. /**
  38993. * 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
  38994. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38995. * See http://doc.babylonjs.com/resources/baking_transformations
  38996. */
  38997. gazeTrackerMesh: Mesh;
  38998. /**
  38999. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39000. */
  39001. updateGazeTrackerScale: boolean;
  39002. /**
  39003. * If the gaze trackers color should be updated when selecting meshes
  39004. */
  39005. updateGazeTrackerColor: boolean;
  39006. /**
  39007. * The gaze tracking mesh corresponding to the left controller
  39008. */
  39009. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39010. /**
  39011. * The gaze tracking mesh corresponding to the right controller
  39012. */
  39013. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39014. /**
  39015. * If the ray of the gaze should be displayed.
  39016. */
  39017. /**
  39018. * Sets if the ray of the gaze should be displayed.
  39019. */
  39020. displayGaze: boolean;
  39021. /**
  39022. * If the ray of the LaserPointer should be displayed.
  39023. */
  39024. /**
  39025. * Sets if the ray of the LaserPointer should be displayed.
  39026. */
  39027. displayLaserPointer: boolean;
  39028. /**
  39029. * The deviceOrientationCamera used as the camera when not in VR.
  39030. */
  39031. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39032. /**
  39033. * Based on the current WebVR support, returns the current VR camera used.
  39034. */
  39035. readonly currentVRCamera: Nullable<Camera>;
  39036. /**
  39037. * The webVRCamera which is used when in VR.
  39038. */
  39039. readonly webVRCamera: WebVRFreeCamera;
  39040. /**
  39041. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39042. */
  39043. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39044. private readonly _teleportationRequestInitiated;
  39045. /**
  39046. * Defines wether or not Pointer lock should be requested when switching to
  39047. * full screen.
  39048. */
  39049. requestPointerLockOnFullScreen: boolean;
  39050. /**
  39051. * Instantiates a VRExperienceHelper.
  39052. * Helps to quickly add VR support to an existing scene.
  39053. * @param scene The scene the VRExperienceHelper belongs to.
  39054. * @param webVROptions Options to modify the vr experience helper's behavior.
  39055. */
  39056. constructor(scene: Scene,
  39057. /** Options to modify the vr experience helper's behavior. */
  39058. webVROptions?: VRExperienceHelperOptions);
  39059. private _onDefaultMeshLoaded;
  39060. private _onResize;
  39061. private _onFullscreenChange;
  39062. /**
  39063. * Gets a value indicating if we are currently in VR mode.
  39064. */
  39065. readonly isInVRMode: boolean;
  39066. private onVrDisplayPresentChange;
  39067. private onVRDisplayChanged;
  39068. private moveButtonToBottomRight;
  39069. private displayVRButton;
  39070. private updateButtonVisibility;
  39071. private _cachedAngularSensibility;
  39072. /**
  39073. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39074. * Otherwise, will use the fullscreen API.
  39075. */
  39076. enterVR(): void;
  39077. /**
  39078. * Attempt to exit VR, or fullscreen.
  39079. */
  39080. exitVR(): void;
  39081. /**
  39082. * The position of the vr experience helper.
  39083. */
  39084. /**
  39085. * Sets the position of the vr experience helper.
  39086. */
  39087. position: Vector3;
  39088. /**
  39089. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39090. */
  39091. enableInteractions(): void;
  39092. private readonly _noControllerIsActive;
  39093. private beforeRender;
  39094. private _isTeleportationFloor;
  39095. /**
  39096. * Adds a floor mesh to be used for teleportation.
  39097. * @param floorMesh the mesh to be used for teleportation.
  39098. */
  39099. addFloorMesh(floorMesh: Mesh): void;
  39100. /**
  39101. * Removes a floor mesh from being used for teleportation.
  39102. * @param floorMesh the mesh to be removed.
  39103. */
  39104. removeFloorMesh(floorMesh: Mesh): void;
  39105. /**
  39106. * Enables interactions and teleportation using the VR controllers and gaze.
  39107. * @param vrTeleportationOptions options to modify teleportation behavior.
  39108. */
  39109. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39110. private _onNewGamepadConnected;
  39111. private _tryEnableInteractionOnController;
  39112. private _onNewGamepadDisconnected;
  39113. private _enableInteractionOnController;
  39114. private _checkTeleportWithRay;
  39115. private _checkRotate;
  39116. private _checkTeleportBackwards;
  39117. private _enableTeleportationOnController;
  39118. private _createTeleportationCircles;
  39119. private _displayTeleportationTarget;
  39120. private _hideTeleportationTarget;
  39121. private _rotateCamera;
  39122. private _moveTeleportationSelectorTo;
  39123. private _workingVector;
  39124. private _workingQuaternion;
  39125. private _workingMatrix;
  39126. /**
  39127. * Teleports the users feet to the desired location
  39128. * @param location The location where the user's feet should be placed
  39129. */
  39130. teleportCamera(location: Vector3): void;
  39131. private _convertNormalToDirectionOfRay;
  39132. private _castRayAndSelectObject;
  39133. private _notifySelectedMeshUnselected;
  39134. /**
  39135. * Sets the color of the laser ray from the vr controllers.
  39136. * @param color new color for the ray.
  39137. */
  39138. changeLaserColor(color: Color3): void;
  39139. /**
  39140. * Sets the color of the ray from the vr headsets gaze.
  39141. * @param color new color for the ray.
  39142. */
  39143. changeGazeColor(color: Color3): void;
  39144. /**
  39145. * Exits VR and disposes of the vr experience helper
  39146. */
  39147. dispose(): void;
  39148. /**
  39149. * Gets the name of the VRExperienceHelper class
  39150. * @returns "VRExperienceHelper"
  39151. */
  39152. getClassName(): string;
  39153. }
  39154. }
  39155. declare module BABYLON {
  39156. /**
  39157. * Manages an XRSession
  39158. * @see https://doc.babylonjs.com/how_to/webxr
  39159. */
  39160. export class WebXRSessionManager implements IDisposable {
  39161. private scene;
  39162. /**
  39163. * Fires every time a new xrFrame arrives which can be used to update the camera
  39164. */
  39165. onXRFrameObservable: Observable<any>;
  39166. /**
  39167. * Fires when the xr session is ended either by the device or manually done
  39168. */
  39169. onXRSessionEnded: Observable<any>;
  39170. /** @hidden */ xrSession: XRSession;
  39171. /** @hidden */ frameOfReference: XRFrameOfReference;
  39172. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39173. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39174. private _xrNavigator;
  39175. private _xrDevice;
  39176. private _tmpMatrix;
  39177. /**
  39178. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39179. * @param scene The scene which the session should be created for
  39180. */
  39181. constructor(scene: Scene);
  39182. /**
  39183. * Initializes the manager
  39184. * After initialization enterXR can be called to start an XR session
  39185. * @returns Promise which resolves after it is initialized
  39186. */
  39187. initializeAsync(): Promise<void>;
  39188. /**
  39189. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39190. * @param sessionCreationOptions xr options to create the session with
  39191. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39192. * @returns Promise which resolves after it enters XR
  39193. */
  39194. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39195. /**
  39196. * Stops the xrSession and restores the renderloop
  39197. * @returns Promise which resolves after it exits XR
  39198. */
  39199. exitXRAsync(): Promise<void>;
  39200. /**
  39201. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39202. * @param ray ray to cast into the environment
  39203. * @returns Promise which resolves with a collision point in the environment if it exists
  39204. */
  39205. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39206. /**
  39207. * Checks if a session would be supported for the creation options specified
  39208. * @param options creation options to check if they are supported
  39209. * @returns true if supported
  39210. */
  39211. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39212. /**
  39213. * @hidden
  39214. * Converts the render layer of xrSession to a render target
  39215. * @param session session to create render target for
  39216. * @param scene scene the new render target should be created for
  39217. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39218. /**
  39219. * Disposes of the session manager
  39220. */
  39221. dispose(): void;
  39222. }
  39223. }
  39224. declare module BABYLON {
  39225. /**
  39226. * WebXR Camera which holds the views for the xrSession
  39227. * @see https://doc.babylonjs.com/how_to/webxr
  39228. */
  39229. export class WebXRCamera extends FreeCamera {
  39230. private static _TmpMatrix;
  39231. /**
  39232. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39233. * @param name the name of the camera
  39234. * @param scene the scene to add the camera to
  39235. */
  39236. constructor(name: string, scene: Scene);
  39237. private _updateNumberOfRigCameras;
  39238. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39239. /**
  39240. * Updates the cameras position from the current pose information of the XR session
  39241. * @param xrSessionManager the session containing pose information
  39242. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39243. */
  39244. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39245. }
  39246. }
  39247. declare module BABYLON {
  39248. /**
  39249. * States of the webXR experience
  39250. */
  39251. export enum WebXRState {
  39252. /**
  39253. * Transitioning to being in XR mode
  39254. */
  39255. ENTERING_XR = 0,
  39256. /**
  39257. * Transitioning to non XR mode
  39258. */
  39259. EXITING_XR = 1,
  39260. /**
  39261. * In XR mode and presenting
  39262. */
  39263. IN_XR = 2,
  39264. /**
  39265. * Not entered XR mode
  39266. */
  39267. NOT_IN_XR = 3
  39268. }
  39269. /**
  39270. * Helper class used to enable XR
  39271. * @see https://doc.babylonjs.com/how_to/webxr
  39272. */
  39273. export class WebXRExperienceHelper implements IDisposable {
  39274. private scene;
  39275. /**
  39276. * 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
  39277. */
  39278. container: AbstractMesh;
  39279. /**
  39280. * Camera used to render xr content
  39281. */
  39282. camera: WebXRCamera;
  39283. /**
  39284. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39285. */
  39286. state: WebXRState;
  39287. private _setState;
  39288. private static _TmpVector;
  39289. /**
  39290. * Fires when the state of the experience helper has changed
  39291. */
  39292. onStateChangedObservable: Observable<WebXRState>;
  39293. /** @hidden */ sessionManager: WebXRSessionManager;
  39294. private _nonVRCamera;
  39295. private _originalSceneAutoClear;
  39296. private _supported;
  39297. /**
  39298. * Creates the experience helper
  39299. * @param scene the scene to attach the experience helper to
  39300. * @returns a promise for the experience helper
  39301. */
  39302. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39303. /**
  39304. * Creates a WebXRExperienceHelper
  39305. * @param scene The scene the helper should be created in
  39306. */
  39307. private constructor();
  39308. /**
  39309. * Exits XR mode and returns the scene to its original state
  39310. * @returns promise that resolves after xr mode has exited
  39311. */
  39312. exitXRAsync(): Promise<void>;
  39313. /**
  39314. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39315. * @param sessionCreationOptions options for the XR session
  39316. * @param frameOfReference frame of reference of the XR session
  39317. * @returns promise that resolves after xr mode has entered
  39318. */
  39319. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39320. /**
  39321. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39322. * @param ray ray to cast into the environment
  39323. * @returns Promise which resolves with a collision point in the environment if it exists
  39324. */
  39325. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39326. /**
  39327. * Updates the global position of the camera by moving the camera's container
  39328. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39329. * @param position The desired global position of the camera
  39330. */
  39331. setPositionOfCameraUsingContainer(position: Vector3): void;
  39332. /**
  39333. * Rotates the xr camera by rotating the camera's container around the camera's position
  39334. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39335. * @param rotation the desired quaternion rotation to apply to the camera
  39336. */
  39337. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39338. /**
  39339. * Checks if the creation options are supported by the xr session
  39340. * @param options creation options
  39341. * @returns true if supported
  39342. */
  39343. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39344. /**
  39345. * Disposes of the experience helper
  39346. */
  39347. dispose(): void;
  39348. }
  39349. }
  39350. declare module BABYLON {
  39351. /**
  39352. * Button which can be used to enter a different mode of XR
  39353. */
  39354. export class WebXREnterExitUIButton {
  39355. /** button element */
  39356. element: HTMLElement;
  39357. /** XR initialization options for the button */
  39358. initializationOptions: XRSessionCreationOptions;
  39359. /**
  39360. * Creates a WebXREnterExitUIButton
  39361. * @param element button element
  39362. * @param initializationOptions XR initialization options for the button
  39363. */
  39364. constructor(
  39365. /** button element */
  39366. element: HTMLElement,
  39367. /** XR initialization options for the button */
  39368. initializationOptions: XRSessionCreationOptions);
  39369. /**
  39370. * Overwritable function which can be used to update the button's visuals when the state changes
  39371. * @param activeButton the current active button in the UI
  39372. */
  39373. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39374. }
  39375. /**
  39376. * Options to create the webXR UI
  39377. */
  39378. export class WebXREnterExitUIOptions {
  39379. /**
  39380. * Context to enter xr with
  39381. */
  39382. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39383. /**
  39384. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39385. */
  39386. customButtons?: Array<WebXREnterExitUIButton>;
  39387. }
  39388. /**
  39389. * UI to allow the user to enter/exit XR mode
  39390. */
  39391. export class WebXREnterExitUI implements IDisposable {
  39392. private scene;
  39393. private _overlay;
  39394. private _buttons;
  39395. private _activeButton;
  39396. /**
  39397. * Fired every time the active button is changed.
  39398. *
  39399. * When xr is entered via a button that launches xr that button will be the callback parameter
  39400. *
  39401. * When exiting xr the callback parameter will be null)
  39402. */
  39403. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39404. /**
  39405. * Creates UI to allow the user to enter/exit XR mode
  39406. * @param scene the scene to add the ui to
  39407. * @param helper the xr experience helper to enter/exit xr with
  39408. * @param options options to configure the UI
  39409. * @returns the created ui
  39410. */
  39411. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39412. private constructor();
  39413. private _updateButtons;
  39414. /**
  39415. * Disposes of the object
  39416. */
  39417. dispose(): void;
  39418. }
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * Represents an XR input
  39423. */
  39424. export class WebXRController {
  39425. /**
  39426. * 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
  39427. */
  39428. grip?: AbstractMesh;
  39429. /**
  39430. * Pointer which can be used to select objects or attach a visible laser to
  39431. */
  39432. pointer: AbstractMesh;
  39433. /**
  39434. * Creates the controller
  39435. * @see https://doc.babylonjs.com/how_to/webxr
  39436. * @param scene the scene which the controller should be associated to
  39437. */
  39438. constructor(scene: Scene);
  39439. /**
  39440. * Disposes of the object
  39441. */
  39442. dispose(): void;
  39443. }
  39444. /**
  39445. * XR input used to track XR inputs such as controllers/rays
  39446. */
  39447. export class WebXRInput implements IDisposable {
  39448. private helper;
  39449. /**
  39450. * XR controllers being tracked
  39451. */
  39452. controllers: Array<WebXRController>;
  39453. private _tmpMatrix;
  39454. private _frameObserver;
  39455. /**
  39456. * Initializes the WebXRInput
  39457. * @param helper experience helper which the input should be created for
  39458. */
  39459. constructor(helper: WebXRExperienceHelper);
  39460. /**
  39461. * Disposes of the object
  39462. */
  39463. dispose(): void;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39469. */
  39470. export class WebXRManagedOutputCanvas implements IDisposable {
  39471. private _canvas;
  39472. /**
  39473. * xrpresent context of the canvas which can be used to display/mirror xr content
  39474. */
  39475. canvasContext: Nullable<WebGLRenderingContext>;
  39476. /**
  39477. * Initializes the canvas to be added/removed upon entering/exiting xr
  39478. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39479. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39480. */
  39481. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39482. /**
  39483. * Disposes of the object
  39484. */
  39485. dispose(): void;
  39486. private _setManagedOutputCanvas;
  39487. private _addCanvas;
  39488. private _removeCanvas;
  39489. }
  39490. }
  39491. declare module BABYLON {
  39492. /**
  39493. * Contains an array of blocks representing the octree
  39494. */
  39495. export interface IOctreeContainer<T> {
  39496. /**
  39497. * Blocks within the octree
  39498. */
  39499. blocks: Array<OctreeBlock<T>>;
  39500. }
  39501. /**
  39502. * Class used to store a cell in an octree
  39503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39504. */
  39505. export class OctreeBlock<T> {
  39506. /**
  39507. * Gets the content of the current block
  39508. */
  39509. entries: T[];
  39510. /**
  39511. * Gets the list of block children
  39512. */
  39513. blocks: Array<OctreeBlock<T>>;
  39514. private _depth;
  39515. private _maxDepth;
  39516. private _capacity;
  39517. private _minPoint;
  39518. private _maxPoint;
  39519. private _boundingVectors;
  39520. private _creationFunc;
  39521. /**
  39522. * Creates a new block
  39523. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39524. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39525. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39526. * @param depth defines the current depth of this block in the octree
  39527. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39528. * @param creationFunc defines a callback to call when an element is added to the block
  39529. */
  39530. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39531. /**
  39532. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39533. */
  39534. readonly capacity: number;
  39535. /**
  39536. * Gets the minimum vector (in world space) of the block's bounding box
  39537. */
  39538. readonly minPoint: Vector3;
  39539. /**
  39540. * Gets the maximum vector (in world space) of the block's bounding box
  39541. */
  39542. readonly maxPoint: Vector3;
  39543. /**
  39544. * Add a new element to this block
  39545. * @param entry defines the element to add
  39546. */
  39547. addEntry(entry: T): void;
  39548. /**
  39549. * Remove an element from this block
  39550. * @param entry defines the element to remove
  39551. */
  39552. removeEntry(entry: T): void;
  39553. /**
  39554. * Add an array of elements to this block
  39555. * @param entries defines the array of elements to add
  39556. */
  39557. addEntries(entries: T[]): void;
  39558. /**
  39559. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39560. * @param frustumPlanes defines the frustum planes to test
  39561. * @param selection defines the array to store current content if selection is positive
  39562. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39563. */
  39564. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39565. /**
  39566. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39567. * @param sphereCenter defines the bounding sphere center
  39568. * @param sphereRadius defines the bounding sphere radius
  39569. * @param selection defines the array to store current content if selection is positive
  39570. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39571. */
  39572. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39573. /**
  39574. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39575. * @param ray defines the ray to test with
  39576. * @param selection defines the array to store current content if selection is positive
  39577. */
  39578. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39579. /**
  39580. * Subdivide the content into child blocks (this block will then be empty)
  39581. */
  39582. createInnerBlocks(): void;
  39583. /**
  39584. * @hidden
  39585. */ 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;
  39586. }
  39587. }
  39588. declare module BABYLON {
  39589. /**
  39590. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39591. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39592. */
  39593. export class Octree<T> {
  39594. /** 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.) */
  39595. maxDepth: number;
  39596. /**
  39597. * Blocks within the octree containing objects
  39598. */
  39599. blocks: Array<OctreeBlock<T>>;
  39600. /**
  39601. * Content stored in the octree
  39602. */
  39603. dynamicContent: T[];
  39604. private _maxBlockCapacity;
  39605. private _selectionContent;
  39606. private _creationFunc;
  39607. /**
  39608. * Creates a octree
  39609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39610. * @param creationFunc function to be used to instatiate the octree
  39611. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39612. * @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.)
  39613. */
  39614. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39615. /** 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.) */
  39616. maxDepth?: number);
  39617. /**
  39618. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39619. * @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);
  39620. * @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);
  39621. * @param entries meshes to be added to the octree blocks
  39622. */
  39623. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39624. /**
  39625. * Adds a mesh to the octree
  39626. * @param entry Mesh to add to the octree
  39627. */
  39628. addMesh(entry: T): void;
  39629. /**
  39630. * Remove an element from the octree
  39631. * @param entry defines the element to remove
  39632. */
  39633. removeMesh(entry: T): void;
  39634. /**
  39635. * Selects an array of meshes within the frustum
  39636. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39637. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39638. * @returns array of meshes within the frustum
  39639. */
  39640. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39641. /**
  39642. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39643. * @param sphereCenter defines the bounding sphere center
  39644. * @param sphereRadius defines the bounding sphere radius
  39645. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39646. * @returns an array of objects that intersect the sphere
  39647. */
  39648. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39649. /**
  39650. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39651. * @param ray defines the ray to test with
  39652. * @returns array of intersected objects
  39653. */
  39654. intersectsRay(ray: Ray): SmartArray<T>;
  39655. /**
  39656. * Adds a mesh into the octree block if it intersects the block
  39657. */
  39658. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39659. /**
  39660. * Adds a submesh into the octree block if it intersects the block
  39661. */
  39662. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39663. }
  39664. }
  39665. declare module BABYLON {
  39666. interface Scene {
  39667. /**
  39668. * @hidden
  39669. * Backing Filed
  39670. */ selectionOctree: Octree<AbstractMesh>;
  39671. /**
  39672. * Gets the octree used to boost mesh selection (picking)
  39673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39674. */
  39675. selectionOctree: Octree<AbstractMesh>;
  39676. /**
  39677. * Creates or updates the octree used to boost selection (picking)
  39678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39679. * @param maxCapacity defines the maximum capacity per leaf
  39680. * @param maxDepth defines the maximum depth of the octree
  39681. * @returns an octree of AbstractMesh
  39682. */
  39683. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39684. }
  39685. interface AbstractMesh {
  39686. /**
  39687. * @hidden
  39688. * Backing Field
  39689. */ submeshesOctree: Octree<SubMesh>;
  39690. /**
  39691. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39693. * @param maxCapacity defines the maximum size of each block (64 by default)
  39694. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39695. * @returns the new octree
  39696. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39698. */
  39699. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39700. }
  39701. /**
  39702. * Defines the octree scene component responsible to manage any octrees
  39703. * in a given scene.
  39704. */
  39705. export class OctreeSceneComponent {
  39706. /**
  39707. * The component name helpfull to identify the component in the list of scene components.
  39708. */
  39709. readonly name: string;
  39710. /**
  39711. * The scene the component belongs to.
  39712. */
  39713. scene: Scene;
  39714. /**
  39715. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39716. */
  39717. readonly checksIsEnabled: boolean;
  39718. /**
  39719. * Creates a new instance of the component for the given scene
  39720. * @param scene Defines the scene to register the component in
  39721. */
  39722. constructor(scene: Scene);
  39723. /**
  39724. * Registers the component in a given scene
  39725. */
  39726. register(): void;
  39727. /**
  39728. * Return the list of active meshes
  39729. * @returns the list of active meshes
  39730. */
  39731. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39732. /**
  39733. * Return the list of active sub meshes
  39734. * @param mesh The mesh to get the candidates sub meshes from
  39735. * @returns the list of active sub meshes
  39736. */
  39737. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39738. private _tempRay;
  39739. /**
  39740. * Return the list of sub meshes intersecting with a given local ray
  39741. * @param mesh defines the mesh to find the submesh for
  39742. * @param localRay defines the ray in local space
  39743. * @returns the list of intersecting sub meshes
  39744. */
  39745. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39746. /**
  39747. * Return the list of sub meshes colliding with a collider
  39748. * @param mesh defines the mesh to find the submesh for
  39749. * @param collider defines the collider to evaluate the collision against
  39750. * @returns the list of colliding sub meshes
  39751. */
  39752. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39753. /**
  39754. * Rebuilds the elements related to this component in case of
  39755. * context lost for instance.
  39756. */
  39757. rebuild(): void;
  39758. /**
  39759. * Disposes the component and the associated ressources.
  39760. */
  39761. dispose(): void;
  39762. }
  39763. }
  39764. declare module BABYLON {
  39765. /**
  39766. * Renders a layer on top of an existing scene
  39767. */
  39768. export class UtilityLayerRenderer implements IDisposable {
  39769. /** the original scene that will be rendered on top of */
  39770. originalScene: Scene;
  39771. private _pointerCaptures;
  39772. private _lastPointerEvents;
  39773. private static _DefaultUtilityLayer;
  39774. private static _DefaultKeepDepthUtilityLayer;
  39775. private _sharedGizmoLight;
  39776. /**
  39777. * @hidden
  39778. * Light which used by gizmos to get light shading
  39779. */ getSharedGizmoLight(): HemisphericLight;
  39780. /**
  39781. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39782. */
  39783. pickUtilitySceneFirst: boolean;
  39784. /**
  39785. * 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)
  39786. */
  39787. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39788. /**
  39789. * 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)
  39790. */
  39791. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39792. /**
  39793. * The scene that is rendered on top of the original scene
  39794. */
  39795. utilityLayerScene: Scene;
  39796. /**
  39797. * If the utility layer should automatically be rendered on top of existing scene
  39798. */
  39799. shouldRender: boolean;
  39800. /**
  39801. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39802. */
  39803. onlyCheckPointerDownEvents: boolean;
  39804. /**
  39805. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39806. */
  39807. processAllEvents: boolean;
  39808. /**
  39809. * Observable raised when the pointer move from the utility layer scene to the main scene
  39810. */
  39811. onPointerOutObservable: Observable<number>;
  39812. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39813. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39814. private _afterRenderObserver;
  39815. private _sceneDisposeObserver;
  39816. private _originalPointerObserver;
  39817. /**
  39818. * Instantiates a UtilityLayerRenderer
  39819. * @param originalScene the original scene that will be rendered on top of
  39820. * @param handleEvents boolean indicating if the utility layer should handle events
  39821. */
  39822. constructor(
  39823. /** the original scene that will be rendered on top of */
  39824. originalScene: Scene, handleEvents?: boolean);
  39825. private _notifyObservers;
  39826. /**
  39827. * Renders the utility layers scene on top of the original scene
  39828. */
  39829. render(): void;
  39830. /**
  39831. * Disposes of the renderer
  39832. */
  39833. dispose(): void;
  39834. private _updateCamera;
  39835. }
  39836. }
  39837. declare module BABYLON {
  39838. /**
  39839. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39840. */
  39841. export class Gizmo implements IDisposable {
  39842. /** The utility layer the gizmo will be added to */
  39843. gizmoLayer: UtilityLayerRenderer;
  39844. /**
  39845. * The root mesh of the gizmo
  39846. */ rootMesh: Mesh;
  39847. private _attachedMesh;
  39848. /**
  39849. * Ratio for the scale of the gizmo (Default: 1)
  39850. */
  39851. scaleRatio: number;
  39852. /**
  39853. * If a custom mesh has been set (Default: false)
  39854. */
  39855. protected _customMeshSet: boolean;
  39856. /**
  39857. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39858. * * When set, interactions will be enabled
  39859. */
  39860. attachedMesh: Nullable<AbstractMesh>;
  39861. /**
  39862. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39863. * @param mesh The mesh to replace the default mesh of the gizmo
  39864. */
  39865. setCustomMesh(mesh: Mesh): void;
  39866. /**
  39867. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39868. */
  39869. updateGizmoRotationToMatchAttachedMesh: boolean;
  39870. /**
  39871. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39872. */
  39873. updateGizmoPositionToMatchAttachedMesh: boolean;
  39874. /**
  39875. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39876. */
  39877. protected _updateScale: boolean;
  39878. protected _interactionsEnabled: boolean;
  39879. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39880. private _beforeRenderObserver;
  39881. private _tempVector;
  39882. /**
  39883. * Creates a gizmo
  39884. * @param gizmoLayer The utility layer the gizmo will be added to
  39885. */
  39886. constructor(
  39887. /** The utility layer the gizmo will be added to */
  39888. gizmoLayer?: UtilityLayerRenderer);
  39889. /**
  39890. * Updates the gizmo to match the attached mesh's position/rotation
  39891. */
  39892. protected _update(): void;
  39893. /**
  39894. * Disposes of the gizmo
  39895. */
  39896. dispose(): void;
  39897. }
  39898. }
  39899. declare module BABYLON {
  39900. /**
  39901. * Single axis drag gizmo
  39902. */
  39903. export class AxisDragGizmo extends Gizmo {
  39904. /**
  39905. * Drag behavior responsible for the gizmos dragging interactions
  39906. */
  39907. dragBehavior: PointerDragBehavior;
  39908. private _pointerObserver;
  39909. /**
  39910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39911. */
  39912. snapDistance: number;
  39913. /**
  39914. * Event that fires each time the gizmo snaps to a new location.
  39915. * * snapDistance is the the change in distance
  39916. */
  39917. onSnapObservable: Observable<{
  39918. snapDistance: number;
  39919. }>;
  39920. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39921. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39922. /**
  39923. * Creates an AxisDragGizmo
  39924. * @param gizmoLayer The utility layer the gizmo will be added to
  39925. * @param dragAxis The axis which the gizmo will be able to drag on
  39926. * @param color The color of the gizmo
  39927. */
  39928. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39929. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39930. /**
  39931. * Disposes of the gizmo
  39932. */
  39933. dispose(): void;
  39934. }
  39935. }
  39936. declare module BABYLON.Debug {
  39937. /**
  39938. * The Axes viewer will show 3 axes in a specific point in space
  39939. */
  39940. export class AxesViewer {
  39941. private _xAxis;
  39942. private _yAxis;
  39943. private _zAxis;
  39944. private _scaleLinesFactor;
  39945. private _instanced;
  39946. /**
  39947. * Gets the hosting scene
  39948. */
  39949. scene: Scene;
  39950. /**
  39951. * Gets or sets a number used to scale line length
  39952. */
  39953. scaleLines: number;
  39954. /** Gets the node hierarchy used to render x-axis */
  39955. readonly xAxis: TransformNode;
  39956. /** Gets the node hierarchy used to render y-axis */
  39957. readonly yAxis: TransformNode;
  39958. /** Gets the node hierarchy used to render z-axis */
  39959. readonly zAxis: TransformNode;
  39960. /**
  39961. * Creates a new AxesViewer
  39962. * @param scene defines the hosting scene
  39963. * @param scaleLines defines a number used to scale line length (1 by default)
  39964. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39965. * @param xAxis defines the node hierarchy used to render the x-axis
  39966. * @param yAxis defines the node hierarchy used to render the y-axis
  39967. * @param zAxis defines the node hierarchy used to render the z-axis
  39968. */
  39969. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39970. /**
  39971. * Force the viewer to update
  39972. * @param position defines the position of the viewer
  39973. * @param xaxis defines the x axis of the viewer
  39974. * @param yaxis defines the y axis of the viewer
  39975. * @param zaxis defines the z axis of the viewer
  39976. */
  39977. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39978. /**
  39979. * Creates an instance of this axes viewer.
  39980. * @returns a new axes viewer with instanced meshes
  39981. */
  39982. createInstance(): AxesViewer;
  39983. /** Releases resources */
  39984. dispose(): void;
  39985. private static _SetRenderingGroupId;
  39986. }
  39987. }
  39988. declare module BABYLON.Debug {
  39989. /**
  39990. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39991. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39992. */
  39993. export class BoneAxesViewer extends AxesViewer {
  39994. /**
  39995. * Gets or sets the target mesh where to display the axes viewer
  39996. */
  39997. mesh: Nullable<Mesh>;
  39998. /**
  39999. * Gets or sets the target bone where to display the axes viewer
  40000. */
  40001. bone: Nullable<Bone>;
  40002. /** Gets current position */
  40003. pos: Vector3;
  40004. /** Gets direction of X axis */
  40005. xaxis: Vector3;
  40006. /** Gets direction of Y axis */
  40007. yaxis: Vector3;
  40008. /** Gets direction of Z axis */
  40009. zaxis: Vector3;
  40010. /**
  40011. * Creates a new BoneAxesViewer
  40012. * @param scene defines the hosting scene
  40013. * @param bone defines the target bone
  40014. * @param mesh defines the target mesh
  40015. * @param scaleLines defines a scaling factor for line length (1 by default)
  40016. */
  40017. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40018. /**
  40019. * Force the viewer to update
  40020. */
  40021. update(): void;
  40022. /** Releases resources */
  40023. dispose(): void;
  40024. }
  40025. }
  40026. declare module BABYLON {
  40027. /**
  40028. * Interface used to define scene explorer extensibility option
  40029. */
  40030. export interface IExplorerExtensibilityOption {
  40031. /**
  40032. * Define the option label
  40033. */
  40034. label: string;
  40035. /**
  40036. * Defines the action to execute on click
  40037. */
  40038. action: (entity: any) => void;
  40039. }
  40040. /**
  40041. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40042. */
  40043. export interface IExplorerExtensibilityGroup {
  40044. /**
  40045. * Defines a predicate to test if a given type mut be extended
  40046. */
  40047. predicate: (entity: any) => boolean;
  40048. /**
  40049. * Gets the list of options added to a type
  40050. */
  40051. entries: IExplorerExtensibilityOption[];
  40052. }
  40053. /**
  40054. * Interface used to define the options to use to create the Inspector
  40055. */
  40056. export interface IInspectorOptions {
  40057. /**
  40058. * Display in overlay mode (default: false)
  40059. */
  40060. overlay?: boolean;
  40061. /**
  40062. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40063. */
  40064. globalRoot?: HTMLElement;
  40065. /**
  40066. * Display the Scene explorer
  40067. */
  40068. showExplorer?: boolean;
  40069. /**
  40070. * Display the property inspector
  40071. */
  40072. showInspector?: boolean;
  40073. /**
  40074. * Display in embed mode (both panes on the right)
  40075. */
  40076. embedMode?: boolean;
  40077. /**
  40078. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40079. */
  40080. handleResize?: boolean;
  40081. /**
  40082. * Allow the panes to popup (default: true)
  40083. */
  40084. enablePopup?: boolean;
  40085. /**
  40086. * Allow the panes to be closed by users (default: true)
  40087. */
  40088. enableClose?: boolean;
  40089. /**
  40090. * Optional list of extensibility entries
  40091. */
  40092. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40093. /**
  40094. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40095. */
  40096. inspectorURL?: string;
  40097. }
  40098. interface Scene {
  40099. /**
  40100. * @hidden
  40101. * Backing field
  40102. */ debugLayer: DebugLayer;
  40103. /**
  40104. * Gets the debug layer (aka Inspector) associated with the scene
  40105. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40106. */
  40107. debugLayer: DebugLayer;
  40108. }
  40109. /**
  40110. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40111. * what is happening in your scene
  40112. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40113. */
  40114. export class DebugLayer {
  40115. /**
  40116. * Define the url to get the inspector script from.
  40117. * By default it uses the babylonjs CDN.
  40118. * @ignoreNaming
  40119. */
  40120. static InspectorURL: string;
  40121. private _scene;
  40122. private BJSINSPECTOR;
  40123. /**
  40124. * Observable triggered when a property is changed through the inspector.
  40125. */
  40126. onPropertyChangedObservable: Observable<{
  40127. object: any;
  40128. property: string;
  40129. value: any;
  40130. initialValue: any;
  40131. }>;
  40132. /**
  40133. * Instantiates a new debug layer.
  40134. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40135. * what is happening in your scene
  40136. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40137. * @param scene Defines the scene to inspect
  40138. */
  40139. constructor(scene: Scene);
  40140. /** Creates the inspector window. */
  40141. private _createInspector;
  40142. /**
  40143. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40144. * @param entity defines the entity to select
  40145. * @param lineContainerTitle defines the specific block to highlight
  40146. */
  40147. select(entity: any, lineContainerTitle?: string): void;
  40148. /** Get the inspector from bundle or global */
  40149. private _getGlobalInspector;
  40150. /**
  40151. * Get if the inspector is visible or not.
  40152. * @returns true if visible otherwise, false
  40153. */
  40154. isVisible(): boolean;
  40155. /**
  40156. * Hide the inspector and close its window.
  40157. */
  40158. hide(): void;
  40159. /**
  40160. * Launch the debugLayer.
  40161. * @param config Define the configuration of the inspector
  40162. * @return a promise fulfilled when the debug layer is visible
  40163. */
  40164. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40165. }
  40166. }
  40167. declare module BABYLON {
  40168. /**
  40169. * Class containing static functions to help procedurally build meshes
  40170. */
  40171. export class BoxBuilder {
  40172. /**
  40173. * Creates a box mesh
  40174. * * The parameter `size` sets the size (float) of each box side (default 1)
  40175. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40176. * * 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)
  40177. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40179. * * 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
  40180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40181. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40182. * @param name defines the name of the mesh
  40183. * @param options defines the options used to create the mesh
  40184. * @param scene defines the hosting scene
  40185. * @returns the box mesh
  40186. */
  40187. static CreateBox(name: string, options: {
  40188. size?: number;
  40189. width?: number;
  40190. height?: number;
  40191. depth?: number;
  40192. faceUV?: Vector4[];
  40193. faceColors?: Color4[];
  40194. sideOrientation?: number;
  40195. frontUVs?: Vector4;
  40196. backUVs?: Vector4;
  40197. wrap?: boolean;
  40198. topBaseAt?: number;
  40199. bottomBaseAt?: number;
  40200. updatable?: boolean;
  40201. }, scene?: Nullable<Scene>): Mesh;
  40202. }
  40203. }
  40204. declare module BABYLON {
  40205. /**
  40206. * Class containing static functions to help procedurally build meshes
  40207. */
  40208. export class SphereBuilder {
  40209. /**
  40210. * Creates a sphere mesh
  40211. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40212. * * 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`)
  40213. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40214. * * 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
  40215. * * 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)
  40216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40217. * * 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
  40218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40219. * @param name defines the name of the mesh
  40220. * @param options defines the options used to create the mesh
  40221. * @param scene defines the hosting scene
  40222. * @returns the sphere mesh
  40223. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40224. */
  40225. static CreateSphere(name: string, options: {
  40226. segments?: number;
  40227. diameter?: number;
  40228. diameterX?: number;
  40229. diameterY?: number;
  40230. diameterZ?: number;
  40231. arc?: number;
  40232. slice?: number;
  40233. sideOrientation?: number;
  40234. frontUVs?: Vector4;
  40235. backUVs?: Vector4;
  40236. updatable?: boolean;
  40237. }, scene: any): Mesh;
  40238. }
  40239. }
  40240. declare module BABYLON.Debug {
  40241. /**
  40242. * Used to show the physics impostor around the specific mesh
  40243. */
  40244. export class PhysicsViewer {
  40245. /** @hidden */
  40246. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40247. /** @hidden */
  40248. protected _meshes: Array<Nullable<AbstractMesh>>;
  40249. /** @hidden */
  40250. protected _scene: Nullable<Scene>;
  40251. /** @hidden */
  40252. protected _numMeshes: number;
  40253. /** @hidden */
  40254. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40255. private _renderFunction;
  40256. private _utilityLayer;
  40257. private _debugBoxMesh;
  40258. private _debugSphereMesh;
  40259. private _debugCylinderMesh;
  40260. private _debugMaterial;
  40261. private _debugMeshMeshes;
  40262. /**
  40263. * Creates a new PhysicsViewer
  40264. * @param scene defines the hosting scene
  40265. */
  40266. constructor(scene: Scene);
  40267. /** @hidden */
  40268. protected _updateDebugMeshes(): void;
  40269. /**
  40270. * Renders a specified physic impostor
  40271. * @param impostor defines the impostor to render
  40272. * @param targetMesh defines the mesh represented by the impostor
  40273. * @returns the new debug mesh used to render the impostor
  40274. */
  40275. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40276. /**
  40277. * Hides a specified physic impostor
  40278. * @param impostor defines the impostor to hide
  40279. */
  40280. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40281. private _getDebugMaterial;
  40282. private _getDebugBoxMesh;
  40283. private _getDebugSphereMesh;
  40284. private _getDebugCylinderMesh;
  40285. private _getDebugMeshMesh;
  40286. private _getDebugMesh;
  40287. /** Releases all resources */
  40288. dispose(): void;
  40289. }
  40290. }
  40291. declare module BABYLON {
  40292. /**
  40293. * Class containing static functions to help procedurally build meshes
  40294. */
  40295. export class LinesBuilder {
  40296. /**
  40297. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40298. * * 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
  40299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40300. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40301. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40302. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40303. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40304. * * 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
  40305. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40308. * @param name defines the name of the new line system
  40309. * @param options defines the options used to create the line system
  40310. * @param scene defines the hosting scene
  40311. * @returns a new line system mesh
  40312. */
  40313. static CreateLineSystem(name: string, options: {
  40314. lines: Vector3[][];
  40315. updatable?: boolean;
  40316. instance?: Nullable<LinesMesh>;
  40317. colors?: Nullable<Color4[][]>;
  40318. useVertexAlpha?: boolean;
  40319. }, scene: Nullable<Scene>): LinesMesh;
  40320. /**
  40321. * Creates a line mesh
  40322. * 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
  40323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40324. * * The parameter `points` is an array successive Vector3
  40325. * * 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
  40326. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40327. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40328. * * When updating an instance, remember that only point positions can change, not the number of points
  40329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40331. * @param name defines the name of the new line system
  40332. * @param options defines the options used to create the line system
  40333. * @param scene defines the hosting scene
  40334. * @returns a new line mesh
  40335. */
  40336. static CreateLines(name: string, options: {
  40337. points: Vector3[];
  40338. updatable?: boolean;
  40339. instance?: Nullable<LinesMesh>;
  40340. colors?: Color4[];
  40341. useVertexAlpha?: boolean;
  40342. }, scene?: Nullable<Scene>): LinesMesh;
  40343. /**
  40344. * Creates a dashed line mesh
  40345. * * 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
  40346. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40347. * * The parameter `points` is an array successive Vector3
  40348. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40349. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40350. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40351. * * 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
  40352. * * When updating an instance, remember that only point positions can change, not the number of points
  40353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40354. * @param name defines the name of the mesh
  40355. * @param options defines the options used to create the mesh
  40356. * @param scene defines the hosting scene
  40357. * @returns the dashed line mesh
  40358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40359. */
  40360. static CreateDashedLines(name: string, options: {
  40361. points: Vector3[];
  40362. dashSize?: number;
  40363. gapSize?: number;
  40364. dashNb?: number;
  40365. updatable?: boolean;
  40366. instance?: LinesMesh;
  40367. }, scene?: Nullable<Scene>): LinesMesh;
  40368. }
  40369. }
  40370. declare module BABYLON {
  40371. /**
  40372. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40373. * in order to better appreciate the issue one might have.
  40374. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40375. */
  40376. export class RayHelper {
  40377. /**
  40378. * Defines the ray we are currently tryin to visualize.
  40379. */
  40380. ray: Nullable<Ray>;
  40381. private _renderPoints;
  40382. private _renderLine;
  40383. private _renderFunction;
  40384. private _scene;
  40385. private _updateToMeshFunction;
  40386. private _attachedToMesh;
  40387. private _meshSpaceDirection;
  40388. private _meshSpaceOrigin;
  40389. /**
  40390. * Helper function to create a colored helper in a scene in one line.
  40391. * @param ray Defines the ray we are currently tryin to visualize
  40392. * @param scene Defines the scene the ray is used in
  40393. * @param color Defines the color we want to see the ray in
  40394. * @returns The newly created ray helper.
  40395. */
  40396. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40397. /**
  40398. * Instantiate a new ray helper.
  40399. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40400. * in order to better appreciate the issue one might have.
  40401. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40402. * @param ray Defines the ray we are currently tryin to visualize
  40403. */
  40404. constructor(ray: Ray);
  40405. /**
  40406. * Shows the ray we are willing to debug.
  40407. * @param scene Defines the scene the ray needs to be rendered in
  40408. * @param color Defines the color the ray needs to be rendered in
  40409. */
  40410. show(scene: Scene, color?: Color3): void;
  40411. /**
  40412. * Hides the ray we are debugging.
  40413. */
  40414. hide(): void;
  40415. private _render;
  40416. /**
  40417. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40418. * @param mesh Defines the mesh we want the helper attached to
  40419. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40420. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40421. * @param length Defines the length of the ray
  40422. */
  40423. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40424. /**
  40425. * Detach the ray helper from the mesh it has previously been attached to.
  40426. */
  40427. detachFromMesh(): void;
  40428. private _updateToMesh;
  40429. /**
  40430. * Dispose the helper and release its associated resources.
  40431. */
  40432. dispose(): void;
  40433. }
  40434. }
  40435. declare module BABYLON.Debug {
  40436. /**
  40437. * Class used to render a debug view of a given skeleton
  40438. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40439. */
  40440. export class SkeletonViewer {
  40441. /** defines the skeleton to render */
  40442. skeleton: Skeleton;
  40443. /** defines the mesh attached to the skeleton */
  40444. mesh: AbstractMesh;
  40445. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40446. autoUpdateBonesMatrices: boolean;
  40447. /** defines the rendering group id to use with the viewer */
  40448. renderingGroupId: number;
  40449. /** Gets or sets the color used to render the skeleton */
  40450. color: Color3;
  40451. private _scene;
  40452. private _debugLines;
  40453. private _debugMesh;
  40454. private _isEnabled;
  40455. private _renderFunction;
  40456. private _utilityLayer;
  40457. /**
  40458. * Returns the mesh used to render the bones
  40459. */
  40460. readonly debugMesh: Nullable<LinesMesh>;
  40461. /**
  40462. * Creates a new SkeletonViewer
  40463. * @param skeleton defines the skeleton to render
  40464. * @param mesh defines the mesh attached to the skeleton
  40465. * @param scene defines the hosting scene
  40466. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40467. * @param renderingGroupId defines the rendering group id to use with the viewer
  40468. */
  40469. constructor(
  40470. /** defines the skeleton to render */
  40471. skeleton: Skeleton,
  40472. /** defines the mesh attached to the skeleton */
  40473. mesh: AbstractMesh, scene: Scene,
  40474. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40475. autoUpdateBonesMatrices?: boolean,
  40476. /** defines the rendering group id to use with the viewer */
  40477. renderingGroupId?: number);
  40478. /** Gets or sets a boolean indicating if the viewer is enabled */
  40479. isEnabled: boolean;
  40480. private _getBonePosition;
  40481. private _getLinesForBonesWithLength;
  40482. private _getLinesForBonesNoLength;
  40483. /** Update the viewer to sync with current skeleton state */
  40484. update(): void;
  40485. /** Release associated resources */
  40486. dispose(): void;
  40487. }
  40488. }
  40489. declare module BABYLON {
  40490. /**
  40491. * Options to create the null engine
  40492. */
  40493. export class NullEngineOptions {
  40494. /**
  40495. * Render width (Default: 512)
  40496. */
  40497. renderWidth: number;
  40498. /**
  40499. * Render height (Default: 256)
  40500. */
  40501. renderHeight: number;
  40502. /**
  40503. * Texture size (Default: 512)
  40504. */
  40505. textureSize: number;
  40506. /**
  40507. * If delta time between frames should be constant
  40508. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40509. */
  40510. deterministicLockstep: boolean;
  40511. /**
  40512. * Maximum about of steps between frames (Default: 4)
  40513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40514. */
  40515. lockstepMaxSteps: number;
  40516. }
  40517. /**
  40518. * The null engine class provides support for headless version of babylon.js.
  40519. * This can be used in server side scenario or for testing purposes
  40520. */
  40521. export class NullEngine extends Engine {
  40522. private _options;
  40523. /**
  40524. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40525. */
  40526. isDeterministicLockStep(): boolean;
  40527. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40528. getLockstepMaxSteps(): number;
  40529. /**
  40530. * Sets hardware scaling, used to save performance if needed
  40531. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40532. */
  40533. getHardwareScalingLevel(): number;
  40534. constructor(options?: NullEngineOptions);
  40535. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40536. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40537. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40538. getRenderWidth(useScreen?: boolean): number;
  40539. getRenderHeight(useScreen?: boolean): number;
  40540. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40541. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40542. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40543. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40544. bindSamplers(effect: Effect): void;
  40545. enableEffect(effect: Effect): void;
  40546. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40547. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40548. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40549. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40550. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40551. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40552. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40553. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40554. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40555. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40556. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40557. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40558. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40559. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40560. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40561. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40562. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40563. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40564. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40565. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40566. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40567. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40568. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40569. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40571. bindBuffers(vertexBuffers: {
  40572. [key: string]: VertexBuffer;
  40573. }, indexBuffer: DataBuffer, effect: Effect): void;
  40574. wipeCaches(bruteForce?: boolean): void;
  40575. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40576. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40577. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40578. /** @hidden */ createTexture(): WebGLTexture;
  40579. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40580. 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;
  40581. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40582. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40583. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40584. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40585. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40586. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40587. areAllEffectsReady(): boolean;
  40588. /**
  40589. * @hidden
  40590. * Get the current error code of the webGL context
  40591. * @returns the error code
  40592. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40593. */
  40594. getError(): number;
  40595. /** @hidden */ getUnpackAlignement(): number;
  40596. /** @hidden */ unpackFlipY(value: boolean): void;
  40597. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40598. /**
  40599. * Updates a dynamic vertex buffer.
  40600. * @param vertexBuffer the vertex buffer to update
  40601. * @param data the data used to update the vertex buffer
  40602. * @param byteOffset the byte offset of the data (optional)
  40603. * @param byteLength the byte length of the data (optional)
  40604. */
  40605. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40606. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40607. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40608. releaseEffects(): void;
  40609. displayLoadingUI(): void;
  40610. hideLoadingUI(): void;
  40611. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40612. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40613. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40614. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40615. }
  40616. }
  40617. declare module BABYLON {
  40618. /** @hidden */
  40619. export class _OcclusionDataStorage {
  40620. /** @hidden */
  40621. occlusionInternalRetryCounter: number;
  40622. /** @hidden */
  40623. isOcclusionQueryInProgress: boolean;
  40624. /** @hidden */
  40625. isOccluded: boolean;
  40626. /** @hidden */
  40627. occlusionRetryCount: number;
  40628. /** @hidden */
  40629. occlusionType: number;
  40630. /** @hidden */
  40631. occlusionQueryAlgorithmType: number;
  40632. }
  40633. interface Engine {
  40634. /**
  40635. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40636. * @return the new query
  40637. */
  40638. createQuery(): WebGLQuery;
  40639. /**
  40640. * Delete and release a webGL query
  40641. * @param query defines the query to delete
  40642. * @return the current engine
  40643. */
  40644. deleteQuery(query: WebGLQuery): Engine;
  40645. /**
  40646. * Check if a given query has resolved and got its value
  40647. * @param query defines the query to check
  40648. * @returns true if the query got its value
  40649. */
  40650. isQueryResultAvailable(query: WebGLQuery): boolean;
  40651. /**
  40652. * Gets the value of a given query
  40653. * @param query defines the query to check
  40654. * @returns the value of the query
  40655. */
  40656. getQueryResult(query: WebGLQuery): number;
  40657. /**
  40658. * Initiates an occlusion query
  40659. * @param algorithmType defines the algorithm to use
  40660. * @param query defines the query to use
  40661. * @returns the current engine
  40662. * @see http://doc.babylonjs.com/features/occlusionquery
  40663. */
  40664. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40665. /**
  40666. * Ends an occlusion query
  40667. * @see http://doc.babylonjs.com/features/occlusionquery
  40668. * @param algorithmType defines the algorithm to use
  40669. * @returns the current engine
  40670. */
  40671. endOcclusionQuery(algorithmType: number): Engine;
  40672. /**
  40673. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40674. * Please note that only one query can be issued at a time
  40675. * @returns a time token used to track the time span
  40676. */
  40677. startTimeQuery(): Nullable<_TimeToken>;
  40678. /**
  40679. * Ends a time query
  40680. * @param token defines the token used to measure the time span
  40681. * @returns the time spent (in ns)
  40682. */
  40683. endTimeQuery(token: _TimeToken): int;
  40684. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40685. /** @hidden */ createTimeQuery(): WebGLQuery;
  40686. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40687. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40688. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40689. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40690. }
  40691. interface AbstractMesh {
  40692. /**
  40693. * Backing filed
  40694. * @hidden
  40695. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40696. /**
  40697. * Access property
  40698. * @hidden
  40699. */ occlusionDataStorage: _OcclusionDataStorage;
  40700. /**
  40701. * 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.
  40702. * The default value is -1 which means don't break the query and wait till the result
  40703. * @see http://doc.babylonjs.com/features/occlusionquery
  40704. */
  40705. occlusionRetryCount: number;
  40706. /**
  40707. * 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:
  40708. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40709. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40710. * * 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.
  40711. * @see http://doc.babylonjs.com/features/occlusionquery
  40712. */
  40713. occlusionType: number;
  40714. /**
  40715. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40716. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40717. * * 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.
  40718. * @see http://doc.babylonjs.com/features/occlusionquery
  40719. */
  40720. occlusionQueryAlgorithmType: number;
  40721. /**
  40722. * 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
  40723. * @see http://doc.babylonjs.com/features/occlusionquery
  40724. */
  40725. isOccluded: boolean;
  40726. /**
  40727. * Flag to check the progress status of the query
  40728. * @see http://doc.babylonjs.com/features/occlusionquery
  40729. */
  40730. isOcclusionQueryInProgress: boolean;
  40731. }
  40732. }
  40733. declare module BABYLON {
  40734. /** @hidden */
  40735. export var _forceTransformFeedbackToBundle: boolean;
  40736. interface Engine {
  40737. /**
  40738. * Creates a webGL transform feedback object
  40739. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40740. * @returns the webGL transform feedback object
  40741. */
  40742. createTransformFeedback(): WebGLTransformFeedback;
  40743. /**
  40744. * Delete a webGL transform feedback object
  40745. * @param value defines the webGL transform feedback object to delete
  40746. */
  40747. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40748. /**
  40749. * Bind a webGL transform feedback object to the webgl context
  40750. * @param value defines the webGL transform feedback object to bind
  40751. */
  40752. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40753. /**
  40754. * Begins a transform feedback operation
  40755. * @param usePoints defines if points or triangles must be used
  40756. */
  40757. beginTransformFeedback(usePoints: boolean): void;
  40758. /**
  40759. * Ends a transform feedback operation
  40760. */
  40761. endTransformFeedback(): void;
  40762. /**
  40763. * Specify the varyings to use with transform feedback
  40764. * @param program defines the associated webGL program
  40765. * @param value defines the list of strings representing the varying names
  40766. */
  40767. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40768. /**
  40769. * Bind a webGL buffer for a transform feedback operation
  40770. * @param value defines the webGL buffer to bind
  40771. */
  40772. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40773. }
  40774. }
  40775. declare module BABYLON {
  40776. /**
  40777. * Creation options of the multi render target texture.
  40778. */
  40779. export interface IMultiRenderTargetOptions {
  40780. /**
  40781. * Define if the texture needs to create mip maps after render.
  40782. */
  40783. generateMipMaps?: boolean;
  40784. /**
  40785. * Define the types of all the draw buffers we want to create
  40786. */
  40787. types?: number[];
  40788. /**
  40789. * Define the sampling modes of all the draw buffers we want to create
  40790. */
  40791. samplingModes?: number[];
  40792. /**
  40793. * Define if a depth buffer is required
  40794. */
  40795. generateDepthBuffer?: boolean;
  40796. /**
  40797. * Define if a stencil buffer is required
  40798. */
  40799. generateStencilBuffer?: boolean;
  40800. /**
  40801. * Define if a depth texture is required instead of a depth buffer
  40802. */
  40803. generateDepthTexture?: boolean;
  40804. /**
  40805. * Define the number of desired draw buffers
  40806. */
  40807. textureCount?: number;
  40808. /**
  40809. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40810. */
  40811. doNotChangeAspectRatio?: boolean;
  40812. /**
  40813. * Define the default type of the buffers we are creating
  40814. */
  40815. defaultType?: number;
  40816. }
  40817. /**
  40818. * A multi render target, like a render target provides the ability to render to a texture.
  40819. * Unlike the render target, it can render to several draw buffers in one draw.
  40820. * This is specially interesting in deferred rendering or for any effects requiring more than
  40821. * just one color from a single pass.
  40822. */
  40823. export class MultiRenderTarget extends RenderTargetTexture {
  40824. private _internalTextures;
  40825. private _textures;
  40826. private _multiRenderTargetOptions;
  40827. /**
  40828. * Get if draw buffers are currently supported by the used hardware and browser.
  40829. */
  40830. readonly isSupported: boolean;
  40831. /**
  40832. * Get the list of textures generated by the multi render target.
  40833. */
  40834. readonly textures: Texture[];
  40835. /**
  40836. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40837. */
  40838. readonly depthTexture: Texture;
  40839. /**
  40840. * Set the wrapping mode on U of all the textures we are rendering to.
  40841. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40842. */
  40843. wrapU: number;
  40844. /**
  40845. * Set the wrapping mode on V of all the textures we are rendering to.
  40846. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40847. */
  40848. wrapV: number;
  40849. /**
  40850. * Instantiate a new multi render target texture.
  40851. * A multi render target, like a render target provides the ability to render to a texture.
  40852. * Unlike the render target, it can render to several draw buffers in one draw.
  40853. * This is specially interesting in deferred rendering or for any effects requiring more than
  40854. * just one color from a single pass.
  40855. * @param name Define the name of the texture
  40856. * @param size Define the size of the buffers to render to
  40857. * @param count Define the number of target we are rendering into
  40858. * @param scene Define the scene the texture belongs to
  40859. * @param options Define the options used to create the multi render target
  40860. */
  40861. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  40862. /** @hidden */ rebuild(): void;
  40863. private _createInternalTextures;
  40864. private _createTextures;
  40865. /**
  40866. * Define the number of samples used if MSAA is enabled.
  40867. */
  40868. samples: number;
  40869. /**
  40870. * Resize all the textures in the multi render target.
  40871. * Be carrefull as it will recreate all the data in the new texture.
  40872. * @param size Define the new size
  40873. */
  40874. resize(size: any): void;
  40875. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40876. /**
  40877. * Dispose the render targets and their associated resources
  40878. */
  40879. dispose(): void;
  40880. /**
  40881. * Release all the underlying texture used as draw buffers.
  40882. */
  40883. releaseInternalTextures(): void;
  40884. }
  40885. }
  40886. declare module BABYLON {
  40887. interface Engine {
  40888. /**
  40889. * Unbind a list of render target textures from the webGL context
  40890. * This is used only when drawBuffer extension or webGL2 are active
  40891. * @param textures defines the render target textures to unbind
  40892. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40893. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40894. */
  40895. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  40896. /**
  40897. * Create a multi render target texture
  40898. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  40899. * @param size defines the size of the texture
  40900. * @param options defines the creation options
  40901. * @returns the cube texture as an InternalTexture
  40902. */
  40903. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  40904. /**
  40905. * Update the sample count for a given multiple render target texture
  40906. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  40907. * @param textures defines the textures to update
  40908. * @param samples defines the sample count to set
  40909. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  40910. */
  40911. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  40912. }
  40913. }
  40914. declare module BABYLON {
  40915. /**
  40916. * Gather the list of clipboard event types as constants.
  40917. */
  40918. export class ClipboardEventTypes {
  40919. /**
  40920. * The clipboard event is fired when a copy command is active (pressed).
  40921. */
  40922. static readonly COPY: number;
  40923. /**
  40924. * The clipboard event is fired when a cut command is active (pressed).
  40925. */
  40926. static readonly CUT: number;
  40927. /**
  40928. * The clipboard event is fired when a paste command is active (pressed).
  40929. */
  40930. static readonly PASTE: number;
  40931. }
  40932. /**
  40933. * This class is used to store clipboard related info for the onClipboardObservable event.
  40934. */
  40935. export class ClipboardInfo {
  40936. /**
  40937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40938. */
  40939. type: number;
  40940. /**
  40941. * Defines the related dom event
  40942. */
  40943. event: ClipboardEvent;
  40944. /**
  40945. *Creates an instance of ClipboardInfo.
  40946. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40947. * @param event Defines the related dom event
  40948. */
  40949. constructor(
  40950. /**
  40951. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40952. */
  40953. type: number,
  40954. /**
  40955. * Defines the related dom event
  40956. */
  40957. event: ClipboardEvent);
  40958. /**
  40959. * Get the clipboard event's type from the keycode.
  40960. * @param keyCode Defines the keyCode for the current keyboard event.
  40961. * @return {number}
  40962. */
  40963. static GetTypeFromCharacter(keyCode: number): number;
  40964. }
  40965. }
  40966. declare module BABYLON {
  40967. /**
  40968. * Class used to represent data loading progression
  40969. */
  40970. export class SceneLoaderProgressEvent {
  40971. /** defines if data length to load can be evaluated */
  40972. readonly lengthComputable: boolean;
  40973. /** defines the loaded data length */
  40974. readonly loaded: number;
  40975. /** defines the data length to load */
  40976. readonly total: number;
  40977. /**
  40978. * Create a new progress event
  40979. * @param lengthComputable defines if data length to load can be evaluated
  40980. * @param loaded defines the loaded data length
  40981. * @param total defines the data length to load
  40982. */
  40983. constructor(
  40984. /** defines if data length to load can be evaluated */
  40985. lengthComputable: boolean,
  40986. /** defines the loaded data length */
  40987. loaded: number,
  40988. /** defines the data length to load */
  40989. total: number);
  40990. /**
  40991. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40992. * @param event defines the source event
  40993. * @returns a new SceneLoaderProgressEvent
  40994. */
  40995. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40996. }
  40997. /**
  40998. * Interface used by SceneLoader plugins to define supported file extensions
  40999. */
  41000. export interface ISceneLoaderPluginExtensions {
  41001. /**
  41002. * Defines the list of supported extensions
  41003. */
  41004. [extension: string]: {
  41005. isBinary: boolean;
  41006. };
  41007. }
  41008. /**
  41009. * Interface used by SceneLoader plugin factory
  41010. */
  41011. export interface ISceneLoaderPluginFactory {
  41012. /**
  41013. * Defines the name of the factory
  41014. */
  41015. name: string;
  41016. /**
  41017. * Function called to create a new plugin
  41018. * @return the new plugin
  41019. */
  41020. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41021. /**
  41022. * Boolean indicating if the plugin can direct load specific data
  41023. */
  41024. canDirectLoad?: (data: string) => boolean;
  41025. }
  41026. /**
  41027. * Interface used to define a SceneLoader plugin
  41028. */
  41029. export interface ISceneLoaderPlugin {
  41030. /**
  41031. * The friendly name of this plugin.
  41032. */
  41033. name: string;
  41034. /**
  41035. * The file extensions supported by this plugin.
  41036. */
  41037. extensions: string | ISceneLoaderPluginExtensions;
  41038. /**
  41039. * Import meshes into a scene.
  41040. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41041. * @param scene The scene to import into
  41042. * @param data The data to import
  41043. * @param rootUrl The root url for scene and resources
  41044. * @param meshes The meshes array to import into
  41045. * @param particleSystems The particle systems array to import into
  41046. * @param skeletons The skeletons array to import into
  41047. * @param onError The callback when import fails
  41048. * @returns True if successful or false otherwise
  41049. */
  41050. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41051. /**
  41052. * Load into a scene.
  41053. * @param scene The scene to load into
  41054. * @param data The data to import
  41055. * @param rootUrl The root url for scene and resources
  41056. * @param onError The callback when import fails
  41057. * @returns true if successful or false otherwise
  41058. */
  41059. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41060. /**
  41061. * The callback that returns true if the data can be directly loaded.
  41062. */
  41063. canDirectLoad?: (data: string) => boolean;
  41064. /**
  41065. * The callback that allows custom handling of the root url based on the response url.
  41066. */
  41067. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41068. /**
  41069. * Load into an asset container.
  41070. * @param scene The scene to load into
  41071. * @param data The data to import
  41072. * @param rootUrl The root url for scene and resources
  41073. * @param onError The callback when import fails
  41074. * @returns The loaded asset container
  41075. */
  41076. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41077. }
  41078. /**
  41079. * Interface used to define an async SceneLoader plugin
  41080. */
  41081. export interface ISceneLoaderPluginAsync {
  41082. /**
  41083. * The friendly name of this plugin.
  41084. */
  41085. name: string;
  41086. /**
  41087. * The file extensions supported by this plugin.
  41088. */
  41089. extensions: string | ISceneLoaderPluginExtensions;
  41090. /**
  41091. * Import meshes into a scene.
  41092. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41093. * @param scene The scene to import into
  41094. * @param data The data to import
  41095. * @param rootUrl The root url for scene and resources
  41096. * @param onProgress The callback when the load progresses
  41097. * @param fileName Defines the name of the file to load
  41098. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41099. */
  41100. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41101. meshes: AbstractMesh[];
  41102. particleSystems: IParticleSystem[];
  41103. skeletons: Skeleton[];
  41104. animationGroups: AnimationGroup[];
  41105. }>;
  41106. /**
  41107. * Load into a scene.
  41108. * @param scene The scene to load into
  41109. * @param data The data to import
  41110. * @param rootUrl The root url for scene and resources
  41111. * @param onProgress The callback when the load progresses
  41112. * @param fileName Defines the name of the file to load
  41113. * @returns Nothing
  41114. */
  41115. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41116. /**
  41117. * The callback that returns true if the data can be directly loaded.
  41118. */
  41119. canDirectLoad?: (data: string) => boolean;
  41120. /**
  41121. * The callback that allows custom handling of the root url based on the response url.
  41122. */
  41123. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41124. /**
  41125. * Load into an asset container.
  41126. * @param scene The scene to load into
  41127. * @param data The data to import
  41128. * @param rootUrl The root url for scene and resources
  41129. * @param onProgress The callback when the load progresses
  41130. * @param fileName Defines the name of the file to load
  41131. * @returns The loaded asset container
  41132. */
  41133. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41134. }
  41135. /**
  41136. * Class used to load scene from various file formats using registered plugins
  41137. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41138. */
  41139. export class SceneLoader {
  41140. /**
  41141. * No logging while loading
  41142. */
  41143. static readonly NO_LOGGING: number;
  41144. /**
  41145. * Minimal logging while loading
  41146. */
  41147. static readonly MINIMAL_LOGGING: number;
  41148. /**
  41149. * Summary logging while loading
  41150. */
  41151. static readonly SUMMARY_LOGGING: number;
  41152. /**
  41153. * Detailled logging while loading
  41154. */
  41155. static readonly DETAILED_LOGGING: number;
  41156. /**
  41157. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41158. */
  41159. static ForceFullSceneLoadingForIncremental: boolean;
  41160. /**
  41161. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41162. */
  41163. static ShowLoadingScreen: boolean;
  41164. /**
  41165. * Defines the current logging level (while loading the scene)
  41166. * @ignorenaming
  41167. */
  41168. static loggingLevel: number;
  41169. /**
  41170. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41171. */
  41172. static CleanBoneMatrixWeights: boolean;
  41173. /**
  41174. * Event raised when a plugin is used to load a scene
  41175. */
  41176. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41177. private static _registeredPlugins;
  41178. private static _getDefaultPlugin;
  41179. private static _getPluginForExtension;
  41180. private static _getPluginForDirectLoad;
  41181. private static _getPluginForFilename;
  41182. private static _getDirectLoad;
  41183. private static _loadData;
  41184. private static _getFileInfo;
  41185. /**
  41186. * Gets a plugin that can load the given extension
  41187. * @param extension defines the extension to load
  41188. * @returns a plugin or null if none works
  41189. */
  41190. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41191. /**
  41192. * Gets a boolean indicating that the given extension can be loaded
  41193. * @param extension defines the extension to load
  41194. * @returns true if the extension is supported
  41195. */
  41196. static IsPluginForExtensionAvailable(extension: string): boolean;
  41197. /**
  41198. * Adds a new plugin to the list of registered plugins
  41199. * @param plugin defines the plugin to add
  41200. */
  41201. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41202. /**
  41203. * Import meshes into a scene
  41204. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41205. * @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)
  41206. * @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)
  41207. * @param scene the instance of BABYLON.Scene to append to
  41208. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41209. * @param onProgress a callback with a progress event for each file being loaded
  41210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41211. * @param pluginExtension the extension used to determine the plugin
  41212. * @returns The loaded plugin
  41213. */
  41214. 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>;
  41215. /**
  41216. * Import meshes into a scene
  41217. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41218. * @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)
  41219. * @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)
  41220. * @param scene the instance of BABYLON.Scene to append to
  41221. * @param onProgress a callback with a progress event for each file being loaded
  41222. * @param pluginExtension the extension used to determine the plugin
  41223. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41224. */
  41225. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41226. meshes: AbstractMesh[];
  41227. particleSystems: IParticleSystem[];
  41228. skeletons: Skeleton[];
  41229. animationGroups: AnimationGroup[];
  41230. }>;
  41231. /**
  41232. * Load a scene
  41233. * @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)
  41234. * @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)
  41235. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41236. * @param onSuccess a callback with the scene when import succeeds
  41237. * @param onProgress a callback with a progress event for each file being loaded
  41238. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41239. * @param pluginExtension the extension used to determine the plugin
  41240. * @returns The loaded plugin
  41241. */
  41242. 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>;
  41243. /**
  41244. * Load a scene
  41245. * @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)
  41246. * @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)
  41247. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41248. * @param onProgress a callback with a progress event for each file being loaded
  41249. * @param pluginExtension the extension used to determine the plugin
  41250. * @returns The loaded scene
  41251. */
  41252. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41253. /**
  41254. * Append a scene
  41255. * @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)
  41256. * @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)
  41257. * @param scene is the instance of BABYLON.Scene to append to
  41258. * @param onSuccess a callback with the scene when import succeeds
  41259. * @param onProgress a callback with a progress event for each file being loaded
  41260. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41261. * @param pluginExtension the extension used to determine the plugin
  41262. * @returns The loaded plugin
  41263. */
  41264. 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>;
  41265. /**
  41266. * Append a scene
  41267. * @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)
  41268. * @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)
  41269. * @param scene is the instance of BABYLON.Scene to append to
  41270. * @param onProgress a callback with a progress event for each file being loaded
  41271. * @param pluginExtension the extension used to determine the plugin
  41272. * @returns The given scene
  41273. */
  41274. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41275. /**
  41276. * Load a scene into an asset container
  41277. * @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)
  41278. * @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)
  41279. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41280. * @param onSuccess a callback with the scene when import succeeds
  41281. * @param onProgress a callback with a progress event for each file being loaded
  41282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41283. * @param pluginExtension the extension used to determine the plugin
  41284. * @returns The loaded plugin
  41285. */
  41286. 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>;
  41287. /**
  41288. * Load a scene into an asset container
  41289. * @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)
  41290. * @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)
  41291. * @param scene is the instance of Scene to append to
  41292. * @param onProgress a callback with a progress event for each file being loaded
  41293. * @param pluginExtension the extension used to determine the plugin
  41294. * @returns The loaded asset container
  41295. */
  41296. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41297. }
  41298. }
  41299. declare module BABYLON {
  41300. /**
  41301. * Google Daydream controller
  41302. */
  41303. export class DaydreamController extends WebVRController {
  41304. /**
  41305. * Base Url for the controller model.
  41306. */
  41307. static MODEL_BASE_URL: string;
  41308. /**
  41309. * File name for the controller model.
  41310. */
  41311. static MODEL_FILENAME: string;
  41312. /**
  41313. * Gamepad Id prefix used to identify Daydream Controller.
  41314. */
  41315. static readonly GAMEPAD_ID_PREFIX: string;
  41316. /**
  41317. * Creates a new DaydreamController from a gamepad
  41318. * @param vrGamepad the gamepad that the controller should be created from
  41319. */
  41320. constructor(vrGamepad: any);
  41321. /**
  41322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41323. * @param scene scene in which to add meshes
  41324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41325. */
  41326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41327. /**
  41328. * Called once for each button that changed state since the last frame
  41329. * @param buttonIdx Which button index changed
  41330. * @param state New state of the button
  41331. * @param changes Which properties on the state changed since last frame
  41332. */
  41333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * Gear VR Controller
  41339. */
  41340. export class GearVRController extends WebVRController {
  41341. /**
  41342. * Base Url for the controller model.
  41343. */
  41344. static MODEL_BASE_URL: string;
  41345. /**
  41346. * File name for the controller model.
  41347. */
  41348. static MODEL_FILENAME: string;
  41349. /**
  41350. * Gamepad Id prefix used to identify this controller.
  41351. */
  41352. static readonly GAMEPAD_ID_PREFIX: string;
  41353. private readonly _buttonIndexToObservableNameMap;
  41354. /**
  41355. * Creates a new GearVRController from a gamepad
  41356. * @param vrGamepad the gamepad that the controller should be created from
  41357. */
  41358. constructor(vrGamepad: any);
  41359. /**
  41360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41361. * @param scene scene in which to add meshes
  41362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41363. */
  41364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41365. /**
  41366. * Called once for each button that changed state since the last frame
  41367. * @param buttonIdx Which button index changed
  41368. * @param state New state of the button
  41369. * @param changes Which properties on the state changed since last frame
  41370. */
  41371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41372. }
  41373. }
  41374. declare module BABYLON {
  41375. /**
  41376. * Generic Controller
  41377. */
  41378. export class GenericController extends WebVRController {
  41379. /**
  41380. * Base Url for the controller model.
  41381. */
  41382. static readonly MODEL_BASE_URL: string;
  41383. /**
  41384. * File name for the controller model.
  41385. */
  41386. static readonly MODEL_FILENAME: string;
  41387. /**
  41388. * Creates a new GenericController from a gamepad
  41389. * @param vrGamepad the gamepad that the controller should be created from
  41390. */
  41391. constructor(vrGamepad: any);
  41392. /**
  41393. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41394. * @param scene scene in which to add meshes
  41395. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41396. */
  41397. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41398. /**
  41399. * Called once for each button that changed state since the last frame
  41400. * @param buttonIdx Which button index changed
  41401. * @param state New state of the button
  41402. * @param changes Which properties on the state changed since last frame
  41403. */
  41404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Oculus Touch Controller
  41410. */
  41411. export class OculusTouchController extends WebVRController {
  41412. /**
  41413. * Base Url for the controller model.
  41414. */
  41415. static MODEL_BASE_URL: string;
  41416. /**
  41417. * File name for the left controller model.
  41418. */
  41419. static MODEL_LEFT_FILENAME: string;
  41420. /**
  41421. * File name for the right controller model.
  41422. */
  41423. static MODEL_RIGHT_FILENAME: string;
  41424. /**
  41425. * Fired when the secondary trigger on this controller is modified
  41426. */
  41427. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41428. /**
  41429. * Fired when the thumb rest on this controller is modified
  41430. */
  41431. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41432. /**
  41433. * Creates a new OculusTouchController from a gamepad
  41434. * @param vrGamepad the gamepad that the controller should be created from
  41435. */
  41436. constructor(vrGamepad: any);
  41437. /**
  41438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41439. * @param scene scene in which to add meshes
  41440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41441. */
  41442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41443. /**
  41444. * Fired when the A button on this controller is modified
  41445. */
  41446. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41447. /**
  41448. * Fired when the B button on this controller is modified
  41449. */
  41450. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41451. /**
  41452. * Fired when the X button on this controller is modified
  41453. */
  41454. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41455. /**
  41456. * Fired when the Y button on this controller is modified
  41457. */
  41458. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41459. /**
  41460. * Called once for each button that changed state since the last frame
  41461. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41462. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41463. * 2) secondary trigger (same)
  41464. * 3) A (right) X (left), touch, pressed = value
  41465. * 4) B / Y
  41466. * 5) thumb rest
  41467. * @param buttonIdx Which button index changed
  41468. * @param state New state of the button
  41469. * @param changes Which properties on the state changed since last frame
  41470. */
  41471. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41472. }
  41473. }
  41474. declare module BABYLON {
  41475. /**
  41476. * Vive Controller
  41477. */
  41478. export class ViveController extends WebVRController {
  41479. /**
  41480. * Base Url for the controller model.
  41481. */
  41482. static MODEL_BASE_URL: string;
  41483. /**
  41484. * File name for the controller model.
  41485. */
  41486. static MODEL_FILENAME: string;
  41487. /**
  41488. * Creates a new ViveController from a gamepad
  41489. * @param vrGamepad the gamepad that the controller should be created from
  41490. */
  41491. constructor(vrGamepad: any);
  41492. /**
  41493. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41494. * @param scene scene in which to add meshes
  41495. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41496. */
  41497. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41498. /**
  41499. * Fired when the left button on this controller is modified
  41500. */
  41501. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41502. /**
  41503. * Fired when the right button on this controller is modified
  41504. */
  41505. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41506. /**
  41507. * Fired when the menu button on this controller is modified
  41508. */
  41509. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41510. /**
  41511. * Called once for each button that changed state since the last frame
  41512. * Vive mapping:
  41513. * 0: touchpad
  41514. * 1: trigger
  41515. * 2: left AND right buttons
  41516. * 3: menu button
  41517. * @param buttonIdx Which button index changed
  41518. * @param state New state of the button
  41519. * @param changes Which properties on the state changed since last frame
  41520. */
  41521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41522. }
  41523. }
  41524. declare module BABYLON {
  41525. /**
  41526. * Defines the WindowsMotionController object that the state of the windows motion controller
  41527. */
  41528. export class WindowsMotionController extends WebVRController {
  41529. /**
  41530. * The base url used to load the left and right controller models
  41531. */
  41532. static MODEL_BASE_URL: string;
  41533. /**
  41534. * The name of the left controller model file
  41535. */
  41536. static MODEL_LEFT_FILENAME: string;
  41537. /**
  41538. * The name of the right controller model file
  41539. */
  41540. static MODEL_RIGHT_FILENAME: string;
  41541. /**
  41542. * The controller name prefix for this controller type
  41543. */
  41544. static readonly GAMEPAD_ID_PREFIX: string;
  41545. /**
  41546. * The controller id pattern for this controller type
  41547. */
  41548. private static readonly GAMEPAD_ID_PATTERN;
  41549. private _loadedMeshInfo;
  41550. private readonly _mapping;
  41551. /**
  41552. * Fired when the trackpad on this controller is clicked
  41553. */
  41554. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41555. /**
  41556. * Fired when the trackpad on this controller is modified
  41557. */
  41558. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41559. /**
  41560. * The current x and y values of this controller's trackpad
  41561. */
  41562. trackpad: StickValues;
  41563. /**
  41564. * Creates a new WindowsMotionController from a gamepad
  41565. * @param vrGamepad the gamepad that the controller should be created from
  41566. */
  41567. constructor(vrGamepad: any);
  41568. /**
  41569. * Fired when the trigger on this controller is modified
  41570. */
  41571. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41572. /**
  41573. * Fired when the menu button on this controller is modified
  41574. */
  41575. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41576. /**
  41577. * Fired when the grip button on this controller is modified
  41578. */
  41579. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41580. /**
  41581. * Fired when the thumbstick button on this controller is modified
  41582. */
  41583. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41584. /**
  41585. * Fired when the touchpad button on this controller is modified
  41586. */
  41587. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41588. /**
  41589. * Fired when the touchpad values on this controller are modified
  41590. */
  41591. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41592. private _updateTrackpad;
  41593. /**
  41594. * Called once per frame by the engine.
  41595. */
  41596. update(): void;
  41597. /**
  41598. * Called once for each button that changed state since the last frame
  41599. * @param buttonIdx Which button index changed
  41600. * @param state New state of the button
  41601. * @param changes Which properties on the state changed since last frame
  41602. */
  41603. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41604. /**
  41605. * Moves the buttons on the controller mesh based on their current state
  41606. * @param buttonName the name of the button to move
  41607. * @param buttonValue the value of the button which determines the buttons new position
  41608. */
  41609. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41610. /**
  41611. * Moves the axis on the controller mesh based on its current state
  41612. * @param axis the index of the axis
  41613. * @param axisValue the value of the axis which determines the meshes new position
  41614. * @hidden
  41615. */
  41616. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41617. /**
  41618. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41619. * @param scene scene in which to add meshes
  41620. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41621. */
  41622. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41623. /**
  41624. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41625. * can be transformed by button presses and axes values, based on this._mapping.
  41626. *
  41627. * @param scene scene in which the meshes exist
  41628. * @param meshes list of meshes that make up the controller model to process
  41629. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41630. */
  41631. private processModel;
  41632. private createMeshInfo;
  41633. /**
  41634. * Gets the ray of the controller in the direction the controller is pointing
  41635. * @param length the length the resulting ray should be
  41636. * @returns a ray in the direction the controller is pointing
  41637. */
  41638. getForwardRay(length?: number): Ray;
  41639. /**
  41640. * Disposes of the controller
  41641. */
  41642. dispose(): void;
  41643. }
  41644. }
  41645. declare module BABYLON {
  41646. /**
  41647. * Single axis scale gizmo
  41648. */
  41649. export class AxisScaleGizmo extends Gizmo {
  41650. private _coloredMaterial;
  41651. /**
  41652. * Drag behavior responsible for the gizmos dragging interactions
  41653. */
  41654. dragBehavior: PointerDragBehavior;
  41655. private _pointerObserver;
  41656. /**
  41657. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41658. */
  41659. snapDistance: number;
  41660. /**
  41661. * Event that fires each time the gizmo snaps to a new location.
  41662. * * snapDistance is the the change in distance
  41663. */
  41664. onSnapObservable: Observable<{
  41665. snapDistance: number;
  41666. }>;
  41667. /**
  41668. * If the scaling operation should be done on all axis (default: false)
  41669. */
  41670. uniformScaling: boolean;
  41671. /**
  41672. * Creates an AxisScaleGizmo
  41673. * @param gizmoLayer The utility layer the gizmo will be added to
  41674. * @param dragAxis The axis which the gizmo will be able to scale on
  41675. * @param color The color of the gizmo
  41676. */
  41677. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41679. /**
  41680. * Disposes of the gizmo
  41681. */
  41682. dispose(): void;
  41683. /**
  41684. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41685. * @param mesh The mesh to replace the default mesh of the gizmo
  41686. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41687. */
  41688. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41689. }
  41690. }
  41691. declare module BABYLON {
  41692. /**
  41693. * Bounding box gizmo
  41694. */
  41695. export class BoundingBoxGizmo extends Gizmo {
  41696. private _lineBoundingBox;
  41697. private _rotateSpheresParent;
  41698. private _scaleBoxesParent;
  41699. private _boundingDimensions;
  41700. private _renderObserver;
  41701. private _pointerObserver;
  41702. private _scaleDragSpeed;
  41703. private _tmpQuaternion;
  41704. private _tmpVector;
  41705. private _tmpRotationMatrix;
  41706. /**
  41707. * 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)
  41708. */
  41709. ignoreChildren: boolean;
  41710. /**
  41711. * 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)
  41712. */
  41713. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41714. /**
  41715. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41716. */
  41717. rotationSphereSize: number;
  41718. /**
  41719. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41720. */
  41721. scaleBoxSize: number;
  41722. /**
  41723. * 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)
  41724. */
  41725. fixedDragMeshScreenSize: boolean;
  41726. /**
  41727. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41728. */
  41729. fixedDragMeshScreenSizeDistanceFactor: number;
  41730. /**
  41731. * Fired when a rotation sphere or scale box is dragged
  41732. */
  41733. onDragStartObservable: Observable<{}>;
  41734. /**
  41735. * Fired when a scale box is dragged
  41736. */
  41737. onScaleBoxDragObservable: Observable<{}>;
  41738. /**
  41739. * Fired when a scale box drag is ended
  41740. */
  41741. onScaleBoxDragEndObservable: Observable<{}>;
  41742. /**
  41743. * Fired when a rotation sphere is dragged
  41744. */
  41745. onRotationSphereDragObservable: Observable<{}>;
  41746. /**
  41747. * Fired when a rotation sphere drag is ended
  41748. */
  41749. onRotationSphereDragEndObservable: Observable<{}>;
  41750. /**
  41751. * 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)
  41752. */
  41753. scalePivot: Nullable<Vector3>;
  41754. /**
  41755. * Mesh used as a pivot to rotate the attached mesh
  41756. */
  41757. private _anchorMesh;
  41758. private _existingMeshScale;
  41759. private _dragMesh;
  41760. private pointerDragBehavior;
  41761. private coloredMaterial;
  41762. private hoverColoredMaterial;
  41763. /**
  41764. * Sets the color of the bounding box gizmo
  41765. * @param color the color to set
  41766. */
  41767. setColor(color: Color3): void;
  41768. /**
  41769. * Creates an BoundingBoxGizmo
  41770. * @param gizmoLayer The utility layer the gizmo will be added to
  41771. * @param color The color of the gizmo
  41772. */
  41773. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41774. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41775. private _selectNode;
  41776. /**
  41777. * Updates the bounding box information for the Gizmo
  41778. */
  41779. updateBoundingBox(): void;
  41780. private _updateRotationSpheres;
  41781. private _updateScaleBoxes;
  41782. /**
  41783. * Enables rotation on the specified axis and disables rotation on the others
  41784. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41785. */
  41786. setEnabledRotationAxis(axis: string): void;
  41787. /**
  41788. * Enables/disables scaling
  41789. * @param enable if scaling should be enabled
  41790. */
  41791. setEnabledScaling(enable: boolean): void;
  41792. private _updateDummy;
  41793. /**
  41794. * Enables a pointer drag behavior on the bounding box of the gizmo
  41795. */
  41796. enableDragBehavior(): void;
  41797. /**
  41798. * Disposes of the gizmo
  41799. */
  41800. dispose(): void;
  41801. /**
  41802. * 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)
  41803. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41804. * @returns the bounding box mesh with the passed in mesh as a child
  41805. */
  41806. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41807. /**
  41808. * CustomMeshes are not supported by this gizmo
  41809. * @param mesh The mesh to replace the default mesh of the gizmo
  41810. */
  41811. setCustomMesh(mesh: Mesh): void;
  41812. }
  41813. }
  41814. declare module BABYLON {
  41815. /**
  41816. * Single plane rotation gizmo
  41817. */
  41818. export class PlaneRotationGizmo extends Gizmo {
  41819. /**
  41820. * Drag behavior responsible for the gizmos dragging interactions
  41821. */
  41822. dragBehavior: PointerDragBehavior;
  41823. private _pointerObserver;
  41824. /**
  41825. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41826. */
  41827. snapDistance: number;
  41828. /**
  41829. * Event that fires each time the gizmo snaps to a new location.
  41830. * * snapDistance is the the change in distance
  41831. */
  41832. onSnapObservable: Observable<{
  41833. snapDistance: number;
  41834. }>;
  41835. /**
  41836. * Creates a PlaneRotationGizmo
  41837. * @param gizmoLayer The utility layer the gizmo will be added to
  41838. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41839. * @param color The color of the gizmo
  41840. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41841. */
  41842. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41843. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41844. /**
  41845. * Disposes of the gizmo
  41846. */
  41847. dispose(): void;
  41848. }
  41849. }
  41850. declare module BABYLON {
  41851. /**
  41852. * Gizmo that enables rotating a mesh along 3 axis
  41853. */
  41854. export class RotationGizmo extends Gizmo {
  41855. /**
  41856. * Internal gizmo used for interactions on the x axis
  41857. */
  41858. xGizmo: PlaneRotationGizmo;
  41859. /**
  41860. * Internal gizmo used for interactions on the y axis
  41861. */
  41862. yGizmo: PlaneRotationGizmo;
  41863. /**
  41864. * Internal gizmo used for interactions on the z axis
  41865. */
  41866. zGizmo: PlaneRotationGizmo;
  41867. /** Fires an event when any of it's sub gizmos are dragged */
  41868. onDragStartObservable: Observable<{}>;
  41869. /** Fires an event when any of it's sub gizmos are released from dragging */
  41870. onDragEndObservable: Observable<{}>;
  41871. attachedMesh: Nullable<AbstractMesh>;
  41872. /**
  41873. * Creates a RotationGizmo
  41874. * @param gizmoLayer The utility layer the gizmo will be added to
  41875. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41876. */
  41877. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41878. updateGizmoRotationToMatchAttachedMesh: boolean;
  41879. /**
  41880. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41881. */
  41882. snapDistance: number;
  41883. /**
  41884. * Ratio for the scale of the gizmo (Default: 1)
  41885. */
  41886. scaleRatio: number;
  41887. /**
  41888. * Disposes of the gizmo
  41889. */
  41890. dispose(): void;
  41891. /**
  41892. * CustomMeshes are not supported by this gizmo
  41893. * @param mesh The mesh to replace the default mesh of the gizmo
  41894. */
  41895. setCustomMesh(mesh: Mesh): void;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /**
  41900. * Gizmo that enables dragging a mesh along 3 axis
  41901. */
  41902. export class PositionGizmo extends Gizmo {
  41903. /**
  41904. * Internal gizmo used for interactions on the x axis
  41905. */
  41906. xGizmo: AxisDragGizmo;
  41907. /**
  41908. * Internal gizmo used for interactions on the y axis
  41909. */
  41910. yGizmo: AxisDragGizmo;
  41911. /**
  41912. * Internal gizmo used for interactions on the z axis
  41913. */
  41914. zGizmo: AxisDragGizmo;
  41915. /** Fires an event when any of it's sub gizmos are dragged */
  41916. onDragStartObservable: Observable<{}>;
  41917. /** Fires an event when any of it's sub gizmos are released from dragging */
  41918. onDragEndObservable: Observable<{}>;
  41919. attachedMesh: Nullable<AbstractMesh>;
  41920. /**
  41921. * Creates a PositionGizmo
  41922. * @param gizmoLayer The utility layer the gizmo will be added to
  41923. */
  41924. constructor(gizmoLayer?: UtilityLayerRenderer);
  41925. updateGizmoRotationToMatchAttachedMesh: boolean;
  41926. /**
  41927. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41928. */
  41929. snapDistance: number;
  41930. /**
  41931. * Ratio for the scale of the gizmo (Default: 1)
  41932. */
  41933. scaleRatio: number;
  41934. /**
  41935. * Disposes of the gizmo
  41936. */
  41937. dispose(): void;
  41938. /**
  41939. * CustomMeshes are not supported by this gizmo
  41940. * @param mesh The mesh to replace the default mesh of the gizmo
  41941. */
  41942. setCustomMesh(mesh: Mesh): void;
  41943. }
  41944. }
  41945. declare module BABYLON {
  41946. /**
  41947. * Class containing static functions to help procedurally build meshes
  41948. */
  41949. export class PolyhedronBuilder {
  41950. /**
  41951. * Creates a polyhedron mesh
  41952. * * 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
  41953. * * The parameter `size` (positive float, default 1) sets the polygon size
  41954. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41955. * * 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`
  41956. * * 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
  41957. * * 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)`)
  41958. * * 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
  41959. * * 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
  41960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41961. * * 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
  41962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41963. * @param name defines the name of the mesh
  41964. * @param options defines the options used to create the mesh
  41965. * @param scene defines the hosting scene
  41966. * @returns the polyhedron mesh
  41967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41968. */
  41969. static CreatePolyhedron(name: string, options: {
  41970. type?: number;
  41971. size?: number;
  41972. sizeX?: number;
  41973. sizeY?: number;
  41974. sizeZ?: number;
  41975. custom?: any;
  41976. faceUV?: Vector4[];
  41977. faceColors?: Color4[];
  41978. flat?: boolean;
  41979. updatable?: boolean;
  41980. sideOrientation?: number;
  41981. frontUVs?: Vector4;
  41982. backUVs?: Vector4;
  41983. }, scene?: Nullable<Scene>): Mesh;
  41984. }
  41985. }
  41986. declare module BABYLON {
  41987. /**
  41988. * Gizmo that enables scaling a mesh along 3 axis
  41989. */
  41990. export class ScaleGizmo extends Gizmo {
  41991. /**
  41992. * Internal gizmo used for interactions on the x axis
  41993. */
  41994. xGizmo: AxisScaleGizmo;
  41995. /**
  41996. * Internal gizmo used for interactions on the y axis
  41997. */
  41998. yGizmo: AxisScaleGizmo;
  41999. /**
  42000. * Internal gizmo used for interactions on the z axis
  42001. */
  42002. zGizmo: AxisScaleGizmo;
  42003. /**
  42004. * Internal gizmo used to scale all axis equally
  42005. */
  42006. uniformScaleGizmo: AxisScaleGizmo;
  42007. /** Fires an event when any of it's sub gizmos are dragged */
  42008. onDragStartObservable: Observable<{}>;
  42009. /** Fires an event when any of it's sub gizmos are released from dragging */
  42010. onDragEndObservable: Observable<{}>;
  42011. attachedMesh: Nullable<AbstractMesh>;
  42012. /**
  42013. * Creates a ScaleGizmo
  42014. * @param gizmoLayer The utility layer the gizmo will be added to
  42015. */
  42016. constructor(gizmoLayer?: UtilityLayerRenderer);
  42017. updateGizmoRotationToMatchAttachedMesh: boolean;
  42018. /**
  42019. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42020. */
  42021. snapDistance: number;
  42022. /**
  42023. * Ratio for the scale of the gizmo (Default: 1)
  42024. */
  42025. scaleRatio: number;
  42026. /**
  42027. * Disposes of the gizmo
  42028. */
  42029. dispose(): void;
  42030. }
  42031. }
  42032. declare module BABYLON {
  42033. /**
  42034. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42035. */
  42036. export class GizmoManager implements IDisposable {
  42037. private scene;
  42038. /**
  42039. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42040. */
  42041. gizmos: {
  42042. positionGizmo: Nullable<PositionGizmo>;
  42043. rotationGizmo: Nullable<RotationGizmo>;
  42044. scaleGizmo: Nullable<ScaleGizmo>;
  42045. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42046. };
  42047. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42048. clearGizmoOnEmptyPointerEvent: boolean;
  42049. /** Fires an event when the manager is attached to a mesh */
  42050. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42051. private _gizmosEnabled;
  42052. private _pointerObserver;
  42053. private _attachedMesh;
  42054. private _boundingBoxColor;
  42055. private _defaultUtilityLayer;
  42056. private _defaultKeepDepthUtilityLayer;
  42057. /**
  42058. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42059. */
  42060. boundingBoxDragBehavior: SixDofDragBehavior;
  42061. /**
  42062. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42063. */
  42064. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42065. /**
  42066. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42067. */
  42068. usePointerToAttachGizmos: boolean;
  42069. /**
  42070. * Instatiates a gizmo manager
  42071. * @param scene the scene to overlay the gizmos on top of
  42072. */
  42073. constructor(scene: Scene);
  42074. /**
  42075. * Attaches a set of gizmos to the specified mesh
  42076. * @param mesh The mesh the gizmo's should be attached to
  42077. */
  42078. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42079. /**
  42080. * If the position gizmo is enabled
  42081. */
  42082. positionGizmoEnabled: boolean;
  42083. /**
  42084. * If the rotation gizmo is enabled
  42085. */
  42086. rotationGizmoEnabled: boolean;
  42087. /**
  42088. * If the scale gizmo is enabled
  42089. */
  42090. scaleGizmoEnabled: boolean;
  42091. /**
  42092. * If the boundingBox gizmo is enabled
  42093. */
  42094. boundingBoxGizmoEnabled: boolean;
  42095. /**
  42096. * Disposes of the gizmo manager
  42097. */
  42098. dispose(): void;
  42099. }
  42100. }
  42101. declare module BABYLON {
  42102. /**
  42103. * A directional light is defined by a direction (what a surprise!).
  42104. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42105. * 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.
  42106. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42107. */
  42108. export class DirectionalLight extends ShadowLight {
  42109. private _shadowFrustumSize;
  42110. /**
  42111. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42112. */
  42113. /**
  42114. * Specifies a fix frustum size for the shadow generation.
  42115. */
  42116. shadowFrustumSize: number;
  42117. private _shadowOrthoScale;
  42118. /**
  42119. * Gets the shadow projection scale against the optimal computed one.
  42120. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42121. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42122. */
  42123. /**
  42124. * Sets the shadow projection scale against the optimal computed one.
  42125. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42126. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42127. */
  42128. shadowOrthoScale: number;
  42129. /**
  42130. * Automatically compute the projection matrix to best fit (including all the casters)
  42131. * on each frame.
  42132. */
  42133. autoUpdateExtends: boolean;
  42134. private _orthoLeft;
  42135. private _orthoRight;
  42136. private _orthoTop;
  42137. private _orthoBottom;
  42138. /**
  42139. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42140. * The directional light is emitted from everywhere in the given direction.
  42141. * It can cast shadows.
  42142. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42143. * @param name The friendly name of the light
  42144. * @param direction The direction of the light
  42145. * @param scene The scene the light belongs to
  42146. */
  42147. constructor(name: string, direction: Vector3, scene: Scene);
  42148. /**
  42149. * Returns the string "DirectionalLight".
  42150. * @return The class name
  42151. */
  42152. getClassName(): string;
  42153. /**
  42154. * Returns the integer 1.
  42155. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42156. */
  42157. getTypeID(): number;
  42158. /**
  42159. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42160. * Returns the DirectionalLight Shadow projection matrix.
  42161. */
  42162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42163. /**
  42164. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42165. * Returns the DirectionalLight Shadow projection matrix.
  42166. */
  42167. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42168. /**
  42169. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42170. * Returns the DirectionalLight Shadow projection matrix.
  42171. */
  42172. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42173. protected _buildUniformLayout(): void;
  42174. /**
  42175. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42176. * @param effect The effect to update
  42177. * @param lightIndex The index of the light in the effect to update
  42178. * @returns The directional light
  42179. */
  42180. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42181. /**
  42182. * Gets the minZ used for shadow according to both the scene and the light.
  42183. *
  42184. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42185. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42186. * @param activeCamera The camera we are returning the min for
  42187. * @returns the depth min z
  42188. */
  42189. getDepthMinZ(activeCamera: Camera): number;
  42190. /**
  42191. * Gets the maxZ used for shadow according to both the scene and the light.
  42192. *
  42193. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42194. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42195. * @param activeCamera The camera we are returning the max for
  42196. * @returns the depth max z
  42197. */
  42198. getDepthMaxZ(activeCamera: Camera): number;
  42199. /**
  42200. * Prepares the list of defines specific to the light type.
  42201. * @param defines the list of defines
  42202. * @param lightIndex defines the index of the light for the effect
  42203. */
  42204. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42205. }
  42206. }
  42207. declare module BABYLON {
  42208. /**
  42209. * Class containing static functions to help procedurally build meshes
  42210. */
  42211. export class HemisphereBuilder {
  42212. /**
  42213. * Creates a hemisphere mesh
  42214. * @param name defines the name of the mesh
  42215. * @param options defines the options used to create the mesh
  42216. * @param scene defines the hosting scene
  42217. * @returns the hemisphere mesh
  42218. */
  42219. static CreateHemisphere(name: string, options: {
  42220. segments?: number;
  42221. diameter?: number;
  42222. sideOrientation?: number;
  42223. }, scene: any): Mesh;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42229. * These values define a cone of light starting from the position, emitting toward the direction.
  42230. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42231. * and the exponent defines the speed of the decay of the light with distance (reach).
  42232. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42233. */
  42234. export class SpotLight extends ShadowLight {
  42235. private _angle;
  42236. private _innerAngle;
  42237. private _cosHalfAngle;
  42238. private _lightAngleScale;
  42239. private _lightAngleOffset;
  42240. /**
  42241. * Gets the cone angle of the spot light in Radians.
  42242. */
  42243. /**
  42244. * Sets the cone angle of the spot light in Radians.
  42245. */
  42246. angle: number;
  42247. /**
  42248. * Only used in gltf falloff mode, this defines the angle where
  42249. * the directional falloff will start before cutting at angle which could be seen
  42250. * as outer angle.
  42251. */
  42252. /**
  42253. * Only used in gltf falloff mode, this defines the angle where
  42254. * the directional falloff will start before cutting at angle which could be seen
  42255. * as outer angle.
  42256. */
  42257. innerAngle: number;
  42258. private _shadowAngleScale;
  42259. /**
  42260. * Allows scaling the angle of the light for shadow generation only.
  42261. */
  42262. /**
  42263. * Allows scaling the angle of the light for shadow generation only.
  42264. */
  42265. shadowAngleScale: number;
  42266. /**
  42267. * The light decay speed with the distance from the emission spot.
  42268. */
  42269. exponent: number;
  42270. private _projectionTextureMatrix;
  42271. /**
  42272. * Allows reading the projecton texture
  42273. */
  42274. readonly projectionTextureMatrix: Matrix;
  42275. protected _projectionTextureLightNear: number;
  42276. /**
  42277. * Gets the near clip of the Spotlight for texture projection.
  42278. */
  42279. /**
  42280. * Sets the near clip of the Spotlight for texture projection.
  42281. */
  42282. projectionTextureLightNear: number;
  42283. protected _projectionTextureLightFar: number;
  42284. /**
  42285. * Gets the far clip of the Spotlight for texture projection.
  42286. */
  42287. /**
  42288. * Sets the far clip of the Spotlight for texture projection.
  42289. */
  42290. projectionTextureLightFar: number;
  42291. protected _projectionTextureUpDirection: Vector3;
  42292. /**
  42293. * Gets the Up vector of the Spotlight for texture projection.
  42294. */
  42295. /**
  42296. * Sets the Up vector of the Spotlight for texture projection.
  42297. */
  42298. projectionTextureUpDirection: Vector3;
  42299. private _projectionTexture;
  42300. /**
  42301. * Gets the projection texture of the light.
  42302. */
  42303. /**
  42304. * Sets the projection texture of the light.
  42305. */
  42306. projectionTexture: Nullable<BaseTexture>;
  42307. private _projectionTextureViewLightDirty;
  42308. private _projectionTextureProjectionLightDirty;
  42309. private _projectionTextureDirty;
  42310. private _projectionTextureViewTargetVector;
  42311. private _projectionTextureViewLightMatrix;
  42312. private _projectionTextureProjectionLightMatrix;
  42313. private _projectionTextureScalingMatrix;
  42314. /**
  42315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42316. * It can cast shadows.
  42317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42318. * @param name The light friendly name
  42319. * @param position The position of the spot light in the scene
  42320. * @param direction The direction of the light in the scene
  42321. * @param angle The cone angle of the light in Radians
  42322. * @param exponent The light decay speed with the distance from the emission spot
  42323. * @param scene The scene the lights belongs to
  42324. */
  42325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42326. /**
  42327. * Returns the string "SpotLight".
  42328. * @returns the class name
  42329. */
  42330. getClassName(): string;
  42331. /**
  42332. * Returns the integer 2.
  42333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42334. */
  42335. getTypeID(): number;
  42336. /**
  42337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42338. */
  42339. protected _setDirection(value: Vector3): void;
  42340. /**
  42341. * Overrides the position setter to recompute the projection texture view light Matrix.
  42342. */
  42343. protected _setPosition(value: Vector3): void;
  42344. /**
  42345. * 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.
  42346. * Returns the SpotLight.
  42347. */
  42348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42349. protected _computeProjectionTextureViewLightMatrix(): void;
  42350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42351. /**
  42352. * Main function for light texture projection matrix computing.
  42353. */
  42354. protected _computeProjectionTextureMatrix(): void;
  42355. protected _buildUniformLayout(): void;
  42356. private _computeAngleValues;
  42357. /**
  42358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42359. * @param effect The effect to update
  42360. * @param lightIndex The index of the light in the effect to update
  42361. * @returns The spot light
  42362. */
  42363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42364. /**
  42365. * Disposes the light and the associated resources.
  42366. */
  42367. dispose(): void;
  42368. /**
  42369. * Prepares the list of defines specific to the light type.
  42370. * @param defines the list of defines
  42371. * @param lightIndex defines the index of the light for the effect
  42372. */
  42373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * Gizmo that enables viewing a light
  42379. */
  42380. export class LightGizmo extends Gizmo {
  42381. private _lightMesh;
  42382. private _material;
  42383. /**
  42384. * Creates a LightGizmo
  42385. * @param gizmoLayer The utility layer the gizmo will be added to
  42386. */
  42387. constructor(gizmoLayer?: UtilityLayerRenderer);
  42388. private _light;
  42389. /**
  42390. * The light that the gizmo is attached to
  42391. */
  42392. light: Nullable<Light>;
  42393. /**
  42394. * @hidden
  42395. * Updates the gizmo to match the attached mesh's position/rotation
  42396. */
  42397. protected _update(): void;
  42398. private static _Scale;
  42399. /**
  42400. * Creates the lines for a light mesh
  42401. */
  42402. private static _createLightLines;
  42403. private static _CreateHemisphericLightMesh;
  42404. private static _CreatePointLightMesh;
  42405. private static _CreateSpotLightMesh;
  42406. private static _CreateDirectionalLightMesh;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /** @hidden */
  42411. export var backgroundFragmentDeclaration: {
  42412. name: string;
  42413. shader: string;
  42414. };
  42415. }
  42416. declare module BABYLON {
  42417. /** @hidden */
  42418. export var backgroundUboDeclaration: {
  42419. name: string;
  42420. shader: string;
  42421. };
  42422. }
  42423. declare module BABYLON {
  42424. /** @hidden */
  42425. export var backgroundPixelShader: {
  42426. name: string;
  42427. shader: string;
  42428. };
  42429. }
  42430. declare module BABYLON {
  42431. /** @hidden */
  42432. export var backgroundVertexDeclaration: {
  42433. name: string;
  42434. shader: string;
  42435. };
  42436. }
  42437. declare module BABYLON {
  42438. /** @hidden */
  42439. export var backgroundVertexShader: {
  42440. name: string;
  42441. shader: string;
  42442. };
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Background material used to create an efficient environement around your scene.
  42447. */
  42448. export class BackgroundMaterial extends PushMaterial {
  42449. /**
  42450. * Standard reflectance value at parallel view angle.
  42451. */
  42452. static StandardReflectance0: number;
  42453. /**
  42454. * Standard reflectance value at grazing angle.
  42455. */
  42456. static StandardReflectance90: number;
  42457. protected _primaryColor: Color3;
  42458. /**
  42459. * Key light Color (multiply against the environement texture)
  42460. */
  42461. primaryColor: Color3;
  42462. protected __perceptualColor: Nullable<Color3>;
  42463. /**
  42464. * Experimental Internal Use Only.
  42465. *
  42466. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42467. * This acts as a helper to set the primary color to a more "human friendly" value.
  42468. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42469. * output color as close as possible from the chosen value.
  42470. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42471. * part of lighting setup.)
  42472. */ perceptualColor: Nullable<Color3>;
  42473. protected _primaryColorShadowLevel: float;
  42474. /**
  42475. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42476. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42477. */
  42478. primaryColorShadowLevel: float;
  42479. protected _primaryColorHighlightLevel: float;
  42480. /**
  42481. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42482. * The primary color is used at the level chosen to define what the white area would look.
  42483. */
  42484. primaryColorHighlightLevel: float;
  42485. protected _reflectionTexture: Nullable<BaseTexture>;
  42486. /**
  42487. * Reflection Texture used in the material.
  42488. * Should be author in a specific way for the best result (refer to the documentation).
  42489. */
  42490. reflectionTexture: Nullable<BaseTexture>;
  42491. protected _reflectionBlur: float;
  42492. /**
  42493. * Reflection Texture level of blur.
  42494. *
  42495. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42496. * texture twice.
  42497. */
  42498. reflectionBlur: float;
  42499. protected _diffuseTexture: Nullable<BaseTexture>;
  42500. /**
  42501. * Diffuse Texture used in the material.
  42502. * Should be author in a specific way for the best result (refer to the documentation).
  42503. */
  42504. diffuseTexture: Nullable<BaseTexture>;
  42505. protected _shadowLights: Nullable<IShadowLight[]>;
  42506. /**
  42507. * Specify the list of lights casting shadow on the material.
  42508. * All scene shadow lights will be included if null.
  42509. */
  42510. shadowLights: Nullable<IShadowLight[]>;
  42511. protected _shadowLevel: float;
  42512. /**
  42513. * Helps adjusting the shadow to a softer level if required.
  42514. * 0 means black shadows and 1 means no shadows.
  42515. */
  42516. shadowLevel: float;
  42517. protected _sceneCenter: Vector3;
  42518. /**
  42519. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42520. * It is usually zero but might be interesting to modify according to your setup.
  42521. */
  42522. sceneCenter: Vector3;
  42523. protected _opacityFresnel: boolean;
  42524. /**
  42525. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42526. * This helps ensuring a nice transition when the camera goes under the ground.
  42527. */
  42528. opacityFresnel: boolean;
  42529. protected _reflectionFresnel: boolean;
  42530. /**
  42531. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42532. * This helps adding a mirror texture on the ground.
  42533. */
  42534. reflectionFresnel: boolean;
  42535. protected _reflectionFalloffDistance: number;
  42536. /**
  42537. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42538. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42539. */
  42540. reflectionFalloffDistance: number;
  42541. protected _reflectionAmount: number;
  42542. /**
  42543. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42544. */
  42545. reflectionAmount: number;
  42546. protected _reflectionReflectance0: number;
  42547. /**
  42548. * This specifies the weight of the reflection at grazing angle.
  42549. */
  42550. reflectionReflectance0: number;
  42551. protected _reflectionReflectance90: number;
  42552. /**
  42553. * This specifies the weight of the reflection at a perpendicular point of view.
  42554. */
  42555. reflectionReflectance90: number;
  42556. /**
  42557. * Sets the reflection reflectance fresnel values according to the default standard
  42558. * empirically know to work well :-)
  42559. */
  42560. reflectionStandardFresnelWeight: number;
  42561. protected _useRGBColor: boolean;
  42562. /**
  42563. * Helps to directly use the maps channels instead of their level.
  42564. */
  42565. useRGBColor: boolean;
  42566. protected _enableNoise: boolean;
  42567. /**
  42568. * This helps reducing the banding effect that could occur on the background.
  42569. */
  42570. enableNoise: boolean;
  42571. /**
  42572. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42573. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42574. * Recommended to be keep at 1.0 except for special cases.
  42575. */
  42576. fovMultiplier: number;
  42577. private _fovMultiplier;
  42578. /**
  42579. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42580. */
  42581. useEquirectangularFOV: boolean;
  42582. private _maxSimultaneousLights;
  42583. /**
  42584. * Number of Simultaneous lights allowed on the material.
  42585. */
  42586. maxSimultaneousLights: int;
  42587. /**
  42588. * Default configuration related to image processing available in the Background Material.
  42589. */
  42590. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42591. /**
  42592. * Keep track of the image processing observer to allow dispose and replace.
  42593. */
  42594. private _imageProcessingObserver;
  42595. /**
  42596. * Attaches a new image processing configuration to the PBR Material.
  42597. * @param configuration (if null the scene configuration will be use)
  42598. */
  42599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42600. /**
  42601. * Gets the image processing configuration used either in this material.
  42602. */
  42603. /**
  42604. * Sets the Default image processing configuration used either in the this material.
  42605. *
  42606. * If sets to null, the scene one is in use.
  42607. */
  42608. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42609. /**
  42610. * Gets wether the color curves effect is enabled.
  42611. */
  42612. /**
  42613. * Sets wether the color curves effect is enabled.
  42614. */
  42615. cameraColorCurvesEnabled: boolean;
  42616. /**
  42617. * Gets wether the color grading effect is enabled.
  42618. */
  42619. /**
  42620. * Gets wether the color grading effect is enabled.
  42621. */
  42622. cameraColorGradingEnabled: boolean;
  42623. /**
  42624. * Gets wether tonemapping is enabled or not.
  42625. */
  42626. /**
  42627. * Sets wether tonemapping is enabled or not
  42628. */
  42629. cameraToneMappingEnabled: boolean;
  42630. /**
  42631. * The camera exposure used on this material.
  42632. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42633. * This corresponds to a photographic exposure.
  42634. */
  42635. /**
  42636. * The camera exposure used on this material.
  42637. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42638. * This corresponds to a photographic exposure.
  42639. */
  42640. cameraExposure: float;
  42641. /**
  42642. * Gets The camera contrast used on this material.
  42643. */
  42644. /**
  42645. * Sets The camera contrast used on this material.
  42646. */
  42647. cameraContrast: float;
  42648. /**
  42649. * Gets the Color Grading 2D Lookup Texture.
  42650. */
  42651. /**
  42652. * Sets the Color Grading 2D Lookup Texture.
  42653. */
  42654. cameraColorGradingTexture: Nullable<BaseTexture>;
  42655. /**
  42656. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42657. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42658. * 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;
  42659. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42660. */
  42661. /**
  42662. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42663. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42664. * 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;
  42665. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42666. */
  42667. cameraColorCurves: Nullable<ColorCurves>;
  42668. /**
  42669. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42670. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42671. */
  42672. switchToBGR: boolean;
  42673. private _renderTargets;
  42674. private _reflectionControls;
  42675. private _white;
  42676. private _primaryShadowColor;
  42677. private _primaryHighlightColor;
  42678. /**
  42679. * Instantiates a Background Material in the given scene
  42680. * @param name The friendly name of the material
  42681. * @param scene The scene to add the material to
  42682. */
  42683. constructor(name: string, scene: Scene);
  42684. /**
  42685. * Gets a boolean indicating that current material needs to register RTT
  42686. */
  42687. readonly hasRenderTargetTextures: boolean;
  42688. /**
  42689. * The entire material has been created in order to prevent overdraw.
  42690. * @returns false
  42691. */
  42692. needAlphaTesting(): boolean;
  42693. /**
  42694. * The entire material has been created in order to prevent overdraw.
  42695. * @returns true if blending is enable
  42696. */
  42697. needAlphaBlending(): boolean;
  42698. /**
  42699. * Checks wether the material is ready to be rendered for a given mesh.
  42700. * @param mesh The mesh to render
  42701. * @param subMesh The submesh to check against
  42702. * @param useInstances Specify wether or not the material is used with instances
  42703. * @returns true if all the dependencies are ready (Textures, Effects...)
  42704. */
  42705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42706. /**
  42707. * Compute the primary color according to the chosen perceptual color.
  42708. */
  42709. private _computePrimaryColorFromPerceptualColor;
  42710. /**
  42711. * Compute the highlights and shadow colors according to their chosen levels.
  42712. */
  42713. private _computePrimaryColors;
  42714. /**
  42715. * Build the uniform buffer used in the material.
  42716. */
  42717. buildUniformLayout(): void;
  42718. /**
  42719. * Unbind the material.
  42720. */
  42721. unbind(): void;
  42722. /**
  42723. * Bind only the world matrix to the material.
  42724. * @param world The world matrix to bind.
  42725. */
  42726. bindOnlyWorldMatrix(world: Matrix): void;
  42727. /**
  42728. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42729. * @param world The world matrix to bind.
  42730. * @param subMesh The submesh to bind for.
  42731. */
  42732. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42733. /**
  42734. * Dispose the material.
  42735. * @param forceDisposeEffect Force disposal of the associated effect.
  42736. * @param forceDisposeTextures Force disposal of the associated textures.
  42737. */
  42738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42739. /**
  42740. * Clones the material.
  42741. * @param name The cloned name.
  42742. * @returns The cloned material.
  42743. */
  42744. clone(name: string): BackgroundMaterial;
  42745. /**
  42746. * Serializes the current material to its JSON representation.
  42747. * @returns The JSON representation.
  42748. */
  42749. serialize(): any;
  42750. /**
  42751. * Gets the class name of the material
  42752. * @returns "BackgroundMaterial"
  42753. */
  42754. getClassName(): string;
  42755. /**
  42756. * Parse a JSON input to create back a background material.
  42757. * @param source The JSON data to parse
  42758. * @param scene The scene to create the parsed material in
  42759. * @param rootUrl The root url of the assets the material depends upon
  42760. * @returns the instantiated BackgroundMaterial.
  42761. */
  42762. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * Represents the different options available during the creation of
  42768. * a Environment helper.
  42769. *
  42770. * This can control the default ground, skybox and image processing setup of your scene.
  42771. */
  42772. export interface IEnvironmentHelperOptions {
  42773. /**
  42774. * Specifies wether or not to create a ground.
  42775. * True by default.
  42776. */
  42777. createGround: boolean;
  42778. /**
  42779. * Specifies the ground size.
  42780. * 15 by default.
  42781. */
  42782. groundSize: number;
  42783. /**
  42784. * The texture used on the ground for the main color.
  42785. * Comes from the BabylonJS CDN by default.
  42786. *
  42787. * Remarks: Can be either a texture or a url.
  42788. */
  42789. groundTexture: string | BaseTexture;
  42790. /**
  42791. * The color mixed in the ground texture by default.
  42792. * BabylonJS clearColor by default.
  42793. */
  42794. groundColor: Color3;
  42795. /**
  42796. * Specifies the ground opacity.
  42797. * 1 by default.
  42798. */
  42799. groundOpacity: number;
  42800. /**
  42801. * Enables the ground to receive shadows.
  42802. * True by default.
  42803. */
  42804. enableGroundShadow: boolean;
  42805. /**
  42806. * Helps preventing the shadow to be fully black on the ground.
  42807. * 0.5 by default.
  42808. */
  42809. groundShadowLevel: number;
  42810. /**
  42811. * Creates a mirror texture attach to the ground.
  42812. * false by default.
  42813. */
  42814. enableGroundMirror: boolean;
  42815. /**
  42816. * Specifies the ground mirror size ratio.
  42817. * 0.3 by default as the default kernel is 64.
  42818. */
  42819. groundMirrorSizeRatio: number;
  42820. /**
  42821. * Specifies the ground mirror blur kernel size.
  42822. * 64 by default.
  42823. */
  42824. groundMirrorBlurKernel: number;
  42825. /**
  42826. * Specifies the ground mirror visibility amount.
  42827. * 1 by default
  42828. */
  42829. groundMirrorAmount: number;
  42830. /**
  42831. * Specifies the ground mirror reflectance weight.
  42832. * This uses the standard weight of the background material to setup the fresnel effect
  42833. * of the mirror.
  42834. * 1 by default.
  42835. */
  42836. groundMirrorFresnelWeight: number;
  42837. /**
  42838. * Specifies the ground mirror Falloff distance.
  42839. * This can helps reducing the size of the reflection.
  42840. * 0 by Default.
  42841. */
  42842. groundMirrorFallOffDistance: number;
  42843. /**
  42844. * Specifies the ground mirror texture type.
  42845. * Unsigned Int by Default.
  42846. */
  42847. groundMirrorTextureType: number;
  42848. /**
  42849. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42850. * the shown objects.
  42851. */
  42852. groundYBias: number;
  42853. /**
  42854. * Specifies wether or not to create a skybox.
  42855. * True by default.
  42856. */
  42857. createSkybox: boolean;
  42858. /**
  42859. * Specifies the skybox size.
  42860. * 20 by default.
  42861. */
  42862. skyboxSize: number;
  42863. /**
  42864. * The texture used on the skybox for the main color.
  42865. * Comes from the BabylonJS CDN by default.
  42866. *
  42867. * Remarks: Can be either a texture or a url.
  42868. */
  42869. skyboxTexture: string | BaseTexture;
  42870. /**
  42871. * The color mixed in the skybox texture by default.
  42872. * BabylonJS clearColor by default.
  42873. */
  42874. skyboxColor: Color3;
  42875. /**
  42876. * The background rotation around the Y axis of the scene.
  42877. * This helps aligning the key lights of your scene with the background.
  42878. * 0 by default.
  42879. */
  42880. backgroundYRotation: number;
  42881. /**
  42882. * Compute automatically the size of the elements to best fit with the scene.
  42883. */
  42884. sizeAuto: boolean;
  42885. /**
  42886. * Default position of the rootMesh if autoSize is not true.
  42887. */
  42888. rootPosition: Vector3;
  42889. /**
  42890. * Sets up the image processing in the scene.
  42891. * true by default.
  42892. */
  42893. setupImageProcessing: boolean;
  42894. /**
  42895. * The texture used as your environment texture in the scene.
  42896. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42897. *
  42898. * Remarks: Can be either a texture or a url.
  42899. */
  42900. environmentTexture: string | BaseTexture;
  42901. /**
  42902. * The value of the exposure to apply to the scene.
  42903. * 0.6 by default if setupImageProcessing is true.
  42904. */
  42905. cameraExposure: number;
  42906. /**
  42907. * The value of the contrast to apply to the scene.
  42908. * 1.6 by default if setupImageProcessing is true.
  42909. */
  42910. cameraContrast: number;
  42911. /**
  42912. * Specifies wether or not tonemapping should be enabled in the scene.
  42913. * true by default if setupImageProcessing is true.
  42914. */
  42915. toneMappingEnabled: boolean;
  42916. }
  42917. /**
  42918. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42919. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42920. * It also helps with the default setup of your imageProcessing configuration.
  42921. */
  42922. export class EnvironmentHelper {
  42923. /**
  42924. * Default ground texture URL.
  42925. */
  42926. private static _groundTextureCDNUrl;
  42927. /**
  42928. * Default skybox texture URL.
  42929. */
  42930. private static _skyboxTextureCDNUrl;
  42931. /**
  42932. * Default environment texture URL.
  42933. */
  42934. private static _environmentTextureCDNUrl;
  42935. /**
  42936. * Creates the default options for the helper.
  42937. */
  42938. private static _getDefaultOptions;
  42939. private _rootMesh;
  42940. /**
  42941. * Gets the root mesh created by the helper.
  42942. */
  42943. readonly rootMesh: Mesh;
  42944. private _skybox;
  42945. /**
  42946. * Gets the skybox created by the helper.
  42947. */
  42948. readonly skybox: Nullable<Mesh>;
  42949. private _skyboxTexture;
  42950. /**
  42951. * Gets the skybox texture created by the helper.
  42952. */
  42953. readonly skyboxTexture: Nullable<BaseTexture>;
  42954. private _skyboxMaterial;
  42955. /**
  42956. * Gets the skybox material created by the helper.
  42957. */
  42958. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42959. private _ground;
  42960. /**
  42961. * Gets the ground mesh created by the helper.
  42962. */
  42963. readonly ground: Nullable<Mesh>;
  42964. private _groundTexture;
  42965. /**
  42966. * Gets the ground texture created by the helper.
  42967. */
  42968. readonly groundTexture: Nullable<BaseTexture>;
  42969. private _groundMirror;
  42970. /**
  42971. * Gets the ground mirror created by the helper.
  42972. */
  42973. readonly groundMirror: Nullable<MirrorTexture>;
  42974. /**
  42975. * Gets the ground mirror render list to helps pushing the meshes
  42976. * you wish in the ground reflection.
  42977. */
  42978. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42979. private _groundMaterial;
  42980. /**
  42981. * Gets the ground material created by the helper.
  42982. */
  42983. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42984. /**
  42985. * Stores the creation options.
  42986. */
  42987. private readonly _scene;
  42988. private _options;
  42989. /**
  42990. * This observable will be notified with any error during the creation of the environment,
  42991. * mainly texture creation errors.
  42992. */
  42993. onErrorObservable: Observable<{
  42994. message?: string;
  42995. exception?: any;
  42996. }>;
  42997. /**
  42998. * constructor
  42999. * @param options Defines the options we want to customize the helper
  43000. * @param scene The scene to add the material to
  43001. */
  43002. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43003. /**
  43004. * Updates the background according to the new options
  43005. * @param options
  43006. */
  43007. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43008. /**
  43009. * Sets the primary color of all the available elements.
  43010. * @param color the main color to affect to the ground and the background
  43011. */
  43012. setMainColor(color: Color3): void;
  43013. /**
  43014. * Setup the image processing according to the specified options.
  43015. */
  43016. private _setupImageProcessing;
  43017. /**
  43018. * Setup the environment texture according to the specified options.
  43019. */
  43020. private _setupEnvironmentTexture;
  43021. /**
  43022. * Setup the background according to the specified options.
  43023. */
  43024. private _setupBackground;
  43025. /**
  43026. * Get the scene sizes according to the setup.
  43027. */
  43028. private _getSceneSize;
  43029. /**
  43030. * Setup the ground according to the specified options.
  43031. */
  43032. private _setupGround;
  43033. /**
  43034. * Setup the ground material according to the specified options.
  43035. */
  43036. private _setupGroundMaterial;
  43037. /**
  43038. * Setup the ground diffuse texture according to the specified options.
  43039. */
  43040. private _setupGroundDiffuseTexture;
  43041. /**
  43042. * Setup the ground mirror texture according to the specified options.
  43043. */
  43044. private _setupGroundMirrorTexture;
  43045. /**
  43046. * Setup the ground to receive the mirror texture.
  43047. */
  43048. private _setupMirrorInGroundMaterial;
  43049. /**
  43050. * Setup the skybox according to the specified options.
  43051. */
  43052. private _setupSkybox;
  43053. /**
  43054. * Setup the skybox material according to the specified options.
  43055. */
  43056. private _setupSkyboxMaterial;
  43057. /**
  43058. * Setup the skybox reflection texture according to the specified options.
  43059. */
  43060. private _setupSkyboxReflectionTexture;
  43061. private _errorHandler;
  43062. /**
  43063. * Dispose all the elements created by the Helper.
  43064. */
  43065. dispose(): void;
  43066. }
  43067. }
  43068. declare module BABYLON {
  43069. /**
  43070. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43071. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43072. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43073. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43074. */
  43075. export class PhotoDome extends TransformNode {
  43076. private _useDirectMapping;
  43077. /**
  43078. * The texture being displayed on the sphere
  43079. */
  43080. protected _photoTexture: Texture;
  43081. /**
  43082. * Gets or sets the texture being displayed on the sphere
  43083. */
  43084. photoTexture: Texture;
  43085. /**
  43086. * Observable raised when an error occured while loading the 360 image
  43087. */
  43088. onLoadErrorObservable: Observable<string>;
  43089. /**
  43090. * The skybox material
  43091. */
  43092. protected _material: BackgroundMaterial;
  43093. /**
  43094. * The surface used for the skybox
  43095. */
  43096. protected _mesh: Mesh;
  43097. /**
  43098. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43099. * Also see the options.resolution property.
  43100. */
  43101. fovMultiplier: number;
  43102. /**
  43103. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43104. * @param name Element's name, child elements will append suffixes for their own names.
  43105. * @param urlsOfPhoto defines the url of the photo to display
  43106. * @param options defines an object containing optional or exposed sub element properties
  43107. * @param onError defines a callback called when an error occured while loading the texture
  43108. */
  43109. constructor(name: string, urlOfPhoto: string, options: {
  43110. resolution?: number;
  43111. size?: number;
  43112. useDirectMapping?: boolean;
  43113. faceForward?: boolean;
  43114. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43115. /**
  43116. * Releases resources associated with this node.
  43117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43119. */
  43120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43121. }
  43122. }
  43123. declare module BABYLON {
  43124. /** @hidden */
  43125. export var rgbdDecodePixelShader: {
  43126. name: string;
  43127. shader: string;
  43128. };
  43129. }
  43130. declare module BABYLON {
  43131. /**
  43132. * Class used to host texture specific utilities
  43133. */
  43134. export class BRDFTextureTools {
  43135. /**
  43136. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43137. * @param texture the texture to expand.
  43138. */
  43139. private static _ExpandDefaultBRDFTexture;
  43140. /**
  43141. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43142. * @param scene defines the hosting scene
  43143. * @returns the environment BRDF texture
  43144. */
  43145. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43146. private static _environmentBRDFBase64Texture;
  43147. }
  43148. }
  43149. declare module BABYLON {
  43150. /**
  43151. * @hidden
  43152. */
  43153. export interface IMaterialClearCoatDefines {
  43154. CLEARCOAT: boolean;
  43155. CLEARCOAT_DEFAULTIOR: boolean;
  43156. CLEARCOAT_TEXTURE: boolean;
  43157. CLEARCOAT_TEXTUREDIRECTUV: number;
  43158. CLEARCOAT_BUMP: boolean;
  43159. CLEARCOAT_BUMPDIRECTUV: number;
  43160. CLEARCOAT_TINT: boolean;
  43161. CLEARCOAT_TINT_TEXTURE: boolean;
  43162. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43163. /** @hidden */ areTexturesDirty: boolean;
  43164. }
  43165. /**
  43166. * Define the code related to the clear coat parameters of the pbr material.
  43167. */
  43168. export class PBRClearCoatConfiguration {
  43169. /**
  43170. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43171. * The default fits with a polyurethane material.
  43172. */
  43173. private static readonly _DefaultIndiceOfRefraction;
  43174. private _isEnabled;
  43175. /**
  43176. * Defines if the clear coat is enabled in the material.
  43177. */
  43178. isEnabled: boolean;
  43179. /**
  43180. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43181. */
  43182. intensity: number;
  43183. /**
  43184. * Defines the clear coat layer roughness.
  43185. */
  43186. roughness: number;
  43187. private _indiceOfRefraction;
  43188. /**
  43189. * Defines the indice of refraction of the clear coat.
  43190. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43191. * The default fits with a polyurethane material.
  43192. * Changing the default value is more performance intensive.
  43193. */
  43194. indiceOfRefraction: number;
  43195. private _texture;
  43196. /**
  43197. * Stores the clear coat values in a texture.
  43198. */
  43199. texture: Nullable<BaseTexture>;
  43200. private _bumpTexture;
  43201. /**
  43202. * Define the clear coat specific bump texture.
  43203. */
  43204. bumpTexture: Nullable<BaseTexture>;
  43205. private _isTintEnabled;
  43206. /**
  43207. * Defines if the clear coat tint is enabled in the material.
  43208. */
  43209. isTintEnabled: boolean;
  43210. /**
  43211. * Defines the clear coat tint of the material.
  43212. * This is only use if tint is enabled
  43213. */
  43214. tintColor: Color3;
  43215. /**
  43216. * Defines the distance at which the tint color should be found in the
  43217. * clear coat media.
  43218. * This is only use if tint is enabled
  43219. */
  43220. tintColorAtDistance: number;
  43221. /**
  43222. * Defines the clear coat layer thickness.
  43223. * This is only use if tint is enabled
  43224. */
  43225. tintThickness: number;
  43226. private _tintTexture;
  43227. /**
  43228. * Stores the clear tint values in a texture.
  43229. * rgb is tint
  43230. * a is a thickness factor
  43231. */
  43232. tintTexture: Nullable<BaseTexture>;
  43233. /** @hidden */
  43234. private _internalMarkAllSubMeshesAsTexturesDirty;
  43235. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43236. /**
  43237. * Instantiate a new istance of clear coat configuration.
  43238. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43239. */
  43240. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43241. /**
  43242. * Gets wehter the submesh is ready to be used or not.
  43243. * @param defines the list of "defines" to update.
  43244. * @param scene defines the scene the material belongs to.
  43245. * @param engine defines the engine the material belongs to.
  43246. * @param disableBumpMap defines wether the material disables bump or not.
  43247. * @returns - boolean indicating that the submesh is ready or not.
  43248. */
  43249. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43250. /**
  43251. * Checks to see if a texture is used in the material.
  43252. * @param defines the list of "defines" to update.
  43253. * @param scene defines the scene to the material belongs to.
  43254. */
  43255. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43256. /**
  43257. * Binds the material data.
  43258. * @param uniformBuffer defines the Uniform buffer to fill in.
  43259. * @param scene defines the scene the material belongs to.
  43260. * @param engine defines the engine the material belongs to.
  43261. * @param disableBumpMap defines wether the material disables bump or not.
  43262. * @param isFrozen defines wether the material is frozen or not.
  43263. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43264. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43265. */
  43266. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43267. /**
  43268. * Checks to see if a texture is used in the material.
  43269. * @param texture - Base texture to use.
  43270. * @returns - Boolean specifying if a texture is used in the material.
  43271. */
  43272. hasTexture(texture: BaseTexture): boolean;
  43273. /**
  43274. * Returns an array of the actively used textures.
  43275. * @param activeTextures Array of BaseTextures
  43276. */
  43277. getActiveTextures(activeTextures: BaseTexture[]): void;
  43278. /**
  43279. * Returns the animatable textures.
  43280. * @param animatables Array of animatable textures.
  43281. */
  43282. getAnimatables(animatables: IAnimatable[]): void;
  43283. /**
  43284. * Disposes the resources of the material.
  43285. * @param forceDisposeTextures - Forces the disposal of all textures.
  43286. */
  43287. dispose(forceDisposeTextures?: boolean): void;
  43288. /**
  43289. * Get the current class name of the texture useful for serialization or dynamic coding.
  43290. * @returns "PBRClearCoatConfiguration"
  43291. */
  43292. getClassName(): string;
  43293. /**
  43294. * Add fallbacks to the effect fallbacks list.
  43295. * @param defines defines the Base texture to use.
  43296. * @param fallbacks defines the current fallback list.
  43297. * @param currentRank defines the current fallback rank.
  43298. * @returns the new fallback rank.
  43299. */
  43300. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43301. /**
  43302. * Add the required uniforms to the current list.
  43303. * @param uniforms defines the current uniform list.
  43304. */
  43305. static AddUniforms(uniforms: string[]): void;
  43306. /**
  43307. * Add the required samplers to the current list.
  43308. * @param samplers defines the current sampler list.
  43309. */
  43310. static AddSamplers(samplers: string[]): void;
  43311. /**
  43312. * Add the required uniforms to the current buffer.
  43313. * @param uniformBuffer defines the current uniform buffer.
  43314. */
  43315. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43316. /**
  43317. * Makes a duplicate of the current configuration into another one.
  43318. * @param clearCoatConfiguration define the config where to copy the info
  43319. */
  43320. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43321. /**
  43322. * Serializes this clear coat configuration.
  43323. * @returns - An object with the serialized config.
  43324. */
  43325. serialize(): any;
  43326. /**
  43327. * Parses a Clear Coat Configuration from a serialized object.
  43328. * @param source - Serialized object.
  43329. */
  43330. parse(source: any): void;
  43331. }
  43332. }
  43333. declare module BABYLON {
  43334. /**
  43335. * @hidden
  43336. */
  43337. export interface IMaterialAnisotropicDefines {
  43338. ANISOTROPIC: boolean;
  43339. ANISOTROPIC_TEXTURE: boolean;
  43340. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43341. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43342. }
  43343. /**
  43344. * Define the code related to the anisotropic parameters of the pbr material.
  43345. */
  43346. export class PBRAnisotropicConfiguration {
  43347. private _isEnabled;
  43348. /**
  43349. * Defines if the anisotropy is enabled in the material.
  43350. */
  43351. isEnabled: boolean;
  43352. /**
  43353. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43354. */
  43355. intensity: number;
  43356. /**
  43357. * Defines if the effect is along the tangents, bitangents or in between.
  43358. * By default, the effect is "strectching" the highlights along the tangents.
  43359. */
  43360. direction: Vector2;
  43361. private _texture;
  43362. /**
  43363. * Stores the anisotropy values in a texture.
  43364. * rg is direction (like normal from -1 to 1)
  43365. * b is a intensity
  43366. */
  43367. texture: Nullable<BaseTexture>;
  43368. /** @hidden */
  43369. private _internalMarkAllSubMeshesAsTexturesDirty;
  43370. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43371. /**
  43372. * Instantiate a new istance of anisotropy configuration.
  43373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43374. */
  43375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43376. /**
  43377. * Specifies that the submesh is ready to be used.
  43378. * @param defines the list of "defines" to update.
  43379. * @param scene defines the scene the material belongs to.
  43380. * @returns - boolean indicating that the submesh is ready or not.
  43381. */
  43382. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43383. /**
  43384. * Checks to see if a texture is used in the material.
  43385. * @param defines the list of "defines" to update.
  43386. * @param mesh the mesh we are preparing the defines for.
  43387. * @param scene defines the scene the material belongs to.
  43388. */
  43389. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43390. /**
  43391. * Binds the material data.
  43392. * @param uniformBuffer defines the Uniform buffer to fill in.
  43393. * @param scene defines the scene the material belongs to.
  43394. * @param isFrozen defines wether the material is frozen or not.
  43395. */
  43396. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43397. /**
  43398. * Checks to see if a texture is used in the material.
  43399. * @param texture - Base texture to use.
  43400. * @returns - Boolean specifying if a texture is used in the material.
  43401. */
  43402. hasTexture(texture: BaseTexture): boolean;
  43403. /**
  43404. * Returns an array of the actively used textures.
  43405. * @param activeTextures Array of BaseTextures
  43406. */
  43407. getActiveTextures(activeTextures: BaseTexture[]): void;
  43408. /**
  43409. * Returns the animatable textures.
  43410. * @param animatables Array of animatable textures.
  43411. */
  43412. getAnimatables(animatables: IAnimatable[]): void;
  43413. /**
  43414. * Disposes the resources of the material.
  43415. * @param forceDisposeTextures - Forces the disposal of all textures.
  43416. */
  43417. dispose(forceDisposeTextures?: boolean): void;
  43418. /**
  43419. * Get the current class name of the texture useful for serialization or dynamic coding.
  43420. * @returns "PBRAnisotropicConfiguration"
  43421. */
  43422. getClassName(): string;
  43423. /**
  43424. * Add fallbacks to the effect fallbacks list.
  43425. * @param defines defines the Base texture to use.
  43426. * @param fallbacks defines the current fallback list.
  43427. * @param currentRank defines the current fallback rank.
  43428. * @returns the new fallback rank.
  43429. */
  43430. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43431. /**
  43432. * Add the required uniforms to the current list.
  43433. * @param uniforms defines the current uniform list.
  43434. */
  43435. static AddUniforms(uniforms: string[]): void;
  43436. /**
  43437. * Add the required uniforms to the current buffer.
  43438. * @param uniformBuffer defines the current uniform buffer.
  43439. */
  43440. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43441. /**
  43442. * Add the required samplers to the current list.
  43443. * @param samplers defines the current sampler list.
  43444. */
  43445. static AddSamplers(samplers: string[]): void;
  43446. /**
  43447. * Makes a duplicate of the current configuration into another one.
  43448. * @param anisotropicConfiguration define the config where to copy the info
  43449. */
  43450. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43451. /**
  43452. * Serializes this anisotropy configuration.
  43453. * @returns - An object with the serialized config.
  43454. */
  43455. serialize(): any;
  43456. /**
  43457. * Parses a anisotropy Configuration from a serialized object.
  43458. * @param source - Serialized object.
  43459. */
  43460. parse(source: any): void;
  43461. }
  43462. }
  43463. declare module BABYLON {
  43464. /**
  43465. * @hidden
  43466. */
  43467. export interface IMaterialBRDFDefines {
  43468. BRDF_V_HEIGHT_CORRELATED: boolean;
  43469. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43470. /** @hidden */ areMiscDirty: boolean;
  43471. }
  43472. /**
  43473. * Define the code related to the BRDF parameters of the pbr material.
  43474. */
  43475. export class PBRBRDFConfiguration {
  43476. /**
  43477. * Default value used for the energy conservation.
  43478. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43479. */
  43480. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43481. /**
  43482. * Default value used for the Smith Visibility Height Correlated mode.
  43483. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43484. */
  43485. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43486. private _useEnergyConservation;
  43487. /**
  43488. * Defines if the material uses energy conservation.
  43489. */
  43490. useEnergyConservation: boolean;
  43491. private _useSmithVisibilityHeightCorrelated;
  43492. /**
  43493. * LEGACY Mode set to false
  43494. * Defines if the material uses height smith correlated visibility term.
  43495. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43496. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43497. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43498. * Not relying on height correlated will also disable energy conservation.
  43499. */
  43500. useSmithVisibilityHeightCorrelated: boolean;
  43501. /** @hidden */
  43502. private _internalMarkAllSubMeshesAsMiscDirty;
  43503. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43504. /**
  43505. * Instantiate a new istance of clear coat configuration.
  43506. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43507. */
  43508. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43509. /**
  43510. * Checks to see if a texture is used in the material.
  43511. * @param defines the list of "defines" to update.
  43512. */
  43513. prepareDefines(defines: IMaterialBRDFDefines): void;
  43514. /**
  43515. * Get the current class name of the texture useful for serialization or dynamic coding.
  43516. * @returns "PBRClearCoatConfiguration"
  43517. */
  43518. getClassName(): string;
  43519. /**
  43520. * Makes a duplicate of the current configuration into another one.
  43521. * @param brdfConfiguration define the config where to copy the info
  43522. */
  43523. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43524. /**
  43525. * Serializes this BRDF configuration.
  43526. * @returns - An object with the serialized config.
  43527. */
  43528. serialize(): any;
  43529. /**
  43530. * Parses a BRDF Configuration from a serialized object.
  43531. * @param source - Serialized object.
  43532. */
  43533. parse(source: any): void;
  43534. }
  43535. }
  43536. declare module BABYLON {
  43537. /**
  43538. * @hidden
  43539. */
  43540. export interface IMaterialSheenDefines {
  43541. SHEEN: boolean;
  43542. SHEEN_TEXTURE: boolean;
  43543. SHEEN_TEXTUREDIRECTUV: number;
  43544. SHEEN_LINKWITHALBEDO: boolean;
  43545. /** @hidden */ areTexturesDirty: boolean;
  43546. }
  43547. /**
  43548. * Define the code related to the Sheen parameters of the pbr material.
  43549. */
  43550. export class PBRSheenConfiguration {
  43551. private _isEnabled;
  43552. /**
  43553. * Defines if the material uses sheen.
  43554. */
  43555. isEnabled: boolean;
  43556. private _linkSheenWithAlbedo;
  43557. /**
  43558. * Defines if the sheen is linked to the sheen color.
  43559. */
  43560. linkSheenWithAlbedo: boolean;
  43561. /**
  43562. * Defines the sheen intensity.
  43563. */
  43564. intensity: number;
  43565. /**
  43566. * Defines the sheen color.
  43567. */
  43568. color: Color3;
  43569. private _texture;
  43570. /**
  43571. * Stores the sheen tint values in a texture.
  43572. * rgb is tint
  43573. * a is a intensity
  43574. */
  43575. texture: Nullable<BaseTexture>;
  43576. /** @hidden */
  43577. private _internalMarkAllSubMeshesAsTexturesDirty;
  43578. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43579. /**
  43580. * Instantiate a new istance of clear coat configuration.
  43581. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43582. */
  43583. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43584. /**
  43585. * Specifies that the submesh is ready to be used.
  43586. * @param defines the list of "defines" to update.
  43587. * @param scene defines the scene the material belongs to.
  43588. * @returns - boolean indicating that the submesh is ready or not.
  43589. */
  43590. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43591. /**
  43592. * Checks to see if a texture is used in the material.
  43593. * @param defines the list of "defines" to update.
  43594. * @param scene defines the scene the material belongs to.
  43595. */
  43596. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43597. /**
  43598. * Binds the material data.
  43599. * @param uniformBuffer defines the Uniform buffer to fill in.
  43600. * @param scene defines the scene the material belongs to.
  43601. * @param isFrozen defines wether the material is frozen or not.
  43602. */
  43603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43604. /**
  43605. * Checks to see if a texture is used in the material.
  43606. * @param texture - Base texture to use.
  43607. * @returns - Boolean specifying if a texture is used in the material.
  43608. */
  43609. hasTexture(texture: BaseTexture): boolean;
  43610. /**
  43611. * Returns an array of the actively used textures.
  43612. * @param activeTextures Array of BaseTextures
  43613. */
  43614. getActiveTextures(activeTextures: BaseTexture[]): void;
  43615. /**
  43616. * Returns the animatable textures.
  43617. * @param animatables Array of animatable textures.
  43618. */
  43619. getAnimatables(animatables: IAnimatable[]): void;
  43620. /**
  43621. * Disposes the resources of the material.
  43622. * @param forceDisposeTextures - Forces the disposal of all textures.
  43623. */
  43624. dispose(forceDisposeTextures?: boolean): void;
  43625. /**
  43626. * Get the current class name of the texture useful for serialization or dynamic coding.
  43627. * @returns "PBRSheenConfiguration"
  43628. */
  43629. getClassName(): string;
  43630. /**
  43631. * Add fallbacks to the effect fallbacks list.
  43632. * @param defines defines the Base texture to use.
  43633. * @param fallbacks defines the current fallback list.
  43634. * @param currentRank defines the current fallback rank.
  43635. * @returns the new fallback rank.
  43636. */
  43637. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43638. /**
  43639. * Add the required uniforms to the current list.
  43640. * @param uniforms defines the current uniform list.
  43641. */
  43642. static AddUniforms(uniforms: string[]): void;
  43643. /**
  43644. * Add the required uniforms to the current buffer.
  43645. * @param uniformBuffer defines the current uniform buffer.
  43646. */
  43647. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43648. /**
  43649. * Add the required samplers to the current list.
  43650. * @param samplers defines the current sampler list.
  43651. */
  43652. static AddSamplers(samplers: string[]): void;
  43653. /**
  43654. * Makes a duplicate of the current configuration into another one.
  43655. * @param sheenConfiguration define the config where to copy the info
  43656. */
  43657. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43658. /**
  43659. * Serializes this BRDF configuration.
  43660. * @returns - An object with the serialized config.
  43661. */
  43662. serialize(): any;
  43663. /**
  43664. * Parses a Sheen Configuration from a serialized object.
  43665. * @param source - Serialized object.
  43666. */
  43667. parse(source: any): void;
  43668. }
  43669. }
  43670. declare module BABYLON {
  43671. /**
  43672. * @hidden
  43673. */
  43674. export interface IMaterialSubSurfaceDefines {
  43675. SUBSURFACE: boolean;
  43676. SS_REFRACTION: boolean;
  43677. SS_TRANSLUCENCY: boolean;
  43678. SS_SCATERRING: boolean;
  43679. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43680. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43681. SS_REFRACTIONMAP_3D: boolean;
  43682. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43683. SS_LODINREFRACTIONALPHA: boolean;
  43684. SS_GAMMAREFRACTION: boolean;
  43685. SS_RGBDREFRACTION: boolean;
  43686. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43687. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43688. /** @hidden */ areTexturesDirty: boolean;
  43689. }
  43690. /**
  43691. * Define the code related to the sub surface parameters of the pbr material.
  43692. */
  43693. export class PBRSubSurfaceConfiguration {
  43694. private _isRefractionEnabled;
  43695. /**
  43696. * Defines if the refraction is enabled in the material.
  43697. */
  43698. isRefractionEnabled: boolean;
  43699. private _isTranslucencyEnabled;
  43700. /**
  43701. * Defines if the translucency is enabled in the material.
  43702. */
  43703. isTranslucencyEnabled: boolean;
  43704. private _isScatteringEnabled;
  43705. /**
  43706. * Defines the refraction intensity of the material.
  43707. * The refraction when enabled replaces the Diffuse part of the material.
  43708. * The intensity helps transitionning between diffuse and refraction.
  43709. */
  43710. refractionIntensity: number;
  43711. /**
  43712. * Defines the translucency intensity of the material.
  43713. * When translucency has been enabled, this defines how much of the "translucency"
  43714. * is addded to the diffuse part of the material.
  43715. */
  43716. translucencyIntensity: number;
  43717. /**
  43718. * Defines the scattering intensity of the material.
  43719. * When scattering has been enabled, this defines how much of the "scattered light"
  43720. * is addded to the diffuse part of the material.
  43721. */
  43722. scatteringIntensity: number;
  43723. private _thicknessTexture;
  43724. /**
  43725. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43726. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43727. * 0 would mean minimumThickness
  43728. * 1 would mean maximumThickness
  43729. * The other channels might be use as a mask to vary the different effects intensity.
  43730. */
  43731. thicknessTexture: Nullable<BaseTexture>;
  43732. private _refractionTexture;
  43733. /**
  43734. * Defines the texture to use for refraction.
  43735. */
  43736. refractionTexture: Nullable<BaseTexture>;
  43737. private _indexOfRefraction;
  43738. /**
  43739. * Defines the indice of refraction used in the material.
  43740. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43741. */
  43742. indexOfRefraction: number;
  43743. private _invertRefractionY;
  43744. /**
  43745. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43746. */
  43747. invertRefractionY: boolean;
  43748. private _linkRefractionWithTransparency;
  43749. /**
  43750. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43751. * Materials half opaque for instance using refraction could benefit from this control.
  43752. */
  43753. linkRefractionWithTransparency: boolean;
  43754. /**
  43755. * Defines the minimum thickness stored in the thickness map.
  43756. * If no thickness map is defined, this value will be used to simulate thickness.
  43757. */
  43758. minimumThickness: number;
  43759. /**
  43760. * Defines the maximum thickness stored in the thickness map.
  43761. */
  43762. maximumThickness: number;
  43763. /**
  43764. * Defines the volume tint of the material.
  43765. * This is used for both translucency and scattering.
  43766. */
  43767. tintColor: Color3;
  43768. /**
  43769. * Defines the distance at which the tint color should be found in the media.
  43770. * This is used for refraction only.
  43771. */
  43772. tintColorAtDistance: number;
  43773. /**
  43774. * Defines how far each channel transmit through the media.
  43775. * It is defined as a color to simplify it selection.
  43776. */
  43777. diffusionDistance: Color3;
  43778. private _useMaskFromThicknessTexture;
  43779. /**
  43780. * Stores the intensity of the different subsurface effects in the thickness texture.
  43781. * * the green channel is the translucency intensity.
  43782. * * the blue channel is the scattering intensity.
  43783. * * the alpha channel is the refraction intensity.
  43784. */
  43785. useMaskFromThicknessTexture: boolean;
  43786. /** @hidden */
  43787. private _internalMarkAllSubMeshesAsTexturesDirty;
  43788. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43789. /**
  43790. * Instantiate a new istance of sub surface configuration.
  43791. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43792. */
  43793. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43794. /**
  43795. * Gets wehter the submesh is ready to be used or not.
  43796. * @param defines the list of "defines" to update.
  43797. * @param scene defines the scene the material belongs to.
  43798. * @returns - boolean indicating that the submesh is ready or not.
  43799. */
  43800. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43801. /**
  43802. * Checks to see if a texture is used in the material.
  43803. * @param defines the list of "defines" to update.
  43804. * @param scene defines the scene to the material belongs to.
  43805. */
  43806. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43807. /**
  43808. * Binds the material data.
  43809. * @param uniformBuffer defines the Uniform buffer to fill in.
  43810. * @param scene defines the scene the material belongs to.
  43811. * @param engine defines the engine the material belongs to.
  43812. * @param isFrozen defines wether the material is frozen or not.
  43813. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43814. */
  43815. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43816. /**
  43817. * Unbinds the material from the mesh.
  43818. * @param activeEffect defines the effect that should be unbound from.
  43819. * @returns true if unbound, otherwise false
  43820. */
  43821. unbind(activeEffect: Effect): boolean;
  43822. /**
  43823. * Returns the texture used for refraction or null if none is used.
  43824. * @param scene defines the scene the material belongs to.
  43825. * @returns - Refraction texture if present. If no refraction texture and refraction
  43826. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43827. */
  43828. private _getRefractionTexture;
  43829. /**
  43830. * Returns true if alpha blending should be disabled.
  43831. */
  43832. readonly disableAlphaBlending: boolean;
  43833. /**
  43834. * Fills the list of render target textures.
  43835. * @param renderTargets the list of render targets to update
  43836. */
  43837. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43838. /**
  43839. * Checks to see if a texture is used in the material.
  43840. * @param texture - Base texture to use.
  43841. * @returns - Boolean specifying if a texture is used in the material.
  43842. */
  43843. hasTexture(texture: BaseTexture): boolean;
  43844. /**
  43845. * Gets a boolean indicating that current material needs to register RTT
  43846. * @returns true if this uses a render target otherwise false.
  43847. */
  43848. hasRenderTargetTextures(): boolean;
  43849. /**
  43850. * Returns an array of the actively used textures.
  43851. * @param activeTextures Array of BaseTextures
  43852. */
  43853. getActiveTextures(activeTextures: BaseTexture[]): void;
  43854. /**
  43855. * Returns the animatable textures.
  43856. * @param animatables Array of animatable textures.
  43857. */
  43858. getAnimatables(animatables: IAnimatable[]): void;
  43859. /**
  43860. * Disposes the resources of the material.
  43861. * @param forceDisposeTextures - Forces the disposal of all textures.
  43862. */
  43863. dispose(forceDisposeTextures?: boolean): void;
  43864. /**
  43865. * Get the current class name of the texture useful for serialization or dynamic coding.
  43866. * @returns "PBRSubSurfaceConfiguration"
  43867. */
  43868. getClassName(): string;
  43869. /**
  43870. * Add fallbacks to the effect fallbacks list.
  43871. * @param defines defines the Base texture to use.
  43872. * @param fallbacks defines the current fallback list.
  43873. * @param currentRank defines the current fallback rank.
  43874. * @returns the new fallback rank.
  43875. */
  43876. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43877. /**
  43878. * Add the required uniforms to the current list.
  43879. * @param uniforms defines the current uniform list.
  43880. */
  43881. static AddUniforms(uniforms: string[]): void;
  43882. /**
  43883. * Add the required samplers to the current list.
  43884. * @param samplers defines the current sampler list.
  43885. */
  43886. static AddSamplers(samplers: string[]): void;
  43887. /**
  43888. * Add the required uniforms to the current buffer.
  43889. * @param uniformBuffer defines the current uniform buffer.
  43890. */
  43891. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43892. /**
  43893. * Makes a duplicate of the current configuration into another one.
  43894. * @param configuration define the config where to copy the info
  43895. */
  43896. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  43897. /**
  43898. * Serializes this Sub Surface configuration.
  43899. * @returns - An object with the serialized config.
  43900. */
  43901. serialize(): any;
  43902. /**
  43903. * Parses a Sub Surface Configuration from a serialized object.
  43904. * @param source - Serialized object.
  43905. */
  43906. parse(source: any): void;
  43907. }
  43908. }
  43909. declare module BABYLON {
  43910. /** @hidden */
  43911. export var pbrFragmentDeclaration: {
  43912. name: string;
  43913. shader: string;
  43914. };
  43915. }
  43916. declare module BABYLON {
  43917. /** @hidden */
  43918. export var pbrUboDeclaration: {
  43919. name: string;
  43920. shader: string;
  43921. };
  43922. }
  43923. declare module BABYLON {
  43924. /** @hidden */
  43925. export var pbrFragmentExtraDeclaration: {
  43926. name: string;
  43927. shader: string;
  43928. };
  43929. }
  43930. declare module BABYLON {
  43931. /** @hidden */
  43932. export var pbrFragmentSamplersDeclaration: {
  43933. name: string;
  43934. shader: string;
  43935. };
  43936. }
  43937. declare module BABYLON {
  43938. /** @hidden */
  43939. export var pbrHelperFunctions: {
  43940. name: string;
  43941. shader: string;
  43942. };
  43943. }
  43944. declare module BABYLON {
  43945. /** @hidden */
  43946. export var harmonicsFunctions: {
  43947. name: string;
  43948. shader: string;
  43949. };
  43950. }
  43951. declare module BABYLON {
  43952. /** @hidden */
  43953. export var pbrDirectLightingSetupFunctions: {
  43954. name: string;
  43955. shader: string;
  43956. };
  43957. }
  43958. declare module BABYLON {
  43959. /** @hidden */
  43960. export var pbrDirectLightingFalloffFunctions: {
  43961. name: string;
  43962. shader: string;
  43963. };
  43964. }
  43965. declare module BABYLON {
  43966. /** @hidden */
  43967. export var pbrBRDFFunctions: {
  43968. name: string;
  43969. shader: string;
  43970. };
  43971. }
  43972. declare module BABYLON {
  43973. /** @hidden */
  43974. export var pbrDirectLightingFunctions: {
  43975. name: string;
  43976. shader: string;
  43977. };
  43978. }
  43979. declare module BABYLON {
  43980. /** @hidden */
  43981. export var pbrIBLFunctions: {
  43982. name: string;
  43983. shader: string;
  43984. };
  43985. }
  43986. declare module BABYLON {
  43987. /** @hidden */
  43988. export var pbrDebug: {
  43989. name: string;
  43990. shader: string;
  43991. };
  43992. }
  43993. declare module BABYLON {
  43994. /** @hidden */
  43995. export var pbrPixelShader: {
  43996. name: string;
  43997. shader: string;
  43998. };
  43999. }
  44000. declare module BABYLON {
  44001. /** @hidden */
  44002. export var pbrVertexDeclaration: {
  44003. name: string;
  44004. shader: string;
  44005. };
  44006. }
  44007. declare module BABYLON {
  44008. /** @hidden */
  44009. export var pbrVertexShader: {
  44010. name: string;
  44011. shader: string;
  44012. };
  44013. }
  44014. declare module BABYLON {
  44015. /**
  44016. * Manages the defines for the PBR Material.
  44017. * @hidden
  44018. */
  44019. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44020. PBR: boolean;
  44021. MAINUV1: boolean;
  44022. MAINUV2: boolean;
  44023. UV1: boolean;
  44024. UV2: boolean;
  44025. ALBEDO: boolean;
  44026. ALBEDODIRECTUV: number;
  44027. VERTEXCOLOR: boolean;
  44028. AMBIENT: boolean;
  44029. AMBIENTDIRECTUV: number;
  44030. AMBIENTINGRAYSCALE: boolean;
  44031. OPACITY: boolean;
  44032. VERTEXALPHA: boolean;
  44033. OPACITYDIRECTUV: number;
  44034. OPACITYRGB: boolean;
  44035. ALPHATEST: boolean;
  44036. DEPTHPREPASS: boolean;
  44037. ALPHABLEND: boolean;
  44038. ALPHAFROMALBEDO: boolean;
  44039. ALPHATESTVALUE: string;
  44040. SPECULAROVERALPHA: boolean;
  44041. RADIANCEOVERALPHA: boolean;
  44042. ALPHAFRESNEL: boolean;
  44043. LINEARALPHAFRESNEL: boolean;
  44044. PREMULTIPLYALPHA: boolean;
  44045. EMISSIVE: boolean;
  44046. EMISSIVEDIRECTUV: number;
  44047. REFLECTIVITY: boolean;
  44048. REFLECTIVITYDIRECTUV: number;
  44049. SPECULARTERM: boolean;
  44050. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44051. MICROSURFACEAUTOMATIC: boolean;
  44052. LODBASEDMICROSFURACE: boolean;
  44053. MICROSURFACEMAP: boolean;
  44054. MICROSURFACEMAPDIRECTUV: number;
  44055. METALLICWORKFLOW: boolean;
  44056. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44057. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44058. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44059. AOSTOREINMETALMAPRED: boolean;
  44060. ENVIRONMENTBRDF: boolean;
  44061. ENVIRONMENTBRDF_RGBD: boolean;
  44062. NORMAL: boolean;
  44063. TANGENT: boolean;
  44064. BUMP: boolean;
  44065. BUMPDIRECTUV: number;
  44066. OBJECTSPACE_NORMALMAP: boolean;
  44067. PARALLAX: boolean;
  44068. PARALLAXOCCLUSION: boolean;
  44069. NORMALXYSCALE: boolean;
  44070. LIGHTMAP: boolean;
  44071. LIGHTMAPDIRECTUV: number;
  44072. USELIGHTMAPASSHADOWMAP: boolean;
  44073. GAMMALIGHTMAP: boolean;
  44074. REFLECTION: boolean;
  44075. REFLECTIONMAP_3D: boolean;
  44076. REFLECTIONMAP_SPHERICAL: boolean;
  44077. REFLECTIONMAP_PLANAR: boolean;
  44078. REFLECTIONMAP_CUBIC: boolean;
  44079. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44080. REFLECTIONMAP_PROJECTION: boolean;
  44081. REFLECTIONMAP_SKYBOX: boolean;
  44082. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44083. REFLECTIONMAP_EXPLICIT: boolean;
  44084. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44085. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44086. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44087. INVERTCUBICMAP: boolean;
  44088. USESPHERICALFROMREFLECTIONMAP: boolean;
  44089. USESPHERICALINVERTEX: boolean;
  44090. REFLECTIONMAP_OPPOSITEZ: boolean;
  44091. LODINREFLECTIONALPHA: boolean;
  44092. GAMMAREFLECTION: boolean;
  44093. RGBDREFLECTION: boolean;
  44094. RADIANCEOCCLUSION: boolean;
  44095. HORIZONOCCLUSION: boolean;
  44096. INSTANCES: boolean;
  44097. NUM_BONE_INFLUENCERS: number;
  44098. BonesPerMesh: number;
  44099. BONETEXTURE: boolean;
  44100. NONUNIFORMSCALING: boolean;
  44101. MORPHTARGETS: boolean;
  44102. MORPHTARGETS_NORMAL: boolean;
  44103. MORPHTARGETS_TANGENT: boolean;
  44104. NUM_MORPH_INFLUENCERS: number;
  44105. IMAGEPROCESSING: boolean;
  44106. VIGNETTE: boolean;
  44107. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44108. VIGNETTEBLENDMODEOPAQUE: boolean;
  44109. TONEMAPPING: boolean;
  44110. TONEMAPPING_ACES: boolean;
  44111. CONTRAST: boolean;
  44112. COLORCURVES: boolean;
  44113. COLORGRADING: boolean;
  44114. COLORGRADING3D: boolean;
  44115. SAMPLER3DGREENDEPTH: boolean;
  44116. SAMPLER3DBGRMAP: boolean;
  44117. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44118. EXPOSURE: boolean;
  44119. MULTIVIEW: boolean;
  44120. USEPHYSICALLIGHTFALLOFF: boolean;
  44121. USEGLTFLIGHTFALLOFF: boolean;
  44122. TWOSIDEDLIGHTING: boolean;
  44123. SHADOWFLOAT: boolean;
  44124. CLIPPLANE: boolean;
  44125. CLIPPLANE2: boolean;
  44126. CLIPPLANE3: boolean;
  44127. CLIPPLANE4: boolean;
  44128. POINTSIZE: boolean;
  44129. FOG: boolean;
  44130. LOGARITHMICDEPTH: boolean;
  44131. FORCENORMALFORWARD: boolean;
  44132. SPECULARAA: boolean;
  44133. CLEARCOAT: boolean;
  44134. CLEARCOAT_DEFAULTIOR: boolean;
  44135. CLEARCOAT_TEXTURE: boolean;
  44136. CLEARCOAT_TEXTUREDIRECTUV: number;
  44137. CLEARCOAT_BUMP: boolean;
  44138. CLEARCOAT_BUMPDIRECTUV: number;
  44139. CLEARCOAT_TINT: boolean;
  44140. CLEARCOAT_TINT_TEXTURE: boolean;
  44141. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44142. ANISOTROPIC: boolean;
  44143. ANISOTROPIC_TEXTURE: boolean;
  44144. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44145. BRDF_V_HEIGHT_CORRELATED: boolean;
  44146. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44147. SHEEN: boolean;
  44148. SHEEN_TEXTURE: boolean;
  44149. SHEEN_TEXTUREDIRECTUV: number;
  44150. SHEEN_LINKWITHALBEDO: boolean;
  44151. SUBSURFACE: boolean;
  44152. SS_REFRACTION: boolean;
  44153. SS_TRANSLUCENCY: boolean;
  44154. SS_SCATERRING: boolean;
  44155. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44156. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44157. SS_REFRACTIONMAP_3D: boolean;
  44158. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44159. SS_LODINREFRACTIONALPHA: boolean;
  44160. SS_GAMMAREFRACTION: boolean;
  44161. SS_RGBDREFRACTION: boolean;
  44162. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44163. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44164. UNLIT: boolean;
  44165. DEBUGMODE: number;
  44166. /**
  44167. * Initializes the PBR Material defines.
  44168. */
  44169. constructor();
  44170. /**
  44171. * Resets the PBR Material defines.
  44172. */
  44173. reset(): void;
  44174. }
  44175. /**
  44176. * The Physically based material base class of BJS.
  44177. *
  44178. * This offers the main features of a standard PBR material.
  44179. * For more information, please refer to the documentation :
  44180. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44181. */
  44182. export abstract class PBRBaseMaterial extends PushMaterial {
  44183. /**
  44184. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44185. */
  44186. static readonly PBRMATERIAL_OPAQUE: number;
  44187. /**
  44188. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44189. */
  44190. static readonly PBRMATERIAL_ALPHATEST: number;
  44191. /**
  44192. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44193. */
  44194. static readonly PBRMATERIAL_ALPHABLEND: number;
  44195. /**
  44196. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44197. * They are also discarded below the alpha cutoff threshold to improve performances.
  44198. */
  44199. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44200. /**
  44201. * Defines the default value of how much AO map is occluding the analytical lights
  44202. * (point spot...).
  44203. */
  44204. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44205. /**
  44206. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44207. */
  44208. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44209. /**
  44210. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44211. * to enhance interoperability with other engines.
  44212. */
  44213. static readonly LIGHTFALLOFF_GLTF: number;
  44214. /**
  44215. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44216. * to enhance interoperability with other materials.
  44217. */
  44218. static readonly LIGHTFALLOFF_STANDARD: number;
  44219. /**
  44220. * Intensity of the direct lights e.g. the four lights available in your scene.
  44221. * This impacts both the direct diffuse and specular highlights.
  44222. */
  44223. protected _directIntensity: number;
  44224. /**
  44225. * Intensity of the emissive part of the material.
  44226. * This helps controlling the emissive effect without modifying the emissive color.
  44227. */
  44228. protected _emissiveIntensity: number;
  44229. /**
  44230. * Intensity of the environment e.g. how much the environment will light the object
  44231. * either through harmonics for rough material or through the refelction for shiny ones.
  44232. */
  44233. protected _environmentIntensity: number;
  44234. /**
  44235. * This is a special control allowing the reduction of the specular highlights coming from the
  44236. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44237. */
  44238. protected _specularIntensity: number;
  44239. /**
  44240. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44241. */
  44242. private _lightingInfos;
  44243. /**
  44244. * Debug Control allowing disabling the bump map on this material.
  44245. */
  44246. protected _disableBumpMap: boolean;
  44247. /**
  44248. * AKA Diffuse Texture in standard nomenclature.
  44249. */
  44250. protected _albedoTexture: Nullable<BaseTexture>;
  44251. /**
  44252. * AKA Occlusion Texture in other nomenclature.
  44253. */
  44254. protected _ambientTexture: Nullable<BaseTexture>;
  44255. /**
  44256. * AKA Occlusion Texture Intensity in other nomenclature.
  44257. */
  44258. protected _ambientTextureStrength: number;
  44259. /**
  44260. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44261. * 1 means it completely occludes it
  44262. * 0 mean it has no impact
  44263. */
  44264. protected _ambientTextureImpactOnAnalyticalLights: number;
  44265. /**
  44266. * Stores the alpha values in a texture.
  44267. */
  44268. protected _opacityTexture: Nullable<BaseTexture>;
  44269. /**
  44270. * Stores the reflection values in a texture.
  44271. */
  44272. protected _reflectionTexture: Nullable<BaseTexture>;
  44273. /**
  44274. * Stores the emissive values in a texture.
  44275. */
  44276. protected _emissiveTexture: Nullable<BaseTexture>;
  44277. /**
  44278. * AKA Specular texture in other nomenclature.
  44279. */
  44280. protected _reflectivityTexture: Nullable<BaseTexture>;
  44281. /**
  44282. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44283. */
  44284. protected _metallicTexture: Nullable<BaseTexture>;
  44285. /**
  44286. * Specifies the metallic scalar of the metallic/roughness workflow.
  44287. * Can also be used to scale the metalness values of the metallic texture.
  44288. */
  44289. protected _metallic: Nullable<number>;
  44290. /**
  44291. * Specifies the roughness scalar of the metallic/roughness workflow.
  44292. * Can also be used to scale the roughness values of the metallic texture.
  44293. */
  44294. protected _roughness: Nullable<number>;
  44295. /**
  44296. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44297. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44298. */
  44299. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44300. /**
  44301. * Stores surface normal data used to displace a mesh in a texture.
  44302. */
  44303. protected _bumpTexture: Nullable<BaseTexture>;
  44304. /**
  44305. * Stores the pre-calculated light information of a mesh in a texture.
  44306. */
  44307. protected _lightmapTexture: Nullable<BaseTexture>;
  44308. /**
  44309. * The color of a material in ambient lighting.
  44310. */
  44311. protected _ambientColor: Color3;
  44312. /**
  44313. * AKA Diffuse Color in other nomenclature.
  44314. */
  44315. protected _albedoColor: Color3;
  44316. /**
  44317. * AKA Specular Color in other nomenclature.
  44318. */
  44319. protected _reflectivityColor: Color3;
  44320. /**
  44321. * The color applied when light is reflected from a material.
  44322. */
  44323. protected _reflectionColor: Color3;
  44324. /**
  44325. * The color applied when light is emitted from a material.
  44326. */
  44327. protected _emissiveColor: Color3;
  44328. /**
  44329. * AKA Glossiness in other nomenclature.
  44330. */
  44331. protected _microSurface: number;
  44332. /**
  44333. * Specifies that the material will use the light map as a show map.
  44334. */
  44335. protected _useLightmapAsShadowmap: boolean;
  44336. /**
  44337. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44338. * makes the reflect vector face the model (under horizon).
  44339. */
  44340. protected _useHorizonOcclusion: boolean;
  44341. /**
  44342. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44343. * too much the area relying on ambient texture to define their ambient occlusion.
  44344. */
  44345. protected _useRadianceOcclusion: boolean;
  44346. /**
  44347. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44348. */
  44349. protected _useAlphaFromAlbedoTexture: boolean;
  44350. /**
  44351. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44352. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44353. */
  44354. protected _useSpecularOverAlpha: boolean;
  44355. /**
  44356. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44357. */
  44358. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44359. /**
  44360. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44361. */
  44362. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44363. /**
  44364. * Specifies if the metallic texture contains the roughness information in its green channel.
  44365. */
  44366. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44367. /**
  44368. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44369. */
  44370. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44371. /**
  44372. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44373. */
  44374. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44375. /**
  44376. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44377. */
  44378. protected _useAmbientInGrayScale: boolean;
  44379. /**
  44380. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44381. * The material will try to infer what glossiness each pixel should be.
  44382. */
  44383. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44384. /**
  44385. * Defines the falloff type used in this material.
  44386. * It by default is Physical.
  44387. */
  44388. protected _lightFalloff: number;
  44389. /**
  44390. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44391. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44392. */
  44393. protected _useRadianceOverAlpha: boolean;
  44394. /**
  44395. * Allows using an object space normal map (instead of tangent space).
  44396. */
  44397. protected _useObjectSpaceNormalMap: boolean;
  44398. /**
  44399. * Allows using the bump map in parallax mode.
  44400. */
  44401. protected _useParallax: boolean;
  44402. /**
  44403. * Allows using the bump map in parallax occlusion mode.
  44404. */
  44405. protected _useParallaxOcclusion: boolean;
  44406. /**
  44407. * Controls the scale bias of the parallax mode.
  44408. */
  44409. protected _parallaxScaleBias: number;
  44410. /**
  44411. * If sets to true, disables all the lights affecting the material.
  44412. */
  44413. protected _disableLighting: boolean;
  44414. /**
  44415. * Number of Simultaneous lights allowed on the material.
  44416. */
  44417. protected _maxSimultaneousLights: number;
  44418. /**
  44419. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44420. */
  44421. protected _invertNormalMapX: boolean;
  44422. /**
  44423. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44424. */
  44425. protected _invertNormalMapY: boolean;
  44426. /**
  44427. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44428. */
  44429. protected _twoSidedLighting: boolean;
  44430. /**
  44431. * Defines the alpha limits in alpha test mode.
  44432. */
  44433. protected _alphaCutOff: number;
  44434. /**
  44435. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44436. */
  44437. protected _forceAlphaTest: boolean;
  44438. /**
  44439. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44440. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44441. */
  44442. protected _useAlphaFresnel: boolean;
  44443. /**
  44444. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44445. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44446. */
  44447. protected _useLinearAlphaFresnel: boolean;
  44448. /**
  44449. * The transparency mode of the material.
  44450. */
  44451. protected _transparencyMode: Nullable<number>;
  44452. /**
  44453. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44454. * from cos thetav and roughness:
  44455. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44456. */
  44457. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44458. /**
  44459. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44460. */
  44461. protected _forceIrradianceInFragment: boolean;
  44462. /**
  44463. * Force normal to face away from face.
  44464. */
  44465. protected _forceNormalForward: boolean;
  44466. /**
  44467. * Enables specular anti aliasing in the PBR shader.
  44468. * It will both interacts on the Geometry for analytical and IBL lighting.
  44469. * It also prefilter the roughness map based on the bump values.
  44470. */
  44471. protected _enableSpecularAntiAliasing: boolean;
  44472. /**
  44473. * Default configuration related to image processing available in the PBR Material.
  44474. */
  44475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44476. /**
  44477. * Keep track of the image processing observer to allow dispose and replace.
  44478. */
  44479. private _imageProcessingObserver;
  44480. /**
  44481. * Attaches a new image processing configuration to the PBR Material.
  44482. * @param configuration
  44483. */
  44484. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44485. /**
  44486. * Stores the available render targets.
  44487. */
  44488. private _renderTargets;
  44489. /**
  44490. * Sets the global ambient color for the material used in lighting calculations.
  44491. */
  44492. private _globalAmbientColor;
  44493. /**
  44494. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44495. */
  44496. private _useLogarithmicDepth;
  44497. /**
  44498. * If set to true, no lighting calculations will be applied.
  44499. */
  44500. private _unlit;
  44501. private _debugMode;
  44502. /**
  44503. * @hidden
  44504. * This is reserved for the inspector.
  44505. * Defines the material debug mode.
  44506. * It helps seeing only some components of the material while troubleshooting.
  44507. */
  44508. debugMode: number;
  44509. /**
  44510. * @hidden
  44511. * This is reserved for the inspector.
  44512. * Specify from where on screen the debug mode should start.
  44513. * The value goes from -1 (full screen) to 1 (not visible)
  44514. * It helps with side by side comparison against the final render
  44515. * This defaults to -1
  44516. */
  44517. private debugLimit;
  44518. /**
  44519. * @hidden
  44520. * This is reserved for the inspector.
  44521. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44522. * You can use the factor to better multiply the final value.
  44523. */
  44524. private debugFactor;
  44525. /**
  44526. * Defines the clear coat layer parameters for the material.
  44527. */
  44528. readonly clearCoat: PBRClearCoatConfiguration;
  44529. /**
  44530. * Defines the anisotropic parameters for the material.
  44531. */
  44532. readonly anisotropy: PBRAnisotropicConfiguration;
  44533. /**
  44534. * Defines the BRDF parameters for the material.
  44535. */
  44536. readonly brdf: PBRBRDFConfiguration;
  44537. /**
  44538. * Defines the Sheen parameters for the material.
  44539. */
  44540. readonly sheen: PBRSheenConfiguration;
  44541. /**
  44542. * Defines the SubSurface parameters for the material.
  44543. */
  44544. readonly subSurface: PBRSubSurfaceConfiguration;
  44545. /**
  44546. * Custom callback helping to override the default shader used in the material.
  44547. */
  44548. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44549. /**
  44550. * Instantiates a new PBRMaterial instance.
  44551. *
  44552. * @param name The material name
  44553. * @param scene The scene the material will be use in.
  44554. */
  44555. constructor(name: string, scene: Scene);
  44556. /**
  44557. * Gets a boolean indicating that current material needs to register RTT
  44558. */
  44559. readonly hasRenderTargetTextures: boolean;
  44560. /**
  44561. * Gets the name of the material class.
  44562. */
  44563. getClassName(): string;
  44564. /**
  44565. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44566. */
  44567. /**
  44568. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44569. */
  44570. useLogarithmicDepth: boolean;
  44571. /**
  44572. * Gets the current transparency mode.
  44573. */
  44574. /**
  44575. * Sets the transparency mode of the material.
  44576. *
  44577. * | Value | Type | Description |
  44578. * | ----- | ----------------------------------- | ----------- |
  44579. * | 0 | OPAQUE | |
  44580. * | 1 | ALPHATEST | |
  44581. * | 2 | ALPHABLEND | |
  44582. * | 3 | ALPHATESTANDBLEND | |
  44583. *
  44584. */
  44585. transparencyMode: Nullable<number>;
  44586. /**
  44587. * Returns true if alpha blending should be disabled.
  44588. */
  44589. private readonly _disableAlphaBlending;
  44590. /**
  44591. * Specifies whether or not this material should be rendered in alpha blend mode.
  44592. */
  44593. needAlphaBlending(): boolean;
  44594. /**
  44595. * Specifies if the mesh will require alpha blending.
  44596. * @param mesh - BJS mesh.
  44597. */
  44598. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44599. /**
  44600. * Specifies whether or not this material should be rendered in alpha test mode.
  44601. */
  44602. needAlphaTesting(): boolean;
  44603. /**
  44604. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44605. */
  44606. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44607. /**
  44608. * Gets the texture used for the alpha test.
  44609. */
  44610. getAlphaTestTexture(): Nullable<BaseTexture>;
  44611. /**
  44612. * Specifies that the submesh is ready to be used.
  44613. * @param mesh - BJS mesh.
  44614. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44615. * @param useInstances - Specifies that instances should be used.
  44616. * @returns - boolean indicating that the submesh is ready or not.
  44617. */
  44618. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44619. /**
  44620. * Specifies if the material uses metallic roughness workflow.
  44621. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44622. */
  44623. isMetallicWorkflow(): boolean;
  44624. private _prepareEffect;
  44625. private _prepareDefines;
  44626. /**
  44627. * Force shader compilation
  44628. */
  44629. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44630. clipPlane: boolean;
  44631. }>): void;
  44632. /**
  44633. * Initializes the uniform buffer layout for the shader.
  44634. */
  44635. buildUniformLayout(): void;
  44636. /**
  44637. * Unbinds the material from the mesh
  44638. */
  44639. unbind(): void;
  44640. /**
  44641. * Binds the submesh data.
  44642. * @param world - The world matrix.
  44643. * @param mesh - The BJS mesh.
  44644. * @param subMesh - A submesh of the BJS mesh.
  44645. */
  44646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44647. /**
  44648. * Returns the animatable textures.
  44649. * @returns - Array of animatable textures.
  44650. */
  44651. getAnimatables(): IAnimatable[];
  44652. /**
  44653. * Returns the texture used for reflections.
  44654. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44655. */
  44656. private _getReflectionTexture;
  44657. /**
  44658. * Returns an array of the actively used textures.
  44659. * @returns - Array of BaseTextures
  44660. */
  44661. getActiveTextures(): BaseTexture[];
  44662. /**
  44663. * Checks to see if a texture is used in the material.
  44664. * @param texture - Base texture to use.
  44665. * @returns - Boolean specifying if a texture is used in the material.
  44666. */
  44667. hasTexture(texture: BaseTexture): boolean;
  44668. /**
  44669. * Disposes the resources of the material.
  44670. * @param forceDisposeEffect - Forces the disposal of effects.
  44671. * @param forceDisposeTextures - Forces the disposal of all textures.
  44672. */
  44673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44674. }
  44675. }
  44676. declare module BABYLON {
  44677. /**
  44678. * The Physically based material of BJS.
  44679. *
  44680. * This offers the main features of a standard PBR material.
  44681. * For more information, please refer to the documentation :
  44682. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44683. */
  44684. export class PBRMaterial extends PBRBaseMaterial {
  44685. /**
  44686. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44687. */
  44688. static readonly PBRMATERIAL_OPAQUE: number;
  44689. /**
  44690. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44691. */
  44692. static readonly PBRMATERIAL_ALPHATEST: number;
  44693. /**
  44694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44695. */
  44696. static readonly PBRMATERIAL_ALPHABLEND: number;
  44697. /**
  44698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44699. * They are also discarded below the alpha cutoff threshold to improve performances.
  44700. */
  44701. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44702. /**
  44703. * Defines the default value of how much AO map is occluding the analytical lights
  44704. * (point spot...).
  44705. */
  44706. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44707. /**
  44708. * Intensity of the direct lights e.g. the four lights available in your scene.
  44709. * This impacts both the direct diffuse and specular highlights.
  44710. */
  44711. directIntensity: number;
  44712. /**
  44713. * Intensity of the emissive part of the material.
  44714. * This helps controlling the emissive effect without modifying the emissive color.
  44715. */
  44716. emissiveIntensity: number;
  44717. /**
  44718. * Intensity of the environment e.g. how much the environment will light the object
  44719. * either through harmonics for rough material or through the refelction for shiny ones.
  44720. */
  44721. environmentIntensity: number;
  44722. /**
  44723. * This is a special control allowing the reduction of the specular highlights coming from the
  44724. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44725. */
  44726. specularIntensity: number;
  44727. /**
  44728. * Debug Control allowing disabling the bump map on this material.
  44729. */
  44730. disableBumpMap: boolean;
  44731. /**
  44732. * AKA Diffuse Texture in standard nomenclature.
  44733. */
  44734. albedoTexture: BaseTexture;
  44735. /**
  44736. * AKA Occlusion Texture in other nomenclature.
  44737. */
  44738. ambientTexture: BaseTexture;
  44739. /**
  44740. * AKA Occlusion Texture Intensity in other nomenclature.
  44741. */
  44742. ambientTextureStrength: number;
  44743. /**
  44744. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44745. * 1 means it completely occludes it
  44746. * 0 mean it has no impact
  44747. */
  44748. ambientTextureImpactOnAnalyticalLights: number;
  44749. /**
  44750. * Stores the alpha values in a texture.
  44751. */
  44752. opacityTexture: BaseTexture;
  44753. /**
  44754. * Stores the reflection values in a texture.
  44755. */
  44756. reflectionTexture: Nullable<BaseTexture>;
  44757. /**
  44758. * Stores the emissive values in a texture.
  44759. */
  44760. emissiveTexture: BaseTexture;
  44761. /**
  44762. * AKA Specular texture in other nomenclature.
  44763. */
  44764. reflectivityTexture: BaseTexture;
  44765. /**
  44766. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44767. */
  44768. metallicTexture: BaseTexture;
  44769. /**
  44770. * Specifies the metallic scalar of the metallic/roughness workflow.
  44771. * Can also be used to scale the metalness values of the metallic texture.
  44772. */
  44773. metallic: Nullable<number>;
  44774. /**
  44775. * Specifies the roughness scalar of the metallic/roughness workflow.
  44776. * Can also be used to scale the roughness values of the metallic texture.
  44777. */
  44778. roughness: Nullable<number>;
  44779. /**
  44780. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44781. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44782. */
  44783. microSurfaceTexture: BaseTexture;
  44784. /**
  44785. * Stores surface normal data used to displace a mesh in a texture.
  44786. */
  44787. bumpTexture: BaseTexture;
  44788. /**
  44789. * Stores the pre-calculated light information of a mesh in a texture.
  44790. */
  44791. lightmapTexture: BaseTexture;
  44792. /**
  44793. * Stores the refracted light information in a texture.
  44794. */
  44795. refractionTexture: Nullable<BaseTexture>;
  44796. /**
  44797. * The color of a material in ambient lighting.
  44798. */
  44799. ambientColor: Color3;
  44800. /**
  44801. * AKA Diffuse Color in other nomenclature.
  44802. */
  44803. albedoColor: Color3;
  44804. /**
  44805. * AKA Specular Color in other nomenclature.
  44806. */
  44807. reflectivityColor: Color3;
  44808. /**
  44809. * The color reflected from the material.
  44810. */
  44811. reflectionColor: Color3;
  44812. /**
  44813. * The color emitted from the material.
  44814. */
  44815. emissiveColor: Color3;
  44816. /**
  44817. * AKA Glossiness in other nomenclature.
  44818. */
  44819. microSurface: number;
  44820. /**
  44821. * source material index of refraction (IOR)' / 'destination material IOR.
  44822. */
  44823. indexOfRefraction: number;
  44824. /**
  44825. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44826. */
  44827. invertRefractionY: boolean;
  44828. /**
  44829. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44830. * Materials half opaque for instance using refraction could benefit from this control.
  44831. */
  44832. linkRefractionWithTransparency: boolean;
  44833. /**
  44834. * If true, the light map contains occlusion information instead of lighting info.
  44835. */
  44836. useLightmapAsShadowmap: boolean;
  44837. /**
  44838. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44839. */
  44840. useAlphaFromAlbedoTexture: boolean;
  44841. /**
  44842. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44843. */
  44844. forceAlphaTest: boolean;
  44845. /**
  44846. * Defines the alpha limits in alpha test mode.
  44847. */
  44848. alphaCutOff: number;
  44849. /**
  44850. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44852. */
  44853. useSpecularOverAlpha: boolean;
  44854. /**
  44855. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44856. */
  44857. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44858. /**
  44859. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44860. */
  44861. useRoughnessFromMetallicTextureAlpha: boolean;
  44862. /**
  44863. * Specifies if the metallic texture contains the roughness information in its green channel.
  44864. */
  44865. useRoughnessFromMetallicTextureGreen: boolean;
  44866. /**
  44867. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44868. */
  44869. useMetallnessFromMetallicTextureBlue: boolean;
  44870. /**
  44871. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44872. */
  44873. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44874. /**
  44875. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44876. */
  44877. useAmbientInGrayScale: boolean;
  44878. /**
  44879. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44880. * The material will try to infer what glossiness each pixel should be.
  44881. */
  44882. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44883. /**
  44884. * BJS is using an harcoded light falloff based on a manually sets up range.
  44885. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44886. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44887. */
  44888. /**
  44889. * BJS is using an harcoded light falloff based on a manually sets up range.
  44890. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44891. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44892. */
  44893. usePhysicalLightFalloff: boolean;
  44894. /**
  44895. * In order to support the falloff compatibility with gltf, a special mode has been added
  44896. * to reproduce the gltf light falloff.
  44897. */
  44898. /**
  44899. * In order to support the falloff compatibility with gltf, a special mode has been added
  44900. * to reproduce the gltf light falloff.
  44901. */
  44902. useGLTFLightFalloff: boolean;
  44903. /**
  44904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44906. */
  44907. useRadianceOverAlpha: boolean;
  44908. /**
  44909. * Allows using an object space normal map (instead of tangent space).
  44910. */
  44911. useObjectSpaceNormalMap: boolean;
  44912. /**
  44913. * Allows using the bump map in parallax mode.
  44914. */
  44915. useParallax: boolean;
  44916. /**
  44917. * Allows using the bump map in parallax occlusion mode.
  44918. */
  44919. useParallaxOcclusion: boolean;
  44920. /**
  44921. * Controls the scale bias of the parallax mode.
  44922. */
  44923. parallaxScaleBias: number;
  44924. /**
  44925. * If sets to true, disables all the lights affecting the material.
  44926. */
  44927. disableLighting: boolean;
  44928. /**
  44929. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44930. */
  44931. forceIrradianceInFragment: boolean;
  44932. /**
  44933. * Number of Simultaneous lights allowed on the material.
  44934. */
  44935. maxSimultaneousLights: number;
  44936. /**
  44937. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44938. */
  44939. invertNormalMapX: boolean;
  44940. /**
  44941. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44942. */
  44943. invertNormalMapY: boolean;
  44944. /**
  44945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44946. */
  44947. twoSidedLighting: boolean;
  44948. /**
  44949. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44950. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44951. */
  44952. useAlphaFresnel: boolean;
  44953. /**
  44954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44955. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44956. */
  44957. useLinearAlphaFresnel: boolean;
  44958. /**
  44959. * Let user defines the brdf lookup texture used for IBL.
  44960. * A default 8bit version is embedded but you could point at :
  44961. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44962. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44963. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44964. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44965. */
  44966. environmentBRDFTexture: Nullable<BaseTexture>;
  44967. /**
  44968. * Force normal to face away from face.
  44969. */
  44970. forceNormalForward: boolean;
  44971. /**
  44972. * Enables specular anti aliasing in the PBR shader.
  44973. * It will both interacts on the Geometry for analytical and IBL lighting.
  44974. * It also prefilter the roughness map based on the bump values.
  44975. */
  44976. enableSpecularAntiAliasing: boolean;
  44977. /**
  44978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44979. * makes the reflect vector face the model (under horizon).
  44980. */
  44981. useHorizonOcclusion: boolean;
  44982. /**
  44983. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44984. * too much the area relying on ambient texture to define their ambient occlusion.
  44985. */
  44986. useRadianceOcclusion: boolean;
  44987. /**
  44988. * If set to true, no lighting calculations will be applied.
  44989. */
  44990. unlit: boolean;
  44991. /**
  44992. * Gets the image processing configuration used either in this material.
  44993. */
  44994. /**
  44995. * Sets the Default image processing configuration used either in the this material.
  44996. *
  44997. * If sets to null, the scene one is in use.
  44998. */
  44999. imageProcessingConfiguration: ImageProcessingConfiguration;
  45000. /**
  45001. * Gets wether the color curves effect is enabled.
  45002. */
  45003. /**
  45004. * Sets wether the color curves effect is enabled.
  45005. */
  45006. cameraColorCurvesEnabled: boolean;
  45007. /**
  45008. * Gets wether the color grading effect is enabled.
  45009. */
  45010. /**
  45011. * Gets wether the color grading effect is enabled.
  45012. */
  45013. cameraColorGradingEnabled: boolean;
  45014. /**
  45015. * Gets wether tonemapping is enabled or not.
  45016. */
  45017. /**
  45018. * Sets wether tonemapping is enabled or not
  45019. */
  45020. cameraToneMappingEnabled: boolean;
  45021. /**
  45022. * The camera exposure used on this material.
  45023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45024. * This corresponds to a photographic exposure.
  45025. */
  45026. /**
  45027. * The camera exposure used on this material.
  45028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45029. * This corresponds to a photographic exposure.
  45030. */
  45031. cameraExposure: number;
  45032. /**
  45033. * Gets The camera contrast used on this material.
  45034. */
  45035. /**
  45036. * Sets The camera contrast used on this material.
  45037. */
  45038. cameraContrast: number;
  45039. /**
  45040. * Gets the Color Grading 2D Lookup Texture.
  45041. */
  45042. /**
  45043. * Sets the Color Grading 2D Lookup Texture.
  45044. */
  45045. cameraColorGradingTexture: Nullable<BaseTexture>;
  45046. /**
  45047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45049. * 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;
  45050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45051. */
  45052. /**
  45053. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45054. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45055. * 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;
  45056. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45057. */
  45058. cameraColorCurves: Nullable<ColorCurves>;
  45059. /**
  45060. * Instantiates a new PBRMaterial instance.
  45061. *
  45062. * @param name The material name
  45063. * @param scene The scene the material will be use in.
  45064. */
  45065. constructor(name: string, scene: Scene);
  45066. /**
  45067. * Returns the name of this material class.
  45068. */
  45069. getClassName(): string;
  45070. /**
  45071. * Makes a duplicate of the current material.
  45072. * @param name - name to use for the new material.
  45073. */
  45074. clone(name: string): PBRMaterial;
  45075. /**
  45076. * Serializes this PBR Material.
  45077. * @returns - An object with the serialized material.
  45078. */
  45079. serialize(): any;
  45080. /**
  45081. * Parses a PBR Material from a serialized object.
  45082. * @param source - Serialized object.
  45083. * @param scene - BJS scene instance.
  45084. * @param rootUrl - url for the scene object
  45085. * @returns - PBRMaterial
  45086. */
  45087. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /**
  45092. * Direct draw surface info
  45093. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45094. */
  45095. export interface DDSInfo {
  45096. /**
  45097. * Width of the texture
  45098. */
  45099. width: number;
  45100. /**
  45101. * Width of the texture
  45102. */
  45103. height: number;
  45104. /**
  45105. * Number of Mipmaps for the texture
  45106. * @see https://en.wikipedia.org/wiki/Mipmap
  45107. */
  45108. mipmapCount: number;
  45109. /**
  45110. * If the textures format is a known fourCC format
  45111. * @see https://www.fourcc.org/
  45112. */
  45113. isFourCC: boolean;
  45114. /**
  45115. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45116. */
  45117. isRGB: boolean;
  45118. /**
  45119. * If the texture is a lumincance format
  45120. */
  45121. isLuminance: boolean;
  45122. /**
  45123. * If this is a cube texture
  45124. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45125. */
  45126. isCube: boolean;
  45127. /**
  45128. * If the texture is a compressed format eg. FOURCC_DXT1
  45129. */
  45130. isCompressed: boolean;
  45131. /**
  45132. * The dxgiFormat of the texture
  45133. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45134. */
  45135. dxgiFormat: number;
  45136. /**
  45137. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45138. */
  45139. textureType: number;
  45140. /**
  45141. * Sphericle polynomial created for the dds texture
  45142. */
  45143. sphericalPolynomial?: SphericalPolynomial;
  45144. }
  45145. /**
  45146. * Class used to provide DDS decompression tools
  45147. */
  45148. export class DDSTools {
  45149. /**
  45150. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45151. */
  45152. static StoreLODInAlphaChannel: boolean;
  45153. /**
  45154. * Gets DDS information from an array buffer
  45155. * @param arrayBuffer defines the array buffer to read data from
  45156. * @returns the DDS information
  45157. */
  45158. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45159. private static _FloatView;
  45160. private static _Int32View;
  45161. private static _ToHalfFloat;
  45162. private static _FromHalfFloat;
  45163. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45164. private static _GetHalfFloatRGBAArrayBuffer;
  45165. private static _GetFloatRGBAArrayBuffer;
  45166. private static _GetFloatAsUIntRGBAArrayBuffer;
  45167. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45168. private static _GetRGBAArrayBuffer;
  45169. private static _ExtractLongWordOrder;
  45170. private static _GetRGBArrayBuffer;
  45171. private static _GetLuminanceArrayBuffer;
  45172. /**
  45173. * Uploads DDS Levels to a Babylon Texture
  45174. * @hidden
  45175. */
  45176. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45177. }
  45178. interface Engine {
  45179. /**
  45180. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45181. * @param rootUrl defines the url where the file to load is located
  45182. * @param scene defines the current scene
  45183. * @param lodScale defines scale to apply to the mip map selection
  45184. * @param lodOffset defines offset to apply to the mip map selection
  45185. * @param onLoad defines an optional callback raised when the texture is loaded
  45186. * @param onError defines an optional callback raised if there is an issue to load the texture
  45187. * @param format defines the format of the data
  45188. * @param forcedExtension defines the extension to use to pick the right loader
  45189. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45190. * @returns the cube texture as an InternalTexture
  45191. */
  45192. 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;
  45193. }
  45194. }
  45195. declare module BABYLON {
  45196. /**
  45197. * Implementation of the DDS Texture Loader.
  45198. * @hidden
  45199. */
  45200. export class _DDSTextureLoader implements IInternalTextureLoader {
  45201. /**
  45202. * Defines wether the loader supports cascade loading the different faces.
  45203. */
  45204. readonly supportCascades: boolean;
  45205. /**
  45206. * This returns if the loader support the current file information.
  45207. * @param extension defines the file extension of the file being loaded
  45208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45209. * @param fallback defines the fallback internal texture if any
  45210. * @param isBase64 defines whether the texture is encoded as a base64
  45211. * @param isBuffer defines whether the texture data are stored as a buffer
  45212. * @returns true if the loader can load the specified file
  45213. */
  45214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45215. /**
  45216. * Transform the url before loading if required.
  45217. * @param rootUrl the url of the texture
  45218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45219. * @returns the transformed texture
  45220. */
  45221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45222. /**
  45223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45224. * @param rootUrl the url of the texture
  45225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45226. * @returns the fallback texture
  45227. */
  45228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45229. /**
  45230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45231. * @param data contains the texture data
  45232. * @param texture defines the BabylonJS internal texture
  45233. * @param createPolynomials will be true if polynomials have been requested
  45234. * @param onLoad defines the callback to trigger once the texture is ready
  45235. * @param onError defines the callback to trigger in case of error
  45236. */
  45237. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45238. /**
  45239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45240. * @param data contains the texture data
  45241. * @param texture defines the BabylonJS internal texture
  45242. * @param callback defines the method to call once ready to upload
  45243. */
  45244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45245. }
  45246. }
  45247. declare module BABYLON {
  45248. /** @hidden */
  45249. export var rgbdEncodePixelShader: {
  45250. name: string;
  45251. shader: string;
  45252. };
  45253. }
  45254. declare module BABYLON {
  45255. /**
  45256. * Raw texture data and descriptor sufficient for WebGL texture upload
  45257. */
  45258. export interface EnvironmentTextureInfo {
  45259. /**
  45260. * Version of the environment map
  45261. */
  45262. version: number;
  45263. /**
  45264. * Width of image
  45265. */
  45266. width: number;
  45267. /**
  45268. * Irradiance information stored in the file.
  45269. */
  45270. irradiance: any;
  45271. /**
  45272. * Specular information stored in the file.
  45273. */
  45274. specular: any;
  45275. }
  45276. /**
  45277. * Sets of helpers addressing the serialization and deserialization of environment texture
  45278. * stored in a BabylonJS env file.
  45279. * Those files are usually stored as .env files.
  45280. */
  45281. export class EnvironmentTextureTools {
  45282. /**
  45283. * Magic number identifying the env file.
  45284. */
  45285. private static _MagicBytes;
  45286. /**
  45287. * Gets the environment info from an env file.
  45288. * @param data The array buffer containing the .env bytes.
  45289. * @returns the environment file info (the json header) if successfully parsed.
  45290. */
  45291. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45292. /**
  45293. * Creates an environment texture from a loaded cube texture.
  45294. * @param texture defines the cube texture to convert in env file
  45295. * @return a promise containing the environment data if succesfull.
  45296. */
  45297. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45298. /**
  45299. * Creates a JSON representation of the spherical data.
  45300. * @param texture defines the texture containing the polynomials
  45301. * @return the JSON representation of the spherical info
  45302. */
  45303. private static _CreateEnvTextureIrradiance;
  45304. /**
  45305. * Uploads the texture info contained in the env file to the GPU.
  45306. * @param texture defines the internal texture to upload to
  45307. * @param arrayBuffer defines the buffer cotaining the data to load
  45308. * @param info defines the texture info retrieved through the GetEnvInfo method
  45309. * @returns a promise
  45310. */
  45311. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45312. /**
  45313. * Uploads the levels of image data to the GPU.
  45314. * @param texture defines the internal texture to upload to
  45315. * @param imageData defines the array buffer views of image data [mipmap][face]
  45316. * @returns a promise
  45317. */
  45318. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45319. /**
  45320. * Uploads spherical polynomials information to the texture.
  45321. * @param texture defines the texture we are trying to upload the information to
  45322. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45323. */
  45324. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45325. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45326. }
  45327. }
  45328. declare module BABYLON {
  45329. /**
  45330. * Implementation of the ENV Texture Loader.
  45331. * @hidden
  45332. */
  45333. export class _ENVTextureLoader implements IInternalTextureLoader {
  45334. /**
  45335. * Defines wether the loader supports cascade loading the different faces.
  45336. */
  45337. readonly supportCascades: boolean;
  45338. /**
  45339. * This returns if the loader support the current file information.
  45340. * @param extension defines the file extension of the file being loaded
  45341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45342. * @param fallback defines the fallback internal texture if any
  45343. * @param isBase64 defines whether the texture is encoded as a base64
  45344. * @param isBuffer defines whether the texture data are stored as a buffer
  45345. * @returns true if the loader can load the specified file
  45346. */
  45347. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45348. /**
  45349. * Transform the url before loading if required.
  45350. * @param rootUrl the url of the texture
  45351. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45352. * @returns the transformed texture
  45353. */
  45354. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45355. /**
  45356. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45357. * @param rootUrl the url of the texture
  45358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45359. * @returns the fallback texture
  45360. */
  45361. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45362. /**
  45363. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45364. * @param data contains the texture data
  45365. * @param texture defines the BabylonJS internal texture
  45366. * @param createPolynomials will be true if polynomials have been requested
  45367. * @param onLoad defines the callback to trigger once the texture is ready
  45368. * @param onError defines the callback to trigger in case of error
  45369. */
  45370. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45371. /**
  45372. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45373. * @param data contains the texture data
  45374. * @param texture defines the BabylonJS internal texture
  45375. * @param callback defines the method to call once ready to upload
  45376. */
  45377. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45378. }
  45379. }
  45380. declare module BABYLON {
  45381. /**
  45382. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45383. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45384. */
  45385. export class KhronosTextureContainer {
  45386. /** contents of the KTX container file */
  45387. arrayBuffer: any;
  45388. private static HEADER_LEN;
  45389. private static COMPRESSED_2D;
  45390. private static COMPRESSED_3D;
  45391. private static TEX_2D;
  45392. private static TEX_3D;
  45393. /**
  45394. * Gets the openGL type
  45395. */
  45396. glType: number;
  45397. /**
  45398. * Gets the openGL type size
  45399. */
  45400. glTypeSize: number;
  45401. /**
  45402. * Gets the openGL format
  45403. */
  45404. glFormat: number;
  45405. /**
  45406. * Gets the openGL internal format
  45407. */
  45408. glInternalFormat: number;
  45409. /**
  45410. * Gets the base internal format
  45411. */
  45412. glBaseInternalFormat: number;
  45413. /**
  45414. * Gets image width in pixel
  45415. */
  45416. pixelWidth: number;
  45417. /**
  45418. * Gets image height in pixel
  45419. */
  45420. pixelHeight: number;
  45421. /**
  45422. * Gets image depth in pixels
  45423. */
  45424. pixelDepth: number;
  45425. /**
  45426. * Gets the number of array elements
  45427. */
  45428. numberOfArrayElements: number;
  45429. /**
  45430. * Gets the number of faces
  45431. */
  45432. numberOfFaces: number;
  45433. /**
  45434. * Gets the number of mipmap levels
  45435. */
  45436. numberOfMipmapLevels: number;
  45437. /**
  45438. * Gets the bytes of key value data
  45439. */
  45440. bytesOfKeyValueData: number;
  45441. /**
  45442. * Gets the load type
  45443. */
  45444. loadType: number;
  45445. /**
  45446. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45447. */
  45448. isInvalid: boolean;
  45449. /**
  45450. * Creates a new KhronosTextureContainer
  45451. * @param arrayBuffer contents of the KTX container file
  45452. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45453. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45454. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45455. */
  45456. constructor(
  45457. /** contents of the KTX container file */
  45458. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45459. /**
  45460. * Uploads KTX content to a Babylon Texture.
  45461. * It is assumed that the texture has already been created & is currently bound
  45462. * @hidden
  45463. */
  45464. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45465. private _upload2DCompressedLevels;
  45466. }
  45467. }
  45468. declare module BABYLON {
  45469. /**
  45470. * Implementation of the KTX Texture Loader.
  45471. * @hidden
  45472. */
  45473. export class _KTXTextureLoader implements IInternalTextureLoader {
  45474. /**
  45475. * Defines wether the loader supports cascade loading the different faces.
  45476. */
  45477. readonly supportCascades: boolean;
  45478. /**
  45479. * This returns if the loader support the current file information.
  45480. * @param extension defines the file extension of the file being loaded
  45481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45482. * @param fallback defines the fallback internal texture if any
  45483. * @param isBase64 defines whether the texture is encoded as a base64
  45484. * @param isBuffer defines whether the texture data are stored as a buffer
  45485. * @returns true if the loader can load the specified file
  45486. */
  45487. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45488. /**
  45489. * Transform the url before loading if required.
  45490. * @param rootUrl the url of the texture
  45491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45492. * @returns the transformed texture
  45493. */
  45494. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45495. /**
  45496. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45497. * @param rootUrl the url of the texture
  45498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45499. * @returns the fallback texture
  45500. */
  45501. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45502. /**
  45503. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45504. * @param data contains the texture data
  45505. * @param texture defines the BabylonJS internal texture
  45506. * @param createPolynomials will be true if polynomials have been requested
  45507. * @param onLoad defines the callback to trigger once the texture is ready
  45508. * @param onError defines the callback to trigger in case of error
  45509. */
  45510. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45511. /**
  45512. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45513. * @param data contains the texture data
  45514. * @param texture defines the BabylonJS internal texture
  45515. * @param callback defines the method to call once ready to upload
  45516. */
  45517. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45518. }
  45519. }
  45520. declare module BABYLON {
  45521. /** @hidden */
  45522. export var _forceSceneHelpersToBundle: boolean;
  45523. interface Scene {
  45524. /**
  45525. * Creates a default light for the scene.
  45526. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45527. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45528. */
  45529. createDefaultLight(replace?: boolean): void;
  45530. /**
  45531. * Creates a default camera for the scene.
  45532. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45533. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45534. * @param replace has default false, when true replaces the active camera in the scene
  45535. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45536. */
  45537. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45538. /**
  45539. * Creates a default camera and a default light.
  45540. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45541. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45542. * @param replace has the default false, when true replaces the active camera/light in the scene
  45543. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45544. */
  45545. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45546. /**
  45547. * Creates a new sky box
  45548. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45549. * @param environmentTexture defines the texture to use as environment texture
  45550. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45551. * @param scale defines the overall scale of the skybox
  45552. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45553. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45554. * @returns a new mesh holding the sky box
  45555. */
  45556. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45557. /**
  45558. * Creates a new environment
  45559. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45560. * @param options defines the options you can use to configure the environment
  45561. * @returns the new EnvironmentHelper
  45562. */
  45563. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45564. /**
  45565. * Creates a new VREXperienceHelper
  45566. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45567. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45568. * @returns a new VREXperienceHelper
  45569. */
  45570. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45571. /**
  45572. * Creates a new XREXperienceHelper
  45573. * @see http://doc.babylonjs.com/how_to/webxr
  45574. * @returns a promise for a new XREXperienceHelper
  45575. */
  45576. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45577. }
  45578. }
  45579. declare module BABYLON {
  45580. /**
  45581. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45582. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45583. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45584. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45585. */
  45586. export class VideoDome extends TransformNode {
  45587. /**
  45588. * Define the video source as a Monoscopic panoramic 360 video.
  45589. */
  45590. static readonly MODE_MONOSCOPIC: number;
  45591. /**
  45592. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45593. */
  45594. static readonly MODE_TOPBOTTOM: number;
  45595. /**
  45596. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45597. */
  45598. static readonly MODE_SIDEBYSIDE: number;
  45599. private _useDirectMapping;
  45600. /**
  45601. * The video texture being displayed on the sphere
  45602. */
  45603. protected _videoTexture: VideoTexture;
  45604. /**
  45605. * Gets the video texture being displayed on the sphere
  45606. */
  45607. readonly videoTexture: VideoTexture;
  45608. /**
  45609. * The skybox material
  45610. */
  45611. protected _material: BackgroundMaterial;
  45612. /**
  45613. * The surface used for the skybox
  45614. */
  45615. protected _mesh: Mesh;
  45616. /**
  45617. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45618. * Also see the options.resolution property.
  45619. */
  45620. fovMultiplier: number;
  45621. private _videoMode;
  45622. /**
  45623. * Gets or set the current video mode for the video. It can be:
  45624. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45625. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45626. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45627. */
  45628. videoMode: number;
  45629. /**
  45630. * Oberserver used in Stereoscopic VR Mode.
  45631. */
  45632. private _onBeforeCameraRenderObserver;
  45633. /**
  45634. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45635. * @param name Element's name, child elements will append suffixes for their own names.
  45636. * @param urlsOrVideo defines the url(s) or the video element to use
  45637. * @param options An object containing optional or exposed sub element properties
  45638. */
  45639. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45640. resolution?: number;
  45641. clickToPlay?: boolean;
  45642. autoPlay?: boolean;
  45643. loop?: boolean;
  45644. size?: number;
  45645. poster?: string;
  45646. faceForward?: boolean;
  45647. useDirectMapping?: boolean;
  45648. }, scene: Scene);
  45649. private _changeVideoMode;
  45650. /**
  45651. * Releases resources associated with this node.
  45652. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45653. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45654. */
  45655. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45656. }
  45657. }
  45658. declare module BABYLON {
  45659. /**
  45660. * This class can be used to get instrumentation data from a Babylon engine
  45661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45662. */
  45663. export class EngineInstrumentation implements IDisposable {
  45664. /**
  45665. * Define the instrumented engine.
  45666. */
  45667. engine: Engine;
  45668. private _captureGPUFrameTime;
  45669. private _gpuFrameTimeToken;
  45670. private _gpuFrameTime;
  45671. private _captureShaderCompilationTime;
  45672. private _shaderCompilationTime;
  45673. private _onBeginFrameObserver;
  45674. private _onEndFrameObserver;
  45675. private _onBeforeShaderCompilationObserver;
  45676. private _onAfterShaderCompilationObserver;
  45677. /**
  45678. * Gets the perf counter used for GPU frame time
  45679. */
  45680. readonly gpuFrameTimeCounter: PerfCounter;
  45681. /**
  45682. * Gets the GPU frame time capture status
  45683. */
  45684. /**
  45685. * Enable or disable the GPU frame time capture
  45686. */
  45687. captureGPUFrameTime: boolean;
  45688. /**
  45689. * Gets the perf counter used for shader compilation time
  45690. */
  45691. readonly shaderCompilationTimeCounter: PerfCounter;
  45692. /**
  45693. * Gets the shader compilation time capture status
  45694. */
  45695. /**
  45696. * Enable or disable the shader compilation time capture
  45697. */
  45698. captureShaderCompilationTime: boolean;
  45699. /**
  45700. * Instantiates a new engine instrumentation.
  45701. * This class can be used to get instrumentation data from a Babylon engine
  45702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45703. * @param engine Defines the engine to instrument
  45704. */
  45705. constructor(
  45706. /**
  45707. * Define the instrumented engine.
  45708. */
  45709. engine: Engine);
  45710. /**
  45711. * Dispose and release associated resources.
  45712. */
  45713. dispose(): void;
  45714. }
  45715. }
  45716. declare module BABYLON {
  45717. /**
  45718. * This class can be used to get instrumentation data from a Babylon engine
  45719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45720. */
  45721. export class SceneInstrumentation implements IDisposable {
  45722. /**
  45723. * Defines the scene to instrument
  45724. */
  45725. scene: Scene;
  45726. private _captureActiveMeshesEvaluationTime;
  45727. private _activeMeshesEvaluationTime;
  45728. private _captureRenderTargetsRenderTime;
  45729. private _renderTargetsRenderTime;
  45730. private _captureFrameTime;
  45731. private _frameTime;
  45732. private _captureRenderTime;
  45733. private _renderTime;
  45734. private _captureInterFrameTime;
  45735. private _interFrameTime;
  45736. private _captureParticlesRenderTime;
  45737. private _particlesRenderTime;
  45738. private _captureSpritesRenderTime;
  45739. private _spritesRenderTime;
  45740. private _capturePhysicsTime;
  45741. private _physicsTime;
  45742. private _captureAnimationsTime;
  45743. private _animationsTime;
  45744. private _captureCameraRenderTime;
  45745. private _cameraRenderTime;
  45746. private _onBeforeActiveMeshesEvaluationObserver;
  45747. private _onAfterActiveMeshesEvaluationObserver;
  45748. private _onBeforeRenderTargetsRenderObserver;
  45749. private _onAfterRenderTargetsRenderObserver;
  45750. private _onAfterRenderObserver;
  45751. private _onBeforeDrawPhaseObserver;
  45752. private _onAfterDrawPhaseObserver;
  45753. private _onBeforeAnimationsObserver;
  45754. private _onBeforeParticlesRenderingObserver;
  45755. private _onAfterParticlesRenderingObserver;
  45756. private _onBeforeSpritesRenderingObserver;
  45757. private _onAfterSpritesRenderingObserver;
  45758. private _onBeforePhysicsObserver;
  45759. private _onAfterPhysicsObserver;
  45760. private _onAfterAnimationsObserver;
  45761. private _onBeforeCameraRenderObserver;
  45762. private _onAfterCameraRenderObserver;
  45763. /**
  45764. * Gets the perf counter used for active meshes evaluation time
  45765. */
  45766. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45767. /**
  45768. * Gets the active meshes evaluation time capture status
  45769. */
  45770. /**
  45771. * Enable or disable the active meshes evaluation time capture
  45772. */
  45773. captureActiveMeshesEvaluationTime: boolean;
  45774. /**
  45775. * Gets the perf counter used for render targets render time
  45776. */
  45777. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45778. /**
  45779. * Gets the render targets render time capture status
  45780. */
  45781. /**
  45782. * Enable or disable the render targets render time capture
  45783. */
  45784. captureRenderTargetsRenderTime: boolean;
  45785. /**
  45786. * Gets the perf counter used for particles render time
  45787. */
  45788. readonly particlesRenderTimeCounter: PerfCounter;
  45789. /**
  45790. * Gets the particles render time capture status
  45791. */
  45792. /**
  45793. * Enable or disable the particles render time capture
  45794. */
  45795. captureParticlesRenderTime: boolean;
  45796. /**
  45797. * Gets the perf counter used for sprites render time
  45798. */
  45799. readonly spritesRenderTimeCounter: PerfCounter;
  45800. /**
  45801. * Gets the sprites render time capture status
  45802. */
  45803. /**
  45804. * Enable or disable the sprites render time capture
  45805. */
  45806. captureSpritesRenderTime: boolean;
  45807. /**
  45808. * Gets the perf counter used for physics time
  45809. */
  45810. readonly physicsTimeCounter: PerfCounter;
  45811. /**
  45812. * Gets the physics time capture status
  45813. */
  45814. /**
  45815. * Enable or disable the physics time capture
  45816. */
  45817. capturePhysicsTime: boolean;
  45818. /**
  45819. * Gets the perf counter used for animations time
  45820. */
  45821. readonly animationsTimeCounter: PerfCounter;
  45822. /**
  45823. * Gets the animations time capture status
  45824. */
  45825. /**
  45826. * Enable or disable the animations time capture
  45827. */
  45828. captureAnimationsTime: boolean;
  45829. /**
  45830. * Gets the perf counter used for frame time capture
  45831. */
  45832. readonly frameTimeCounter: PerfCounter;
  45833. /**
  45834. * Gets the frame time capture status
  45835. */
  45836. /**
  45837. * Enable or disable the frame time capture
  45838. */
  45839. captureFrameTime: boolean;
  45840. /**
  45841. * Gets the perf counter used for inter-frames time capture
  45842. */
  45843. readonly interFrameTimeCounter: PerfCounter;
  45844. /**
  45845. * Gets the inter-frames time capture status
  45846. */
  45847. /**
  45848. * Enable or disable the inter-frames time capture
  45849. */
  45850. captureInterFrameTime: boolean;
  45851. /**
  45852. * Gets the perf counter used for render time capture
  45853. */
  45854. readonly renderTimeCounter: PerfCounter;
  45855. /**
  45856. * Gets the render time capture status
  45857. */
  45858. /**
  45859. * Enable or disable the render time capture
  45860. */
  45861. captureRenderTime: boolean;
  45862. /**
  45863. * Gets the perf counter used for camera render time capture
  45864. */
  45865. readonly cameraRenderTimeCounter: PerfCounter;
  45866. /**
  45867. * Gets the camera render time capture status
  45868. */
  45869. /**
  45870. * Enable or disable the camera render time capture
  45871. */
  45872. captureCameraRenderTime: boolean;
  45873. /**
  45874. * Gets the perf counter used for draw calls
  45875. */
  45876. readonly drawCallsCounter: PerfCounter;
  45877. /**
  45878. * Instantiates a new scene instrumentation.
  45879. * This class can be used to get instrumentation data from a Babylon engine
  45880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45881. * @param scene Defines the scene to instrument
  45882. */
  45883. constructor(
  45884. /**
  45885. * Defines the scene to instrument
  45886. */
  45887. scene: Scene);
  45888. /**
  45889. * Dispose and release associated resources.
  45890. */
  45891. dispose(): void;
  45892. }
  45893. }
  45894. declare module BABYLON {
  45895. /** @hidden */
  45896. export var glowMapGenerationPixelShader: {
  45897. name: string;
  45898. shader: string;
  45899. };
  45900. }
  45901. declare module BABYLON {
  45902. /** @hidden */
  45903. export var glowMapGenerationVertexShader: {
  45904. name: string;
  45905. shader: string;
  45906. };
  45907. }
  45908. declare module BABYLON {
  45909. /**
  45910. * Effect layer options. This helps customizing the behaviour
  45911. * of the effect layer.
  45912. */
  45913. export interface IEffectLayerOptions {
  45914. /**
  45915. * Multiplication factor apply to the canvas size to compute the render target size
  45916. * used to generated the objects (the smaller the faster).
  45917. */
  45918. mainTextureRatio: number;
  45919. /**
  45920. * Enforces a fixed size texture to ensure effect stability across devices.
  45921. */
  45922. mainTextureFixedSize?: number;
  45923. /**
  45924. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45925. */
  45926. alphaBlendingMode: number;
  45927. /**
  45928. * The camera attached to the layer.
  45929. */
  45930. camera: Nullable<Camera>;
  45931. /**
  45932. * The rendering group to draw the layer in.
  45933. */
  45934. renderingGroupId: number;
  45935. }
  45936. /**
  45937. * The effect layer Helps adding post process effect blended with the main pass.
  45938. *
  45939. * This can be for instance use to generate glow or higlight effects on the scene.
  45940. *
  45941. * The effect layer class can not be used directly and is intented to inherited from to be
  45942. * customized per effects.
  45943. */
  45944. export abstract class EffectLayer {
  45945. private _vertexBuffers;
  45946. private _indexBuffer;
  45947. private _cachedDefines;
  45948. private _effectLayerMapGenerationEffect;
  45949. private _effectLayerOptions;
  45950. private _mergeEffect;
  45951. protected _scene: Scene;
  45952. protected _engine: Engine;
  45953. protected _maxSize: number;
  45954. protected _mainTextureDesiredSize: ISize;
  45955. protected _mainTexture: RenderTargetTexture;
  45956. protected _shouldRender: boolean;
  45957. protected _postProcesses: PostProcess[];
  45958. protected _textures: BaseTexture[];
  45959. protected _emissiveTextureAndColor: {
  45960. texture: Nullable<BaseTexture>;
  45961. color: Color4;
  45962. };
  45963. /**
  45964. * The name of the layer
  45965. */
  45966. name: string;
  45967. /**
  45968. * The clear color of the texture used to generate the glow map.
  45969. */
  45970. neutralColor: Color4;
  45971. /**
  45972. * Specifies wether the highlight layer is enabled or not.
  45973. */
  45974. isEnabled: boolean;
  45975. /**
  45976. * Gets the camera attached to the layer.
  45977. */
  45978. readonly camera: Nullable<Camera>;
  45979. /**
  45980. * Gets the rendering group id the layer should render in.
  45981. */
  45982. readonly renderingGroupId: number;
  45983. /**
  45984. * An event triggered when the effect layer has been disposed.
  45985. */
  45986. onDisposeObservable: Observable<EffectLayer>;
  45987. /**
  45988. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45989. */
  45990. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45991. /**
  45992. * An event triggered when the generated texture is being merged in the scene.
  45993. */
  45994. onBeforeComposeObservable: Observable<EffectLayer>;
  45995. /**
  45996. * An event triggered when the generated texture has been merged in the scene.
  45997. */
  45998. onAfterComposeObservable: Observable<EffectLayer>;
  45999. /**
  46000. * An event triggered when the efffect layer changes its size.
  46001. */
  46002. onSizeChangedObservable: Observable<EffectLayer>;
  46003. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46004. /**
  46005. * Instantiates a new effect Layer and references it in the scene.
  46006. * @param name The name of the layer
  46007. * @param scene The scene to use the layer in
  46008. */
  46009. constructor(
  46010. /** The Friendly of the effect in the scene */
  46011. name: string, scene: Scene);
  46012. /**
  46013. * Get the effect name of the layer.
  46014. * @return The effect name
  46015. */
  46016. abstract getEffectName(): string;
  46017. /**
  46018. * Checks for the readiness of the element composing the layer.
  46019. * @param subMesh the mesh to check for
  46020. * @param useInstances specify wether or not to use instances to render the mesh
  46021. * @return true if ready otherwise, false
  46022. */
  46023. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46024. /**
  46025. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46026. * @returns true if the effect requires stencil during the main canvas render pass.
  46027. */
  46028. abstract needStencil(): boolean;
  46029. /**
  46030. * Create the merge effect. This is the shader use to blit the information back
  46031. * to the main canvas at the end of the scene rendering.
  46032. * @returns The effect containing the shader used to merge the effect on the main canvas
  46033. */
  46034. protected abstract _createMergeEffect(): Effect;
  46035. /**
  46036. * Creates the render target textures and post processes used in the effect layer.
  46037. */
  46038. protected abstract _createTextureAndPostProcesses(): void;
  46039. /**
  46040. * Implementation specific of rendering the generating effect on the main canvas.
  46041. * @param effect The effect used to render through
  46042. */
  46043. protected abstract _internalRender(effect: Effect): void;
  46044. /**
  46045. * Sets the required values for both the emissive texture and and the main color.
  46046. */
  46047. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46048. /**
  46049. * Free any resources and references associated to a mesh.
  46050. * Internal use
  46051. * @param mesh The mesh to free.
  46052. */
  46053. abstract _disposeMesh(mesh: Mesh): void;
  46054. /**
  46055. * Serializes this layer (Glow or Highlight for example)
  46056. * @returns a serialized layer object
  46057. */
  46058. abstract serialize?(): any;
  46059. /**
  46060. * Initializes the effect layer with the required options.
  46061. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46062. */
  46063. protected _init(options: Partial<IEffectLayerOptions>): void;
  46064. /**
  46065. * Generates the index buffer of the full screen quad blending to the main canvas.
  46066. */
  46067. private _generateIndexBuffer;
  46068. /**
  46069. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46070. */
  46071. private _genrateVertexBuffer;
  46072. /**
  46073. * Sets the main texture desired size which is the closest power of two
  46074. * of the engine canvas size.
  46075. */
  46076. private _setMainTextureSize;
  46077. /**
  46078. * Creates the main texture for the effect layer.
  46079. */
  46080. protected _createMainTexture(): void;
  46081. /**
  46082. * Adds specific effects defines.
  46083. * @param defines The defines to add specifics to.
  46084. */
  46085. protected _addCustomEffectDefines(defines: string[]): void;
  46086. /**
  46087. * Checks for the readiness of the element composing the layer.
  46088. * @param subMesh the mesh to check for
  46089. * @param useInstances specify wether or not to use instances to render the mesh
  46090. * @param emissiveTexture the associated emissive texture used to generate the glow
  46091. * @return true if ready otherwise, false
  46092. */
  46093. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46094. /**
  46095. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46096. */
  46097. render(): void;
  46098. /**
  46099. * Determine if a given mesh will be used in the current effect.
  46100. * @param mesh mesh to test
  46101. * @returns true if the mesh will be used
  46102. */
  46103. hasMesh(mesh: AbstractMesh): boolean;
  46104. /**
  46105. * Returns true if the layer contains information to display, otherwise false.
  46106. * @returns true if the glow layer should be rendered
  46107. */
  46108. shouldRender(): boolean;
  46109. /**
  46110. * Returns true if the mesh should render, otherwise false.
  46111. * @param mesh The mesh to render
  46112. * @returns true if it should render otherwise false
  46113. */
  46114. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46115. /**
  46116. * Returns true if the mesh can be rendered, otherwise false.
  46117. * @param mesh The mesh to render
  46118. * @param material The material used on the mesh
  46119. * @returns true if it can be rendered otherwise false
  46120. */
  46121. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46122. /**
  46123. * Returns true if the mesh should render, otherwise false.
  46124. * @param mesh The mesh to render
  46125. * @returns true if it should render otherwise false
  46126. */
  46127. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46128. /**
  46129. * Renders the submesh passed in parameter to the generation map.
  46130. */
  46131. protected _renderSubMesh(subMesh: SubMesh): void;
  46132. /**
  46133. * Rebuild the required buffers.
  46134. * @hidden Internal use only.
  46135. */ rebuild(): void;
  46136. /**
  46137. * Dispose only the render target textures and post process.
  46138. */
  46139. private _disposeTextureAndPostProcesses;
  46140. /**
  46141. * Dispose the highlight layer and free resources.
  46142. */
  46143. dispose(): void;
  46144. /**
  46145. * Gets the class name of the effect layer
  46146. * @returns the string with the class name of the effect layer
  46147. */
  46148. getClassName(): string;
  46149. /**
  46150. * Creates an effect layer from parsed effect layer data
  46151. * @param parsedEffectLayer defines effect layer data
  46152. * @param scene defines the current scene
  46153. * @param rootUrl defines the root URL containing the effect layer information
  46154. * @returns a parsed effect Layer
  46155. */
  46156. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46157. }
  46158. }
  46159. declare module BABYLON {
  46160. interface AbstractScene {
  46161. /**
  46162. * The list of effect layers (highlights/glow) added to the scene
  46163. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46164. * @see http://doc.babylonjs.com/how_to/glow_layer
  46165. */
  46166. effectLayers: Array<EffectLayer>;
  46167. /**
  46168. * Removes the given effect layer from this scene.
  46169. * @param toRemove defines the effect layer to remove
  46170. * @returns the index of the removed effect layer
  46171. */
  46172. removeEffectLayer(toRemove: EffectLayer): number;
  46173. /**
  46174. * Adds the given effect layer to this scene
  46175. * @param newEffectLayer defines the effect layer to add
  46176. */
  46177. addEffectLayer(newEffectLayer: EffectLayer): void;
  46178. }
  46179. /**
  46180. * Defines the layer scene component responsible to manage any effect layers
  46181. * in a given scene.
  46182. */
  46183. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46184. /**
  46185. * The component name helpfull to identify the component in the list of scene components.
  46186. */
  46187. readonly name: string;
  46188. /**
  46189. * The scene the component belongs to.
  46190. */
  46191. scene: Scene;
  46192. private _engine;
  46193. private _renderEffects;
  46194. private _needStencil;
  46195. private _previousStencilState;
  46196. /**
  46197. * Creates a new instance of the component for the given scene
  46198. * @param scene Defines the scene to register the component in
  46199. */
  46200. constructor(scene: Scene);
  46201. /**
  46202. * Registers the component in a given scene
  46203. */
  46204. register(): void;
  46205. /**
  46206. * Rebuilds the elements related to this component in case of
  46207. * context lost for instance.
  46208. */
  46209. rebuild(): void;
  46210. /**
  46211. * Serializes the component data to the specified json object
  46212. * @param serializationObject The object to serialize to
  46213. */
  46214. serialize(serializationObject: any): void;
  46215. /**
  46216. * Adds all the element from the container to the scene
  46217. * @param container the container holding the elements
  46218. */
  46219. addFromContainer(container: AbstractScene): void;
  46220. /**
  46221. * Removes all the elements in the container from the scene
  46222. * @param container contains the elements to remove
  46223. * @param dispose if the removed element should be disposed (default: false)
  46224. */
  46225. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46226. /**
  46227. * Disposes the component and the associated ressources.
  46228. */
  46229. dispose(): void;
  46230. private _isReadyForMesh;
  46231. private _renderMainTexture;
  46232. private _setStencil;
  46233. private _setStencilBack;
  46234. private _draw;
  46235. private _drawCamera;
  46236. private _drawRenderingGroup;
  46237. }
  46238. }
  46239. declare module BABYLON {
  46240. /** @hidden */
  46241. export var glowMapMergePixelShader: {
  46242. name: string;
  46243. shader: string;
  46244. };
  46245. }
  46246. declare module BABYLON {
  46247. /** @hidden */
  46248. export var glowMapMergeVertexShader: {
  46249. name: string;
  46250. shader: string;
  46251. };
  46252. }
  46253. declare module BABYLON {
  46254. interface AbstractScene {
  46255. /**
  46256. * Return a the first highlight layer of the scene with a given name.
  46257. * @param name The name of the highlight layer to look for.
  46258. * @return The highlight layer if found otherwise null.
  46259. */
  46260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46261. }
  46262. /**
  46263. * Glow layer options. This helps customizing the behaviour
  46264. * of the glow layer.
  46265. */
  46266. export interface IGlowLayerOptions {
  46267. /**
  46268. * Multiplication factor apply to the canvas size to compute the render target size
  46269. * used to generated the glowing objects (the smaller the faster).
  46270. */
  46271. mainTextureRatio: number;
  46272. /**
  46273. * Enforces a fixed size texture to ensure resize independant blur.
  46274. */
  46275. mainTextureFixedSize?: number;
  46276. /**
  46277. * How big is the kernel of the blur texture.
  46278. */
  46279. blurKernelSize: number;
  46280. /**
  46281. * The camera attached to the layer.
  46282. */
  46283. camera: Nullable<Camera>;
  46284. /**
  46285. * Enable MSAA by chosing the number of samples.
  46286. */
  46287. mainTextureSamples?: number;
  46288. /**
  46289. * The rendering group to draw the layer in.
  46290. */
  46291. renderingGroupId: number;
  46292. }
  46293. /**
  46294. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46295. *
  46296. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46297. * glowy meshes to your scene.
  46298. *
  46299. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46300. */
  46301. export class GlowLayer extends EffectLayer {
  46302. /**
  46303. * Effect Name of the layer.
  46304. */
  46305. static readonly EffectName: string;
  46306. /**
  46307. * The default blur kernel size used for the glow.
  46308. */
  46309. static DefaultBlurKernelSize: number;
  46310. /**
  46311. * The default texture size ratio used for the glow.
  46312. */
  46313. static DefaultTextureRatio: number;
  46314. /**
  46315. * Sets the kernel size of the blur.
  46316. */
  46317. /**
  46318. * Gets the kernel size of the blur.
  46319. */
  46320. blurKernelSize: number;
  46321. /**
  46322. * Sets the glow intensity.
  46323. */
  46324. /**
  46325. * Gets the glow intensity.
  46326. */
  46327. intensity: number;
  46328. private _options;
  46329. private _intensity;
  46330. private _horizontalBlurPostprocess1;
  46331. private _verticalBlurPostprocess1;
  46332. private _horizontalBlurPostprocess2;
  46333. private _verticalBlurPostprocess2;
  46334. private _blurTexture1;
  46335. private _blurTexture2;
  46336. private _postProcesses1;
  46337. private _postProcesses2;
  46338. private _includedOnlyMeshes;
  46339. private _excludedMeshes;
  46340. /**
  46341. * Callback used to let the user override the color selection on a per mesh basis
  46342. */
  46343. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46344. /**
  46345. * Callback used to let the user override the texture selection on a per mesh basis
  46346. */
  46347. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46348. /**
  46349. * Instantiates a new glow Layer and references it to the scene.
  46350. * @param name The name of the layer
  46351. * @param scene The scene to use the layer in
  46352. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46353. */
  46354. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46355. /**
  46356. * Get the effect name of the layer.
  46357. * @return The effect name
  46358. */
  46359. getEffectName(): string;
  46360. /**
  46361. * Create the merge effect. This is the shader use to blit the information back
  46362. * to the main canvas at the end of the scene rendering.
  46363. */
  46364. protected _createMergeEffect(): Effect;
  46365. /**
  46366. * Creates the render target textures and post processes used in the glow layer.
  46367. */
  46368. protected _createTextureAndPostProcesses(): void;
  46369. /**
  46370. * Checks for the readiness of the element composing the layer.
  46371. * @param subMesh the mesh to check for
  46372. * @param useInstances specify wether or not to use instances to render the mesh
  46373. * @param emissiveTexture the associated emissive texture used to generate the glow
  46374. * @return true if ready otherwise, false
  46375. */
  46376. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46377. /**
  46378. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46379. */
  46380. needStencil(): boolean;
  46381. /**
  46382. * Returns true if the mesh can be rendered, otherwise false.
  46383. * @param mesh The mesh to render
  46384. * @param material The material used on the mesh
  46385. * @returns true if it can be rendered otherwise false
  46386. */
  46387. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46388. /**
  46389. * Implementation specific of rendering the generating effect on the main canvas.
  46390. * @param effect The effect used to render through
  46391. */
  46392. protected _internalRender(effect: Effect): void;
  46393. /**
  46394. * Sets the required values for both the emissive texture and and the main color.
  46395. */
  46396. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46397. /**
  46398. * Returns true if the mesh should render, otherwise false.
  46399. * @param mesh The mesh to render
  46400. * @returns true if it should render otherwise false
  46401. */
  46402. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46403. /**
  46404. * Adds specific effects defines.
  46405. * @param defines The defines to add specifics to.
  46406. */
  46407. protected _addCustomEffectDefines(defines: string[]): void;
  46408. /**
  46409. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46410. * @param mesh The mesh to exclude from the glow layer
  46411. */
  46412. addExcludedMesh(mesh: Mesh): void;
  46413. /**
  46414. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46415. * @param mesh The mesh to remove
  46416. */
  46417. removeExcludedMesh(mesh: Mesh): void;
  46418. /**
  46419. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46420. * @param mesh The mesh to include in the glow layer
  46421. */
  46422. addIncludedOnlyMesh(mesh: Mesh): void;
  46423. /**
  46424. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46425. * @param mesh The mesh to remove
  46426. */
  46427. removeIncludedOnlyMesh(mesh: Mesh): void;
  46428. /**
  46429. * Determine if a given mesh will be used in the glow layer
  46430. * @param mesh The mesh to test
  46431. * @returns true if the mesh will be highlighted by the current glow layer
  46432. */
  46433. hasMesh(mesh: AbstractMesh): boolean;
  46434. /**
  46435. * Free any resources and references associated to a mesh.
  46436. * Internal use
  46437. * @param mesh The mesh to free.
  46438. * @hidden
  46439. */ disposeMesh(mesh: Mesh): void;
  46440. /**
  46441. * Gets the class name of the effect layer
  46442. * @returns the string with the class name of the effect layer
  46443. */
  46444. getClassName(): string;
  46445. /**
  46446. * Serializes this glow layer
  46447. * @returns a serialized glow layer object
  46448. */
  46449. serialize(): any;
  46450. /**
  46451. * Creates a Glow Layer from parsed glow layer data
  46452. * @param parsedGlowLayer defines glow layer data
  46453. * @param scene defines the current scene
  46454. * @param rootUrl defines the root URL containing the glow layer information
  46455. * @returns a parsed Glow Layer
  46456. */
  46457. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46458. }
  46459. }
  46460. declare module BABYLON {
  46461. /** @hidden */
  46462. export var glowBlurPostProcessPixelShader: {
  46463. name: string;
  46464. shader: string;
  46465. };
  46466. }
  46467. declare module BABYLON {
  46468. interface AbstractScene {
  46469. /**
  46470. * Return a the first highlight layer of the scene with a given name.
  46471. * @param name The name of the highlight layer to look for.
  46472. * @return The highlight layer if found otherwise null.
  46473. */
  46474. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46475. }
  46476. /**
  46477. * Highlight layer options. This helps customizing the behaviour
  46478. * of the highlight layer.
  46479. */
  46480. export interface IHighlightLayerOptions {
  46481. /**
  46482. * Multiplication factor apply to the canvas size to compute the render target size
  46483. * used to generated the glowing objects (the smaller the faster).
  46484. */
  46485. mainTextureRatio: number;
  46486. /**
  46487. * Enforces a fixed size texture to ensure resize independant blur.
  46488. */
  46489. mainTextureFixedSize?: number;
  46490. /**
  46491. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46492. * of the picture to blur (the smaller the faster).
  46493. */
  46494. blurTextureSizeRatio: number;
  46495. /**
  46496. * How big in texel of the blur texture is the vertical blur.
  46497. */
  46498. blurVerticalSize: number;
  46499. /**
  46500. * How big in texel of the blur texture is the horizontal blur.
  46501. */
  46502. blurHorizontalSize: number;
  46503. /**
  46504. * Alpha blending mode used to apply the blur. Default is combine.
  46505. */
  46506. alphaBlendingMode: number;
  46507. /**
  46508. * The camera attached to the layer.
  46509. */
  46510. camera: Nullable<Camera>;
  46511. /**
  46512. * Should we display highlight as a solid stroke?
  46513. */
  46514. isStroke?: boolean;
  46515. /**
  46516. * The rendering group to draw the layer in.
  46517. */
  46518. renderingGroupId: number;
  46519. }
  46520. /**
  46521. * The highlight layer Helps adding a glow effect around a mesh.
  46522. *
  46523. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46524. * glowy meshes to your scene.
  46525. *
  46526. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46527. */
  46528. export class HighlightLayer extends EffectLayer {
  46529. name: string;
  46530. /**
  46531. * Effect Name of the highlight layer.
  46532. */
  46533. static readonly EffectName: string;
  46534. /**
  46535. * The neutral color used during the preparation of the glow effect.
  46536. * This is black by default as the blend operation is a blend operation.
  46537. */
  46538. static NeutralColor: Color4;
  46539. /**
  46540. * Stencil value used for glowing meshes.
  46541. */
  46542. static GlowingMeshStencilReference: number;
  46543. /**
  46544. * Stencil value used for the other meshes in the scene.
  46545. */
  46546. static NormalMeshStencilReference: number;
  46547. /**
  46548. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46549. */
  46550. innerGlow: boolean;
  46551. /**
  46552. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46553. */
  46554. outerGlow: boolean;
  46555. /**
  46556. * Specifies the horizontal size of the blur.
  46557. */
  46558. /**
  46559. * Gets the horizontal size of the blur.
  46560. */
  46561. blurHorizontalSize: number;
  46562. /**
  46563. * Specifies the vertical size of the blur.
  46564. */
  46565. /**
  46566. * Gets the vertical size of the blur.
  46567. */
  46568. blurVerticalSize: number;
  46569. /**
  46570. * An event triggered when the highlight layer is being blurred.
  46571. */
  46572. onBeforeBlurObservable: Observable<HighlightLayer>;
  46573. /**
  46574. * An event triggered when the highlight layer has been blurred.
  46575. */
  46576. onAfterBlurObservable: Observable<HighlightLayer>;
  46577. private _instanceGlowingMeshStencilReference;
  46578. private _options;
  46579. private _downSamplePostprocess;
  46580. private _horizontalBlurPostprocess;
  46581. private _verticalBlurPostprocess;
  46582. private _blurTexture;
  46583. private _meshes;
  46584. private _excludedMeshes;
  46585. /**
  46586. * Instantiates a new highlight Layer and references it to the scene..
  46587. * @param name The name of the layer
  46588. * @param scene The scene to use the layer in
  46589. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46590. */
  46591. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46592. /**
  46593. * Get the effect name of the layer.
  46594. * @return The effect name
  46595. */
  46596. getEffectName(): string;
  46597. /**
  46598. * Create the merge effect. This is the shader use to blit the information back
  46599. * to the main canvas at the end of the scene rendering.
  46600. */
  46601. protected _createMergeEffect(): Effect;
  46602. /**
  46603. * Creates the render target textures and post processes used in the highlight layer.
  46604. */
  46605. protected _createTextureAndPostProcesses(): void;
  46606. /**
  46607. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46608. */
  46609. needStencil(): boolean;
  46610. /**
  46611. * Checks for the readiness of the element composing the layer.
  46612. * @param subMesh the mesh to check for
  46613. * @param useInstances specify wether or not to use instances to render the mesh
  46614. * @param emissiveTexture the associated emissive texture used to generate the glow
  46615. * @return true if ready otherwise, false
  46616. */
  46617. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46618. /**
  46619. * Implementation specific of rendering the generating effect on the main canvas.
  46620. * @param effect The effect used to render through
  46621. */
  46622. protected _internalRender(effect: Effect): void;
  46623. /**
  46624. * Returns true if the layer contains information to display, otherwise false.
  46625. */
  46626. shouldRender(): boolean;
  46627. /**
  46628. * Returns true if the mesh should render, otherwise false.
  46629. * @param mesh The mesh to render
  46630. * @returns true if it should render otherwise false
  46631. */
  46632. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46633. /**
  46634. * Sets the required values for both the emissive texture and and the main color.
  46635. */
  46636. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46637. /**
  46638. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46639. * @param mesh The mesh to exclude from the highlight layer
  46640. */
  46641. addExcludedMesh(mesh: Mesh): void;
  46642. /**
  46643. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46644. * @param mesh The mesh to highlight
  46645. */
  46646. removeExcludedMesh(mesh: Mesh): void;
  46647. /**
  46648. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46649. * @param mesh mesh to test
  46650. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46651. */
  46652. hasMesh(mesh: AbstractMesh): boolean;
  46653. /**
  46654. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46655. * @param mesh The mesh to highlight
  46656. * @param color The color of the highlight
  46657. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46658. */
  46659. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46660. /**
  46661. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46662. * @param mesh The mesh to highlight
  46663. */
  46664. removeMesh(mesh: Mesh): void;
  46665. /**
  46666. * Force the stencil to the normal expected value for none glowing parts
  46667. */
  46668. private _defaultStencilReference;
  46669. /**
  46670. * Free any resources and references associated to a mesh.
  46671. * Internal use
  46672. * @param mesh The mesh to free.
  46673. * @hidden
  46674. */ disposeMesh(mesh: Mesh): void;
  46675. /**
  46676. * Dispose the highlight layer and free resources.
  46677. */
  46678. dispose(): void;
  46679. /**
  46680. * Gets the class name of the effect layer
  46681. * @returns the string with the class name of the effect layer
  46682. */
  46683. getClassName(): string;
  46684. /**
  46685. * Serializes this Highlight layer
  46686. * @returns a serialized Highlight layer object
  46687. */
  46688. serialize(): any;
  46689. /**
  46690. * Creates a Highlight layer from parsed Highlight layer data
  46691. * @param parsedHightlightLayer defines the Highlight layer data
  46692. * @param scene defines the current scene
  46693. * @param rootUrl defines the root URL containing the Highlight layer information
  46694. * @returns a parsed Highlight layer
  46695. */
  46696. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46697. }
  46698. }
  46699. declare module BABYLON {
  46700. /** @hidden */
  46701. export var lensFlarePixelShader: {
  46702. name: string;
  46703. shader: string;
  46704. };
  46705. }
  46706. declare module BABYLON {
  46707. /** @hidden */
  46708. export var lensFlareVertexShader: {
  46709. name: string;
  46710. shader: string;
  46711. };
  46712. }
  46713. declare module BABYLON {
  46714. /**
  46715. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46716. * It is usually composed of several `lensFlare`.
  46717. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46718. */
  46719. export class LensFlareSystem {
  46720. /**
  46721. * Define the name of the lens flare system
  46722. */
  46723. name: string;
  46724. /**
  46725. * List of lens flares used in this system.
  46726. */
  46727. lensFlares: LensFlare[];
  46728. /**
  46729. * Define a limit from the border the lens flare can be visible.
  46730. */
  46731. borderLimit: number;
  46732. /**
  46733. * Define a viewport border we do not want to see the lens flare in.
  46734. */
  46735. viewportBorder: number;
  46736. /**
  46737. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46738. */
  46739. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46740. /**
  46741. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46742. */
  46743. layerMask: number;
  46744. /**
  46745. * Define the id of the lens flare system in the scene.
  46746. * (equal to name by default)
  46747. */
  46748. id: string;
  46749. private _scene;
  46750. private _emitter;
  46751. private _vertexBuffers;
  46752. private _indexBuffer;
  46753. private _effect;
  46754. private _positionX;
  46755. private _positionY;
  46756. private _isEnabled;
  46757. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46758. /**
  46759. * Instantiates a lens flare system.
  46760. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46761. * It is usually composed of several `lensFlare`.
  46762. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46763. * @param name Define the name of the lens flare system in the scene
  46764. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46765. * @param scene Define the scene the lens flare system belongs to
  46766. */
  46767. constructor(
  46768. /**
  46769. * Define the name of the lens flare system
  46770. */
  46771. name: string, emitter: any, scene: Scene);
  46772. /**
  46773. * Define if the lens flare system is enabled.
  46774. */
  46775. isEnabled: boolean;
  46776. /**
  46777. * Get the scene the effects belongs to.
  46778. * @returns the scene holding the lens flare system
  46779. */
  46780. getScene(): Scene;
  46781. /**
  46782. * Get the emitter of the lens flare system.
  46783. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46784. * @returns the emitter of the lens flare system
  46785. */
  46786. getEmitter(): any;
  46787. /**
  46788. * Set the emitter of the lens flare system.
  46789. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46790. * @param newEmitter Define the new emitter of the system
  46791. */
  46792. setEmitter(newEmitter: any): void;
  46793. /**
  46794. * Get the lens flare system emitter position.
  46795. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46796. * @returns the position
  46797. */
  46798. getEmitterPosition(): Vector3;
  46799. /**
  46800. * @hidden
  46801. */
  46802. computeEffectivePosition(globalViewport: Viewport): boolean;
  46803. /** @hidden */ isVisible(): boolean;
  46804. /**
  46805. * @hidden
  46806. */
  46807. render(): boolean;
  46808. /**
  46809. * Dispose and release the lens flare with its associated resources.
  46810. */
  46811. dispose(): void;
  46812. /**
  46813. * Parse a lens flare system from a JSON repressentation
  46814. * @param parsedLensFlareSystem Define the JSON to parse
  46815. * @param scene Define the scene the parsed system should be instantiated in
  46816. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46817. * @returns the parsed system
  46818. */
  46819. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46820. /**
  46821. * Serialize the current Lens Flare System into a JSON representation.
  46822. * @returns the serialized JSON
  46823. */
  46824. serialize(): any;
  46825. }
  46826. }
  46827. declare module BABYLON {
  46828. /**
  46829. * This represents one of the lens effect in a `lensFlareSystem`.
  46830. * It controls one of the indiviual texture used in the effect.
  46831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46832. */
  46833. export class LensFlare {
  46834. /**
  46835. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46836. */
  46837. size: number;
  46838. /**
  46839. * 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.
  46840. */
  46841. position: number;
  46842. /**
  46843. * Define the lens color.
  46844. */
  46845. color: Color3;
  46846. /**
  46847. * Define the lens texture.
  46848. */
  46849. texture: Nullable<Texture>;
  46850. /**
  46851. * Define the alpha mode to render this particular lens.
  46852. */
  46853. alphaMode: number;
  46854. private _system;
  46855. /**
  46856. * Creates a new Lens Flare.
  46857. * This represents one of the lens effect in a `lensFlareSystem`.
  46858. * It controls one of the indiviual texture used in the effect.
  46859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46860. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46861. * @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.
  46862. * @param color Define the lens color
  46863. * @param imgUrl Define the lens texture url
  46864. * @param system Define the `lensFlareSystem` this flare is part of
  46865. * @returns The newly created Lens Flare
  46866. */
  46867. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46868. /**
  46869. * Instantiates a new Lens Flare.
  46870. * This represents one of the lens effect in a `lensFlareSystem`.
  46871. * It controls one of the indiviual texture used in the effect.
  46872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46873. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46874. * @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.
  46875. * @param color Define the lens color
  46876. * @param imgUrl Define the lens texture url
  46877. * @param system Define the `lensFlareSystem` this flare is part of
  46878. */
  46879. constructor(
  46880. /**
  46881. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46882. */
  46883. size: number,
  46884. /**
  46885. * 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.
  46886. */
  46887. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46888. /**
  46889. * Dispose and release the lens flare with its associated resources.
  46890. */
  46891. dispose(): void;
  46892. }
  46893. }
  46894. declare module BABYLON {
  46895. interface AbstractScene {
  46896. /**
  46897. * The list of lens flare system added to the scene
  46898. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46899. */
  46900. lensFlareSystems: Array<LensFlareSystem>;
  46901. /**
  46902. * Removes the given lens flare system from this scene.
  46903. * @param toRemove The lens flare system to remove
  46904. * @returns The index of the removed lens flare system
  46905. */
  46906. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46907. /**
  46908. * Adds the given lens flare system to this scene
  46909. * @param newLensFlareSystem The lens flare system to add
  46910. */
  46911. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46912. /**
  46913. * Gets a lens flare system using its name
  46914. * @param name defines the name to look for
  46915. * @returns the lens flare system or null if not found
  46916. */
  46917. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46918. /**
  46919. * Gets a lens flare system using its id
  46920. * @param id defines the id to look for
  46921. * @returns the lens flare system or null if not found
  46922. */
  46923. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46924. }
  46925. /**
  46926. * Defines the lens flare scene component responsible to manage any lens flares
  46927. * in a given scene.
  46928. */
  46929. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46930. /**
  46931. * The component name helpfull to identify the component in the list of scene components.
  46932. */
  46933. readonly name: string;
  46934. /**
  46935. * The scene the component belongs to.
  46936. */
  46937. scene: Scene;
  46938. /**
  46939. * Creates a new instance of the component for the given scene
  46940. * @param scene Defines the scene to register the component in
  46941. */
  46942. constructor(scene: Scene);
  46943. /**
  46944. * Registers the component in a given scene
  46945. */
  46946. register(): void;
  46947. /**
  46948. * Rebuilds the elements related to this component in case of
  46949. * context lost for instance.
  46950. */
  46951. rebuild(): void;
  46952. /**
  46953. * Adds all the element from the container to the scene
  46954. * @param container the container holding the elements
  46955. */
  46956. addFromContainer(container: AbstractScene): void;
  46957. /**
  46958. * Removes all the elements in the container from the scene
  46959. * @param container contains the elements to remove
  46960. * @param dispose if the removed element should be disposed (default: false)
  46961. */
  46962. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46963. /**
  46964. * Serializes the component data to the specified json object
  46965. * @param serializationObject The object to serialize to
  46966. */
  46967. serialize(serializationObject: any): void;
  46968. /**
  46969. * Disposes the component and the associated ressources.
  46970. */
  46971. dispose(): void;
  46972. private _draw;
  46973. }
  46974. }
  46975. declare module BABYLON {
  46976. /**
  46977. * Defines the shadow generator component responsible to manage any shadow generators
  46978. * in a given scene.
  46979. */
  46980. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46981. /**
  46982. * The component name helpfull to identify the component in the list of scene components.
  46983. */
  46984. readonly name: string;
  46985. /**
  46986. * The scene the component belongs to.
  46987. */
  46988. scene: Scene;
  46989. /**
  46990. * Creates a new instance of the component for the given scene
  46991. * @param scene Defines the scene to register the component in
  46992. */
  46993. constructor(scene: Scene);
  46994. /**
  46995. * Registers the component in a given scene
  46996. */
  46997. register(): void;
  46998. /**
  46999. * Rebuilds the elements related to this component in case of
  47000. * context lost for instance.
  47001. */
  47002. rebuild(): void;
  47003. /**
  47004. * Serializes the component data to the specified json object
  47005. * @param serializationObject The object to serialize to
  47006. */
  47007. serialize(serializationObject: any): void;
  47008. /**
  47009. * Adds all the element from the container to the scene
  47010. * @param container the container holding the elements
  47011. */
  47012. addFromContainer(container: AbstractScene): void;
  47013. /**
  47014. * Removes all the elements in the container from the scene
  47015. * @param container contains the elements to remove
  47016. * @param dispose if the removed element should be disposed (default: false)
  47017. */
  47018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47019. /**
  47020. * Rebuilds the elements related to this component in case of
  47021. * context lost for instance.
  47022. */
  47023. dispose(): void;
  47024. private _gatherRenderTargets;
  47025. }
  47026. }
  47027. declare module BABYLON {
  47028. /**
  47029. * A point light is a light defined by an unique point in world space.
  47030. * The light is emitted in every direction from this point.
  47031. * A good example of a point light is a standard light bulb.
  47032. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47033. */
  47034. export class PointLight extends ShadowLight {
  47035. private _shadowAngle;
  47036. /**
  47037. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47038. * This specifies what angle the shadow will use to be created.
  47039. *
  47040. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47041. */
  47042. /**
  47043. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47044. * This specifies what angle the shadow will use to be created.
  47045. *
  47046. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47047. */
  47048. shadowAngle: number;
  47049. /**
  47050. * Gets the direction if it has been set.
  47051. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47052. */
  47053. /**
  47054. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47055. */
  47056. direction: Vector3;
  47057. /**
  47058. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47059. * A PointLight emits the light in every direction.
  47060. * It can cast shadows.
  47061. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47062. * ```javascript
  47063. * var pointLight = new PointLight("pl", camera.position, scene);
  47064. * ```
  47065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47066. * @param name The light friendly name
  47067. * @param position The position of the point light in the scene
  47068. * @param scene The scene the lights belongs to
  47069. */
  47070. constructor(name: string, position: Vector3, scene: Scene);
  47071. /**
  47072. * Returns the string "PointLight"
  47073. * @returns the class name
  47074. */
  47075. getClassName(): string;
  47076. /**
  47077. * Returns the integer 0.
  47078. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47079. */
  47080. getTypeID(): number;
  47081. /**
  47082. * Specifies wether or not the shadowmap should be a cube texture.
  47083. * @returns true if the shadowmap needs to be a cube texture.
  47084. */
  47085. needCube(): boolean;
  47086. /**
  47087. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47088. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47089. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47090. */
  47091. getShadowDirection(faceIndex?: number): Vector3;
  47092. /**
  47093. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47094. * - fov = PI / 2
  47095. * - aspect ratio : 1.0
  47096. * - z-near and far equal to the active camera minZ and maxZ.
  47097. * Returns the PointLight.
  47098. */
  47099. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47100. protected _buildUniformLayout(): void;
  47101. /**
  47102. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47103. * @param effect The effect to update
  47104. * @param lightIndex The index of the light in the effect to update
  47105. * @returns The point light
  47106. */
  47107. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47108. /**
  47109. * Prepares the list of defines specific to the light type.
  47110. * @param defines the list of defines
  47111. * @param lightIndex defines the index of the light for the effect
  47112. */
  47113. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47114. }
  47115. }
  47116. declare module BABYLON {
  47117. /**
  47118. * Header information of HDR texture files.
  47119. */
  47120. export interface HDRInfo {
  47121. /**
  47122. * The height of the texture in pixels.
  47123. */
  47124. height: number;
  47125. /**
  47126. * The width of the texture in pixels.
  47127. */
  47128. width: number;
  47129. /**
  47130. * The index of the beginning of the data in the binary file.
  47131. */
  47132. dataPosition: number;
  47133. }
  47134. /**
  47135. * This groups tools to convert HDR texture to native colors array.
  47136. */
  47137. export class HDRTools {
  47138. private static Ldexp;
  47139. private static Rgbe2float;
  47140. private static readStringLine;
  47141. /**
  47142. * Reads header information from an RGBE texture stored in a native array.
  47143. * More information on this format are available here:
  47144. * https://en.wikipedia.org/wiki/RGBE_image_format
  47145. *
  47146. * @param uint8array The binary file stored in native array.
  47147. * @return The header information.
  47148. */
  47149. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47150. /**
  47151. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47152. * This RGBE texture needs to store the information as a panorama.
  47153. *
  47154. * More information on this format are available here:
  47155. * https://en.wikipedia.org/wiki/RGBE_image_format
  47156. *
  47157. * @param buffer The binary file stored in an array buffer.
  47158. * @param size The expected size of the extracted cubemap.
  47159. * @return The Cube Map information.
  47160. */
  47161. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47162. /**
  47163. * Returns the pixels data extracted from an RGBE texture.
  47164. * This pixels will be stored left to right up to down in the R G B order in one array.
  47165. *
  47166. * More information on this format are available here:
  47167. * https://en.wikipedia.org/wiki/RGBE_image_format
  47168. *
  47169. * @param uint8array The binary file stored in an array buffer.
  47170. * @param hdrInfo The header information of the file.
  47171. * @return The pixels data in RGB right to left up to down order.
  47172. */
  47173. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47174. private static RGBE_ReadPixels_RLE;
  47175. }
  47176. }
  47177. declare module BABYLON {
  47178. /**
  47179. * This represents a texture coming from an HDR input.
  47180. *
  47181. * The only supported format is currently panorama picture stored in RGBE format.
  47182. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47183. */
  47184. export class HDRCubeTexture extends BaseTexture {
  47185. private static _facesMapping;
  47186. private _generateHarmonics;
  47187. private _noMipmap;
  47188. private _textureMatrix;
  47189. private _size;
  47190. private _onLoad;
  47191. private _onError;
  47192. /**
  47193. * The texture URL.
  47194. */
  47195. url: string;
  47196. /**
  47197. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47198. */
  47199. coordinatesMode: number;
  47200. protected _isBlocking: boolean;
  47201. /**
  47202. * Sets wether or not the texture is blocking during loading.
  47203. */
  47204. /**
  47205. * Gets wether or not the texture is blocking during loading.
  47206. */
  47207. isBlocking: boolean;
  47208. protected _rotationY: number;
  47209. /**
  47210. * Sets texture matrix rotation angle around Y axis in radians.
  47211. */
  47212. /**
  47213. * Gets texture matrix rotation angle around Y axis radians.
  47214. */
  47215. rotationY: number;
  47216. /**
  47217. * Gets or sets the center of the bounding box associated with the cube texture
  47218. * It must define where the camera used to render the texture was set
  47219. */
  47220. boundingBoxPosition: Vector3;
  47221. private _boundingBoxSize;
  47222. /**
  47223. * Gets or sets the size of the bounding box associated with the cube texture
  47224. * When defined, the cubemap will switch to local mode
  47225. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47226. * @example https://www.babylonjs-playground.com/#RNASML
  47227. */
  47228. boundingBoxSize: Vector3;
  47229. /**
  47230. * Instantiates an HDRTexture from the following parameters.
  47231. *
  47232. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47233. * @param scene The scene the texture will be used in
  47234. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47235. * @param noMipmap Forces to not generate the mipmap if true
  47236. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47237. * @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)
  47238. * @param reserved Reserved flag for internal use.
  47239. */
  47240. 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>);
  47241. /**
  47242. * Get the current class name of the texture useful for serialization or dynamic coding.
  47243. * @returns "HDRCubeTexture"
  47244. */
  47245. getClassName(): string;
  47246. /**
  47247. * Occurs when the file is raw .hdr file.
  47248. */
  47249. private loadTexture;
  47250. clone(): HDRCubeTexture;
  47251. delayLoad(): void;
  47252. /**
  47253. * Get the texture reflection matrix used to rotate/transform the reflection.
  47254. * @returns the reflection matrix
  47255. */
  47256. getReflectionTextureMatrix(): Matrix;
  47257. /**
  47258. * Set the texture reflection matrix used to rotate/transform the reflection.
  47259. * @param value Define the reflection matrix to set
  47260. */
  47261. setReflectionTextureMatrix(value: Matrix): void;
  47262. /**
  47263. * Parses a JSON representation of an HDR Texture in order to create the texture
  47264. * @param parsedTexture Define the JSON representation
  47265. * @param scene Define the scene the texture should be created in
  47266. * @param rootUrl Define the root url in case we need to load relative dependencies
  47267. * @returns the newly created texture after parsing
  47268. */
  47269. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47270. serialize(): any;
  47271. }
  47272. }
  47273. declare module BABYLON {
  47274. /**
  47275. * Class used to control physics engine
  47276. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47277. */
  47278. export class PhysicsEngine implements IPhysicsEngine {
  47279. private _physicsPlugin;
  47280. /**
  47281. * Global value used to control the smallest number supported by the simulation
  47282. */
  47283. static Epsilon: number;
  47284. private _impostors;
  47285. private _joints;
  47286. /**
  47287. * Gets the gravity vector used by the simulation
  47288. */
  47289. gravity: Vector3;
  47290. /**
  47291. * Factory used to create the default physics plugin.
  47292. * @returns The default physics plugin
  47293. */
  47294. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47295. /**
  47296. * Creates a new Physics Engine
  47297. * @param gravity defines the gravity vector used by the simulation
  47298. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47299. */
  47300. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47301. /**
  47302. * Sets the gravity vector used by the simulation
  47303. * @param gravity defines the gravity vector to use
  47304. */
  47305. setGravity(gravity: Vector3): void;
  47306. /**
  47307. * Set the time step of the physics engine.
  47308. * Default is 1/60.
  47309. * To slow it down, enter 1/600 for example.
  47310. * To speed it up, 1/30
  47311. * @param newTimeStep defines the new timestep to apply to this world.
  47312. */
  47313. setTimeStep(newTimeStep?: number): void;
  47314. /**
  47315. * Get the time step of the physics engine.
  47316. * @returns the current time step
  47317. */
  47318. getTimeStep(): number;
  47319. /**
  47320. * Release all resources
  47321. */
  47322. dispose(): void;
  47323. /**
  47324. * Gets the name of the current physics plugin
  47325. * @returns the name of the plugin
  47326. */
  47327. getPhysicsPluginName(): string;
  47328. /**
  47329. * Adding a new impostor for the impostor tracking.
  47330. * This will be done by the impostor itself.
  47331. * @param impostor the impostor to add
  47332. */
  47333. addImpostor(impostor: PhysicsImpostor): void;
  47334. /**
  47335. * Remove an impostor from the engine.
  47336. * This impostor and its mesh will not longer be updated by the physics engine.
  47337. * @param impostor the impostor to remove
  47338. */
  47339. removeImpostor(impostor: PhysicsImpostor): void;
  47340. /**
  47341. * Add a joint to the physics engine
  47342. * @param mainImpostor defines the main impostor to which the joint is added.
  47343. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47344. * @param joint defines the joint that will connect both impostors.
  47345. */
  47346. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47347. /**
  47348. * Removes a joint from the simulation
  47349. * @param mainImpostor defines the impostor used with the joint
  47350. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47351. * @param joint defines the joint to remove
  47352. */
  47353. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47354. /**
  47355. * Called by the scene. No need to call it.
  47356. * @param delta defines the timespam between frames
  47357. */ step(delta: number): void;
  47358. /**
  47359. * Gets the current plugin used to run the simulation
  47360. * @returns current plugin
  47361. */
  47362. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47363. /**
  47364. * Gets the list of physic impostors
  47365. * @returns an array of PhysicsImpostor
  47366. */
  47367. getImpostors(): Array<PhysicsImpostor>;
  47368. /**
  47369. * Gets the impostor for a physics enabled object
  47370. * @param object defines the object impersonated by the impostor
  47371. * @returns the PhysicsImpostor or null if not found
  47372. */
  47373. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47374. /**
  47375. * Gets the impostor for a physics body object
  47376. * @param body defines physics body used by the impostor
  47377. * @returns the PhysicsImpostor or null if not found
  47378. */
  47379. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47380. /**
  47381. * Does a raycast in the physics world
  47382. * @param from when should the ray start?
  47383. * @param to when should the ray end?
  47384. * @returns PhysicsRaycastResult
  47385. */
  47386. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /** @hidden */
  47391. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47392. private _useDeltaForWorldStep;
  47393. world: any;
  47394. name: string;
  47395. private _physicsMaterials;
  47396. private _fixedTimeStep;
  47397. private _cannonRaycastResult;
  47398. private _raycastResult;
  47399. private _removeAfterStep;
  47400. BJSCANNON: any;
  47401. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47402. setGravity(gravity: Vector3): void;
  47403. setTimeStep(timeStep: number): void;
  47404. getTimeStep(): number;
  47405. executeStep(delta: number): void;
  47406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47409. private _processChildMeshes;
  47410. removePhysicsBody(impostor: PhysicsImpostor): void;
  47411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47413. private _addMaterial;
  47414. private _checkWithEpsilon;
  47415. private _createShape;
  47416. private _createHeightmap;
  47417. private _minus90X;
  47418. private _plus90X;
  47419. private _tmpPosition;
  47420. private _tmpDeltaPosition;
  47421. private _tmpUnityRotation;
  47422. private _updatePhysicsBodyTransformation;
  47423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47425. isSupported(): boolean;
  47426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47431. getBodyMass(impostor: PhysicsImpostor): number;
  47432. getBodyFriction(impostor: PhysicsImpostor): number;
  47433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47434. getBodyRestitution(impostor: PhysicsImpostor): number;
  47435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47436. sleepBody(impostor: PhysicsImpostor): void;
  47437. wakeUpBody(impostor: PhysicsImpostor): void;
  47438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47439. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47441. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47442. getRadius(impostor: PhysicsImpostor): number;
  47443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47444. dispose(): void;
  47445. private _extendNamespace;
  47446. /**
  47447. * Does a raycast in the physics world
  47448. * @param from when should the ray start?
  47449. * @param to when should the ray end?
  47450. * @returns PhysicsRaycastResult
  47451. */
  47452. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47453. }
  47454. }
  47455. declare module BABYLON {
  47456. /** @hidden */
  47457. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47458. world: any;
  47459. name: string;
  47460. BJSOIMO: any;
  47461. private _raycastResult;
  47462. constructor(iterations?: number, oimoInjection?: any);
  47463. setGravity(gravity: Vector3): void;
  47464. setTimeStep(timeStep: number): void;
  47465. getTimeStep(): number;
  47466. private _tmpImpostorsArray;
  47467. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47468. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47469. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47470. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47471. private _tmpPositionVector;
  47472. removePhysicsBody(impostor: PhysicsImpostor): void;
  47473. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47474. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47475. isSupported(): boolean;
  47476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47477. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47478. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47479. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47480. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47481. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47482. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47483. getBodyMass(impostor: PhysicsImpostor): number;
  47484. getBodyFriction(impostor: PhysicsImpostor): number;
  47485. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47486. getBodyRestitution(impostor: PhysicsImpostor): number;
  47487. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47488. sleepBody(impostor: PhysicsImpostor): void;
  47489. wakeUpBody(impostor: PhysicsImpostor): void;
  47490. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47491. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47492. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47493. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47494. getRadius(impostor: PhysicsImpostor): number;
  47495. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47496. dispose(): void;
  47497. /**
  47498. * Does a raycast in the physics world
  47499. * @param from when should the ray start?
  47500. * @param to when should the ray end?
  47501. * @returns PhysicsRaycastResult
  47502. */
  47503. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47504. }
  47505. }
  47506. declare module BABYLON {
  47507. /**
  47508. * Class containing static functions to help procedurally build meshes
  47509. */
  47510. export class RibbonBuilder {
  47511. /**
  47512. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47513. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47514. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47515. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47516. * * 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
  47517. * * 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
  47518. * * 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
  47519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47520. * * 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
  47521. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47522. * * 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
  47523. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47524. * * 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
  47525. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47527. * @param name defines the name of the mesh
  47528. * @param options defines the options used to create the mesh
  47529. * @param scene defines the hosting scene
  47530. * @returns the ribbon mesh
  47531. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47533. */
  47534. static CreateRibbon(name: string, options: {
  47535. pathArray: Vector3[][];
  47536. closeArray?: boolean;
  47537. closePath?: boolean;
  47538. offset?: number;
  47539. updatable?: boolean;
  47540. sideOrientation?: number;
  47541. frontUVs?: Vector4;
  47542. backUVs?: Vector4;
  47543. instance?: Mesh;
  47544. invertUV?: boolean;
  47545. uvs?: Vector2[];
  47546. colors?: Color4[];
  47547. }, scene?: Nullable<Scene>): Mesh;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Class containing static functions to help procedurally build meshes
  47553. */
  47554. export class ShapeBuilder {
  47555. /**
  47556. * 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.
  47557. * * 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.
  47558. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47559. * * 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.
  47560. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47561. * * 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
  47562. * * 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
  47563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47565. * * 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
  47566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47568. * @param name defines the name of the mesh
  47569. * @param options defines the options used to create the mesh
  47570. * @param scene defines the hosting scene
  47571. * @returns the extruded shape mesh
  47572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47574. */
  47575. static ExtrudeShape(name: string, options: {
  47576. shape: Vector3[];
  47577. path: Vector3[];
  47578. scale?: number;
  47579. rotation?: number;
  47580. cap?: number;
  47581. updatable?: boolean;
  47582. sideOrientation?: number;
  47583. frontUVs?: Vector4;
  47584. backUVs?: Vector4;
  47585. instance?: Mesh;
  47586. invertUV?: boolean;
  47587. }, scene?: Nullable<Scene>): Mesh;
  47588. /**
  47589. * Creates an custom extruded shape mesh.
  47590. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47591. * * 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.
  47592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47593. * * 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
  47594. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47595. * * 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
  47596. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47597. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47598. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47599. * * 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
  47600. * * 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
  47601. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47603. * * 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
  47604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47606. * @param name defines the name of the mesh
  47607. * @param options defines the options used to create the mesh
  47608. * @param scene defines the hosting scene
  47609. * @returns the custom extruded shape mesh
  47610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47613. */
  47614. static ExtrudeShapeCustom(name: string, options: {
  47615. shape: Vector3[];
  47616. path: Vector3[];
  47617. scaleFunction?: any;
  47618. rotationFunction?: any;
  47619. ribbonCloseArray?: boolean;
  47620. ribbonClosePath?: boolean;
  47621. cap?: number;
  47622. updatable?: boolean;
  47623. sideOrientation?: number;
  47624. frontUVs?: Vector4;
  47625. backUVs?: Vector4;
  47626. instance?: Mesh;
  47627. invertUV?: boolean;
  47628. }, scene?: Nullable<Scene>): Mesh;
  47629. private static _ExtrudeShapeGeneric;
  47630. }
  47631. }
  47632. declare module BABYLON {
  47633. /**
  47634. * AmmoJS Physics plugin
  47635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47636. * @see https://github.com/kripken/ammo.js/
  47637. */
  47638. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47639. private _useDeltaForWorldStep;
  47640. /**
  47641. * Reference to the Ammo library
  47642. */
  47643. bjsAMMO: any;
  47644. /**
  47645. * Created ammoJS world which physics bodies are added to
  47646. */
  47647. world: any;
  47648. /**
  47649. * Name of the plugin
  47650. */
  47651. name: string;
  47652. private _timeStep;
  47653. private _fixedTimeStep;
  47654. private _maxSteps;
  47655. private _tmpQuaternion;
  47656. private _tmpAmmoTransform;
  47657. private _tmpAmmoQuaternion;
  47658. private _tmpAmmoConcreteContactResultCallback;
  47659. private _collisionConfiguration;
  47660. private _dispatcher;
  47661. private _overlappingPairCache;
  47662. private _solver;
  47663. private _softBodySolver;
  47664. private _tmpAmmoVectorA;
  47665. private _tmpAmmoVectorB;
  47666. private _tmpAmmoVectorC;
  47667. private _tmpAmmoVectorD;
  47668. private _tmpContactCallbackResult;
  47669. private _tmpAmmoVectorRCA;
  47670. private _tmpAmmoVectorRCB;
  47671. private _raycastResult;
  47672. private static readonly DISABLE_COLLISION_FLAG;
  47673. private static readonly KINEMATIC_FLAG;
  47674. private static readonly DISABLE_DEACTIVATION_FLAG;
  47675. /**
  47676. * Initializes the ammoJS plugin
  47677. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47678. * @param ammoInjection can be used to inject your own ammo reference
  47679. */
  47680. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47681. /**
  47682. * Sets the gravity of the physics world (m/(s^2))
  47683. * @param gravity Gravity to set
  47684. */
  47685. setGravity(gravity: Vector3): void;
  47686. /**
  47687. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47688. * @param timeStep timestep to use in seconds
  47689. */
  47690. setTimeStep(timeStep: number): void;
  47691. /**
  47692. * 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)
  47693. * @param fixedTimeStep fixedTimeStep to use in seconds
  47694. */
  47695. setFixedTimeStep(fixedTimeStep: number): void;
  47696. /**
  47697. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47698. * @param maxSteps the maximum number of steps by the physics engine per frame
  47699. */
  47700. setMaxSteps(maxSteps: number): void;
  47701. /**
  47702. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47703. * @returns the current timestep in seconds
  47704. */
  47705. getTimeStep(): number;
  47706. private _isImpostorInContact;
  47707. private _isImpostorPairInContact;
  47708. private _stepSimulation;
  47709. /**
  47710. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47711. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47712. * After the step the babylon meshes are set to the position of the physics imposters
  47713. * @param delta amount of time to step forward
  47714. * @param impostors array of imposters to update before/after the step
  47715. */
  47716. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47717. /**
  47718. * Update babylon mesh to match physics world object
  47719. * @param impostor imposter to match
  47720. */
  47721. private _afterSoftStep;
  47722. /**
  47723. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47724. * @param impostor imposter to match
  47725. */
  47726. private _ropeStep;
  47727. /**
  47728. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47729. * @param impostor imposter to match
  47730. */
  47731. private _softbodyOrClothStep;
  47732. private _tmpVector;
  47733. private _tmpMatrix;
  47734. /**
  47735. * Applies an impulse on the imposter
  47736. * @param impostor imposter to apply impulse to
  47737. * @param force amount of force to be applied to the imposter
  47738. * @param contactPoint the location to apply the impulse on the imposter
  47739. */
  47740. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47741. /**
  47742. * Applies a force on the imposter
  47743. * @param impostor imposter to apply force
  47744. * @param force amount of force to be applied to the imposter
  47745. * @param contactPoint the location to apply the force on the imposter
  47746. */
  47747. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47748. /**
  47749. * Creates a physics body using the plugin
  47750. * @param impostor the imposter to create the physics body on
  47751. */
  47752. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47753. /**
  47754. * Removes the physics body from the imposter and disposes of the body's memory
  47755. * @param impostor imposter to remove the physics body from
  47756. */
  47757. removePhysicsBody(impostor: PhysicsImpostor): void;
  47758. /**
  47759. * Generates a joint
  47760. * @param impostorJoint the imposter joint to create the joint with
  47761. */
  47762. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47763. /**
  47764. * Removes a joint
  47765. * @param impostorJoint the imposter joint to remove the joint from
  47766. */
  47767. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47768. private _addMeshVerts;
  47769. /**
  47770. * Initialise the soft body vertices to match its object's (mesh) vertices
  47771. * Softbody vertices (nodes) are in world space and to match this
  47772. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47773. * @param impostor to create the softbody for
  47774. */
  47775. private _softVertexData;
  47776. /**
  47777. * Create an impostor's soft body
  47778. * @param impostor to create the softbody for
  47779. */
  47780. private _createSoftbody;
  47781. /**
  47782. * Create cloth for an impostor
  47783. * @param impostor to create the softbody for
  47784. */
  47785. private _createCloth;
  47786. /**
  47787. * Create rope for an impostor
  47788. * @param impostor to create the softbody for
  47789. */
  47790. private _createRope;
  47791. private _addHullVerts;
  47792. private _createShape;
  47793. /**
  47794. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47795. * @param impostor imposter containing the physics body and babylon object
  47796. */
  47797. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47798. /**
  47799. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47800. * @param impostor imposter containing the physics body and babylon object
  47801. * @param newPosition new position
  47802. * @param newRotation new rotation
  47803. */
  47804. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47805. /**
  47806. * If this plugin is supported
  47807. * @returns true if its supported
  47808. */
  47809. isSupported(): boolean;
  47810. /**
  47811. * Sets the linear velocity of the physics body
  47812. * @param impostor imposter to set the velocity on
  47813. * @param velocity velocity to set
  47814. */
  47815. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47816. /**
  47817. * Sets the angular velocity of the physics body
  47818. * @param impostor imposter to set the velocity on
  47819. * @param velocity velocity to set
  47820. */
  47821. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47822. /**
  47823. * gets the linear velocity
  47824. * @param impostor imposter to get linear velocity from
  47825. * @returns linear velocity
  47826. */
  47827. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47828. /**
  47829. * gets the angular velocity
  47830. * @param impostor imposter to get angular velocity from
  47831. * @returns angular velocity
  47832. */
  47833. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47834. /**
  47835. * Sets the mass of physics body
  47836. * @param impostor imposter to set the mass on
  47837. * @param mass mass to set
  47838. */
  47839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47840. /**
  47841. * Gets the mass of the physics body
  47842. * @param impostor imposter to get the mass from
  47843. * @returns mass
  47844. */
  47845. getBodyMass(impostor: PhysicsImpostor): number;
  47846. /**
  47847. * Gets friction of the impostor
  47848. * @param impostor impostor to get friction from
  47849. * @returns friction value
  47850. */
  47851. getBodyFriction(impostor: PhysicsImpostor): number;
  47852. /**
  47853. * Sets friction of the impostor
  47854. * @param impostor impostor to set friction on
  47855. * @param friction friction value
  47856. */
  47857. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47858. /**
  47859. * Gets restitution of the impostor
  47860. * @param impostor impostor to get restitution from
  47861. * @returns restitution value
  47862. */
  47863. getBodyRestitution(impostor: PhysicsImpostor): number;
  47864. /**
  47865. * Sets resitution of the impostor
  47866. * @param impostor impostor to set resitution on
  47867. * @param restitution resitution value
  47868. */
  47869. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47870. /**
  47871. * Gets pressure inside the impostor
  47872. * @param impostor impostor to get pressure from
  47873. * @returns pressure value
  47874. */
  47875. getBodyPressure(impostor: PhysicsImpostor): number;
  47876. /**
  47877. * Sets pressure inside a soft body impostor
  47878. * Cloth and rope must remain 0 pressure
  47879. * @param impostor impostor to set pressure on
  47880. * @param pressure pressure value
  47881. */
  47882. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47883. /**
  47884. * Gets stiffness of the impostor
  47885. * @param impostor impostor to get stiffness from
  47886. * @returns pressure value
  47887. */
  47888. getBodyStiffness(impostor: PhysicsImpostor): number;
  47889. /**
  47890. * Sets stiffness of the impostor
  47891. * @param impostor impostor to set stiffness on
  47892. * @param stiffness stiffness value from 0 to 1
  47893. */
  47894. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47895. /**
  47896. * Gets velocityIterations of the impostor
  47897. * @param impostor impostor to get velocity iterations from
  47898. * @returns velocityIterations value
  47899. */
  47900. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47901. /**
  47902. * Sets velocityIterations of the impostor
  47903. * @param impostor impostor to set velocity iterations on
  47904. * @param velocityIterations velocityIterations value
  47905. */
  47906. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47907. /**
  47908. * Gets positionIterations of the impostor
  47909. * @param impostor impostor to get position iterations from
  47910. * @returns positionIterations value
  47911. */
  47912. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47913. /**
  47914. * Sets positionIterations of the impostor
  47915. * @param impostor impostor to set position on
  47916. * @param positionIterations positionIterations value
  47917. */
  47918. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47919. /**
  47920. * Append an anchor to a cloth object
  47921. * @param impostor is the cloth impostor to add anchor to
  47922. * @param otherImpostor is the rigid impostor to anchor to
  47923. * @param width ratio across width from 0 to 1
  47924. * @param height ratio up height from 0 to 1
  47925. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47926. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47927. */
  47928. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47929. /**
  47930. * Append an hook to a rope object
  47931. * @param impostor is the rope impostor to add hook to
  47932. * @param otherImpostor is the rigid impostor to hook to
  47933. * @param length ratio along the rope from 0 to 1
  47934. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47935. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47936. */
  47937. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47938. /**
  47939. * Sleeps the physics body and stops it from being active
  47940. * @param impostor impostor to sleep
  47941. */
  47942. sleepBody(impostor: PhysicsImpostor): void;
  47943. /**
  47944. * Activates the physics body
  47945. * @param impostor impostor to activate
  47946. */
  47947. wakeUpBody(impostor: PhysicsImpostor): void;
  47948. /**
  47949. * Updates the distance parameters of the joint
  47950. * @param joint joint to update
  47951. * @param maxDistance maximum distance of the joint
  47952. * @param minDistance minimum distance of the joint
  47953. */
  47954. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47955. /**
  47956. * Sets a motor on the joint
  47957. * @param joint joint to set motor on
  47958. * @param speed speed of the motor
  47959. * @param maxForce maximum force of the motor
  47960. * @param motorIndex index of the motor
  47961. */
  47962. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47963. /**
  47964. * Sets the motors limit
  47965. * @param joint joint to set limit on
  47966. * @param upperLimit upper limit
  47967. * @param lowerLimit lower limit
  47968. */
  47969. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47970. /**
  47971. * Syncs the position and rotation of a mesh with the impostor
  47972. * @param mesh mesh to sync
  47973. * @param impostor impostor to update the mesh with
  47974. */
  47975. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47976. /**
  47977. * Gets the radius of the impostor
  47978. * @param impostor impostor to get radius from
  47979. * @returns the radius
  47980. */
  47981. getRadius(impostor: PhysicsImpostor): number;
  47982. /**
  47983. * Gets the box size of the impostor
  47984. * @param impostor impostor to get box size from
  47985. * @param result the resulting box size
  47986. */
  47987. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47988. /**
  47989. * Disposes of the impostor
  47990. */
  47991. dispose(): void;
  47992. /**
  47993. * Does a raycast in the physics world
  47994. * @param from when should the ray start?
  47995. * @param to when should the ray end?
  47996. * @returns PhysicsRaycastResult
  47997. */
  47998. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47999. }
  48000. }
  48001. declare module BABYLON {
  48002. interface AbstractScene {
  48003. /**
  48004. * The list of reflection probes added to the scene
  48005. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48006. */
  48007. reflectionProbes: Array<ReflectionProbe>;
  48008. /**
  48009. * Removes the given reflection probe from this scene.
  48010. * @param toRemove The reflection probe to remove
  48011. * @returns The index of the removed reflection probe
  48012. */
  48013. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48014. /**
  48015. * Adds the given reflection probe to this scene.
  48016. * @param newReflectionProbe The reflection probe to add
  48017. */
  48018. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48019. }
  48020. /**
  48021. * Class used to generate realtime reflection / refraction cube textures
  48022. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48023. */
  48024. export class ReflectionProbe {
  48025. /** defines the name of the probe */
  48026. name: string;
  48027. private _scene;
  48028. private _renderTargetTexture;
  48029. private _projectionMatrix;
  48030. private _viewMatrix;
  48031. private _target;
  48032. private _add;
  48033. private _attachedMesh;
  48034. private _invertYAxis;
  48035. /** Gets or sets probe position (center of the cube map) */
  48036. position: Vector3;
  48037. /**
  48038. * Creates a new reflection probe
  48039. * @param name defines the name of the probe
  48040. * @param size defines the texture resolution (for each face)
  48041. * @param scene defines the hosting scene
  48042. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48043. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48044. */
  48045. constructor(
  48046. /** defines the name of the probe */
  48047. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48048. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48049. samples: number;
  48050. /** Gets or sets the refresh rate to use (on every frame by default) */
  48051. refreshRate: number;
  48052. /**
  48053. * Gets the hosting scene
  48054. * @returns a Scene
  48055. */
  48056. getScene(): Scene;
  48057. /** Gets the internal CubeTexture used to render to */
  48058. readonly cubeTexture: RenderTargetTexture;
  48059. /** Gets the list of meshes to render */
  48060. readonly renderList: Nullable<AbstractMesh[]>;
  48061. /**
  48062. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48063. * @param mesh defines the mesh to attach to
  48064. */
  48065. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48066. /**
  48067. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48068. * @param renderingGroupId The rendering group id corresponding to its index
  48069. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48070. */
  48071. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48072. /**
  48073. * Clean all associated resources
  48074. */
  48075. dispose(): void;
  48076. /**
  48077. * Converts the reflection probe information to a readable string for debug purpose.
  48078. * @param fullDetails Supports for multiple levels of logging within scene loading
  48079. * @returns the human readable reflection probe info
  48080. */
  48081. toString(fullDetails?: boolean): string;
  48082. /**
  48083. * Get the class name of the relfection probe.
  48084. * @returns "ReflectionProbe"
  48085. */
  48086. getClassName(): string;
  48087. /**
  48088. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48089. * @returns The JSON representation of the texture
  48090. */
  48091. serialize(): any;
  48092. /**
  48093. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48094. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48095. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48096. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48097. * @returns The parsed reflection probe if successful
  48098. */
  48099. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48100. }
  48101. }
  48102. declare module BABYLON {
  48103. /** @hidden */
  48104. export var _BabylonLoaderRegistered: boolean;
  48105. }
  48106. declare module BABYLON {
  48107. /**
  48108. * The Physically based simple base material of BJS.
  48109. *
  48110. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48111. * It is used as the base class for both the specGloss and metalRough conventions.
  48112. */
  48113. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48114. /**
  48115. * Number of Simultaneous lights allowed on the material.
  48116. */
  48117. maxSimultaneousLights: number;
  48118. /**
  48119. * If sets to true, disables all the lights affecting the material.
  48120. */
  48121. disableLighting: boolean;
  48122. /**
  48123. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48124. */
  48125. environmentTexture: BaseTexture;
  48126. /**
  48127. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48128. */
  48129. invertNormalMapX: boolean;
  48130. /**
  48131. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48132. */
  48133. invertNormalMapY: boolean;
  48134. /**
  48135. * Normal map used in the model.
  48136. */
  48137. normalTexture: BaseTexture;
  48138. /**
  48139. * Emissivie color used to self-illuminate the model.
  48140. */
  48141. emissiveColor: Color3;
  48142. /**
  48143. * Emissivie texture used to self-illuminate the model.
  48144. */
  48145. emissiveTexture: BaseTexture;
  48146. /**
  48147. * Occlusion Channel Strenght.
  48148. */
  48149. occlusionStrength: number;
  48150. /**
  48151. * Occlusion Texture of the material (adding extra occlusion effects).
  48152. */
  48153. occlusionTexture: BaseTexture;
  48154. /**
  48155. * Defines the alpha limits in alpha test mode.
  48156. */
  48157. alphaCutOff: number;
  48158. /**
  48159. * Gets the current double sided mode.
  48160. */
  48161. /**
  48162. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48163. */
  48164. doubleSided: boolean;
  48165. /**
  48166. * Stores the pre-calculated light information of a mesh in a texture.
  48167. */
  48168. lightmapTexture: BaseTexture;
  48169. /**
  48170. * If true, the light map contains occlusion information instead of lighting info.
  48171. */
  48172. useLightmapAsShadowmap: boolean;
  48173. /**
  48174. * Instantiates a new PBRMaterial instance.
  48175. *
  48176. * @param name The material name
  48177. * @param scene The scene the material will be use in.
  48178. */
  48179. constructor(name: string, scene: Scene);
  48180. getClassName(): string;
  48181. }
  48182. }
  48183. declare module BABYLON {
  48184. /**
  48185. * The PBR material of BJS following the metal roughness convention.
  48186. *
  48187. * This fits to the PBR convention in the GLTF definition:
  48188. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48189. */
  48190. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48191. /**
  48192. * The base color has two different interpretations depending on the value of metalness.
  48193. * When the material is a metal, the base color is the specific measured reflectance value
  48194. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48195. * of the material.
  48196. */
  48197. baseColor: Color3;
  48198. /**
  48199. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48200. * well as opacity information in the alpha channel.
  48201. */
  48202. baseTexture: BaseTexture;
  48203. /**
  48204. * Specifies the metallic scalar value of the material.
  48205. * Can also be used to scale the metalness values of the metallic texture.
  48206. */
  48207. metallic: number;
  48208. /**
  48209. * Specifies the roughness scalar value of the material.
  48210. * Can also be used to scale the roughness values of the metallic texture.
  48211. */
  48212. roughness: number;
  48213. /**
  48214. * Texture containing both the metallic value in the B channel and the
  48215. * roughness value in the G channel to keep better precision.
  48216. */
  48217. metallicRoughnessTexture: BaseTexture;
  48218. /**
  48219. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48220. *
  48221. * @param name The material name
  48222. * @param scene The scene the material will be use in.
  48223. */
  48224. constructor(name: string, scene: Scene);
  48225. /**
  48226. * Return the currrent class name of the material.
  48227. */
  48228. getClassName(): string;
  48229. /**
  48230. * Makes a duplicate of the current material.
  48231. * @param name - name to use for the new material.
  48232. */
  48233. clone(name: string): PBRMetallicRoughnessMaterial;
  48234. /**
  48235. * Serialize the material to a parsable JSON object.
  48236. */
  48237. serialize(): any;
  48238. /**
  48239. * Parses a JSON object correponding to the serialize function.
  48240. */
  48241. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48242. }
  48243. }
  48244. declare module BABYLON {
  48245. /**
  48246. * The PBR material of BJS following the specular glossiness convention.
  48247. *
  48248. * This fits to the PBR convention in the GLTF definition:
  48249. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48250. */
  48251. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48252. /**
  48253. * Specifies the diffuse color of the material.
  48254. */
  48255. diffuseColor: Color3;
  48256. /**
  48257. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48258. * channel.
  48259. */
  48260. diffuseTexture: BaseTexture;
  48261. /**
  48262. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48263. */
  48264. specularColor: Color3;
  48265. /**
  48266. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48267. */
  48268. glossiness: number;
  48269. /**
  48270. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48271. */
  48272. specularGlossinessTexture: BaseTexture;
  48273. /**
  48274. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48275. *
  48276. * @param name The material name
  48277. * @param scene The scene the material will be use in.
  48278. */
  48279. constructor(name: string, scene: Scene);
  48280. /**
  48281. * Return the currrent class name of the material.
  48282. */
  48283. getClassName(): string;
  48284. /**
  48285. * Makes a duplicate of the current material.
  48286. * @param name - name to use for the new material.
  48287. */
  48288. clone(name: string): PBRSpecularGlossinessMaterial;
  48289. /**
  48290. * Serialize the material to a parsable JSON object.
  48291. */
  48292. serialize(): any;
  48293. /**
  48294. * Parses a JSON object correponding to the serialize function.
  48295. */
  48296. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48297. }
  48298. }
  48299. declare module BABYLON {
  48300. /**
  48301. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48302. * It can help converting any input color in a desired output one. This can then be used to create effects
  48303. * from sepia, black and white to sixties or futuristic rendering...
  48304. *
  48305. * The only supported format is currently 3dl.
  48306. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48307. */
  48308. export class ColorGradingTexture extends BaseTexture {
  48309. /**
  48310. * The current texture matrix. (will always be identity in color grading texture)
  48311. */
  48312. private _textureMatrix;
  48313. /**
  48314. * The texture URL.
  48315. */
  48316. url: string;
  48317. /**
  48318. * Empty line regex stored for GC.
  48319. */
  48320. private static _noneEmptyLineRegex;
  48321. private _engine;
  48322. /**
  48323. * Instantiates a ColorGradingTexture from the following parameters.
  48324. *
  48325. * @param url The location of the color gradind data (currently only supporting 3dl)
  48326. * @param scene The scene the texture will be used in
  48327. */
  48328. constructor(url: string, scene: Scene);
  48329. /**
  48330. * Returns the texture matrix used in most of the material.
  48331. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48332. */
  48333. getTextureMatrix(): Matrix;
  48334. /**
  48335. * Occurs when the file being loaded is a .3dl LUT file.
  48336. */
  48337. private load3dlTexture;
  48338. /**
  48339. * Starts the loading process of the texture.
  48340. */
  48341. private loadTexture;
  48342. /**
  48343. * Clones the color gradind texture.
  48344. */
  48345. clone(): ColorGradingTexture;
  48346. /**
  48347. * Called during delayed load for textures.
  48348. */
  48349. delayLoad(): void;
  48350. /**
  48351. * Parses a color grading texture serialized by Babylon.
  48352. * @param parsedTexture The texture information being parsedTexture
  48353. * @param scene The scene to load the texture in
  48354. * @param rootUrl The root url of the data assets to load
  48355. * @return A color gradind texture
  48356. */
  48357. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48358. /**
  48359. * Serializes the LUT texture to json format.
  48360. */
  48361. serialize(): any;
  48362. }
  48363. }
  48364. declare module BABYLON {
  48365. /**
  48366. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48367. */
  48368. export class EquiRectangularCubeTexture extends BaseTexture {
  48369. /** The six faces of the cube. */
  48370. private static _FacesMapping;
  48371. private _noMipmap;
  48372. private _onLoad;
  48373. private _onError;
  48374. /** The size of the cubemap. */
  48375. private _size;
  48376. /** The buffer of the image. */
  48377. private _buffer;
  48378. /** The width of the input image. */
  48379. private _width;
  48380. /** The height of the input image. */
  48381. private _height;
  48382. /** The URL to the image. */
  48383. url: string;
  48384. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48385. coordinatesMode: number;
  48386. /**
  48387. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48388. * @param url The location of the image
  48389. * @param scene The scene the texture will be used in
  48390. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48391. * @param noMipmap Forces to not generate the mipmap if true
  48392. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48393. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48394. * @param onLoad — defines a callback called when texture is loaded
  48395. * @param onError — defines a callback called if there is an error
  48396. */
  48397. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48398. /**
  48399. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48400. */
  48401. private loadImage;
  48402. /**
  48403. * Convert the image buffer into a cubemap and create a CubeTexture.
  48404. */
  48405. private loadTexture;
  48406. /**
  48407. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48408. * @param buffer The ArrayBuffer that should be converted.
  48409. * @returns The buffer as Float32Array.
  48410. */
  48411. private getFloat32ArrayFromArrayBuffer;
  48412. /**
  48413. * Get the current class name of the texture useful for serialization or dynamic coding.
  48414. * @returns "EquiRectangularCubeTexture"
  48415. */
  48416. getClassName(): string;
  48417. /**
  48418. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48419. * @returns A clone of the current EquiRectangularCubeTexture.
  48420. */
  48421. clone(): EquiRectangularCubeTexture;
  48422. }
  48423. }
  48424. declare module BABYLON {
  48425. /**
  48426. * Based on jsTGALoader - Javascript loader for TGA file
  48427. * By Vincent Thibault
  48428. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48429. */
  48430. export class TGATools {
  48431. private static _TYPE_INDEXED;
  48432. private static _TYPE_RGB;
  48433. private static _TYPE_GREY;
  48434. private static _TYPE_RLE_INDEXED;
  48435. private static _TYPE_RLE_RGB;
  48436. private static _TYPE_RLE_GREY;
  48437. private static _ORIGIN_MASK;
  48438. private static _ORIGIN_SHIFT;
  48439. private static _ORIGIN_BL;
  48440. private static _ORIGIN_BR;
  48441. private static _ORIGIN_UL;
  48442. private static _ORIGIN_UR;
  48443. /**
  48444. * Gets the header of a TGA file
  48445. * @param data defines the TGA data
  48446. * @returns the header
  48447. */
  48448. static GetTGAHeader(data: Uint8Array): any;
  48449. /**
  48450. * Uploads TGA content to a Babylon Texture
  48451. * @hidden
  48452. */
  48453. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48454. /** @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;
  48455. /** @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;
  48456. /** @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;
  48457. /** @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;
  48458. /** @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;
  48459. /** @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;
  48460. }
  48461. }
  48462. declare module BABYLON {
  48463. /**
  48464. * Implementation of the TGA Texture Loader.
  48465. * @hidden
  48466. */
  48467. export class _TGATextureLoader implements IInternalTextureLoader {
  48468. /**
  48469. * Defines wether the loader supports cascade loading the different faces.
  48470. */
  48471. readonly supportCascades: boolean;
  48472. /**
  48473. * This returns if the loader support the current file information.
  48474. * @param extension defines the file extension of the file being loaded
  48475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48476. * @param fallback defines the fallback internal texture if any
  48477. * @param isBase64 defines whether the texture is encoded as a base64
  48478. * @param isBuffer defines whether the texture data are stored as a buffer
  48479. * @returns true if the loader can load the specified file
  48480. */
  48481. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48482. /**
  48483. * Transform the url before loading if required.
  48484. * @param rootUrl the url of the texture
  48485. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48486. * @returns the transformed texture
  48487. */
  48488. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48489. /**
  48490. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48491. * @param rootUrl the url of the texture
  48492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48493. * @returns the fallback texture
  48494. */
  48495. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48496. /**
  48497. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48498. * @param data contains the texture data
  48499. * @param texture defines the BabylonJS internal texture
  48500. * @param createPolynomials will be true if polynomials have been requested
  48501. * @param onLoad defines the callback to trigger once the texture is ready
  48502. * @param onError defines the callback to trigger in case of error
  48503. */
  48504. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48505. /**
  48506. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48507. * @param data contains the texture data
  48508. * @param texture defines the BabylonJS internal texture
  48509. * @param callback defines the method to call once ready to upload
  48510. */
  48511. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48512. }
  48513. }
  48514. declare module BABYLON {
  48515. /**
  48516. * 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.
  48517. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48518. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48519. */
  48520. export class CustomProceduralTexture extends ProceduralTexture {
  48521. private _animate;
  48522. private _time;
  48523. private _config;
  48524. private _texturePath;
  48525. /**
  48526. * Instantiates a new Custom Procedural Texture.
  48527. * 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.
  48528. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48529. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48530. * @param name Define the name of the texture
  48531. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48532. * @param size Define the size of the texture to create
  48533. * @param scene Define the scene the texture belongs to
  48534. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48535. * @param generateMipMaps Define if the texture should creates mip maps or not
  48536. */
  48537. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48538. private _loadJson;
  48539. /**
  48540. * Is the texture ready to be used ? (rendered at least once)
  48541. * @returns true if ready, otherwise, false.
  48542. */
  48543. isReady(): boolean;
  48544. /**
  48545. * Render the texture to its associated render target.
  48546. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48547. */
  48548. render(useCameraPostProcess?: boolean): void;
  48549. /**
  48550. * Update the list of dependant textures samplers in the shader.
  48551. */
  48552. updateTextures(): void;
  48553. /**
  48554. * Update the uniform values of the procedural texture in the shader.
  48555. */
  48556. updateShaderUniforms(): void;
  48557. /**
  48558. * Define if the texture animates or not.
  48559. */
  48560. animate: boolean;
  48561. }
  48562. }
  48563. declare module BABYLON {
  48564. /** @hidden */
  48565. export var noisePixelShader: {
  48566. name: string;
  48567. shader: string;
  48568. };
  48569. }
  48570. declare module BABYLON {
  48571. /**
  48572. * Class used to generate noise procedural textures
  48573. */
  48574. export class NoiseProceduralTexture extends ProceduralTexture {
  48575. private _time;
  48576. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48577. brightness: number;
  48578. /** Defines the number of octaves to process */
  48579. octaves: number;
  48580. /** Defines the level of persistence (0.8 by default) */
  48581. persistence: number;
  48582. /** Gets or sets animation speed factor (default is 1) */
  48583. animationSpeedFactor: number;
  48584. /**
  48585. * Creates a new NoiseProceduralTexture
  48586. * @param name defines the name fo the texture
  48587. * @param size defines the size of the texture (default is 256)
  48588. * @param scene defines the hosting scene
  48589. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48590. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48591. */
  48592. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48593. private _updateShaderUniforms;
  48594. protected _getDefines(): string;
  48595. /** Generate the current state of the procedural texture */
  48596. render(useCameraPostProcess?: boolean): void;
  48597. /**
  48598. * Serializes this noise procedural texture
  48599. * @returns a serialized noise procedural texture object
  48600. */
  48601. serialize(): any;
  48602. /**
  48603. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48604. * @param parsedTexture defines parsed texture data
  48605. * @param scene defines the current scene
  48606. * @param rootUrl defines the root URL containing noise procedural texture information
  48607. * @returns a parsed NoiseProceduralTexture
  48608. */
  48609. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48610. }
  48611. }
  48612. declare module BABYLON {
  48613. /**
  48614. * Raw cube texture where the raw buffers are passed in
  48615. */
  48616. export class RawCubeTexture extends CubeTexture {
  48617. /**
  48618. * Creates a cube texture where the raw buffers are passed in.
  48619. * @param scene defines the scene the texture is attached to
  48620. * @param data defines the array of data to use to create each face
  48621. * @param size defines the size of the textures
  48622. * @param format defines the format of the data
  48623. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48624. * @param generateMipMaps defines if the engine should generate the mip levels
  48625. * @param invertY defines if data must be stored with Y axis inverted
  48626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48627. * @param compression defines the compression used (null by default)
  48628. */
  48629. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48630. /**
  48631. * Updates the raw cube texture.
  48632. * @param data defines the data to store
  48633. * @param format defines the data format
  48634. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48635. * @param invertY defines if data must be stored with Y axis inverted
  48636. * @param compression defines the compression used (null by default)
  48637. * @param level defines which level of the texture to update
  48638. */
  48639. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48640. /**
  48641. * Updates a raw cube texture with RGBD encoded data.
  48642. * @param data defines the array of data [mipmap][face] to use to create each face
  48643. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48644. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48645. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48646. * @returns a promsie that resolves when the operation is complete
  48647. */
  48648. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48649. /**
  48650. * Clones the raw cube texture.
  48651. * @return a new cube texture
  48652. */
  48653. clone(): CubeTexture;
  48654. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48655. }
  48656. }
  48657. declare module BABYLON {
  48658. /**
  48659. * Class used to store 3D textures containing user data
  48660. */
  48661. export class RawTexture3D extends Texture {
  48662. /** Gets or sets the texture format to use */
  48663. format: number;
  48664. private _engine;
  48665. /**
  48666. * Create a new RawTexture3D
  48667. * @param data defines the data of the texture
  48668. * @param width defines the width of the texture
  48669. * @param height defines the height of the texture
  48670. * @param depth defines the depth of the texture
  48671. * @param format defines the texture format to use
  48672. * @param scene defines the hosting scene
  48673. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48674. * @param invertY defines if texture must be stored with Y axis inverted
  48675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48676. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48677. */
  48678. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48679. /** Gets or sets the texture format to use */
  48680. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48681. /**
  48682. * Update the texture with new data
  48683. * @param data defines the data to store in the texture
  48684. */
  48685. update(data: ArrayBufferView): void;
  48686. }
  48687. }
  48688. declare module BABYLON {
  48689. /**
  48690. * Creates a refraction texture used by refraction channel of the standard material.
  48691. * It is like a mirror but to see through a material.
  48692. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48693. */
  48694. export class RefractionTexture extends RenderTargetTexture {
  48695. /**
  48696. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48697. * 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.
  48698. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48699. */
  48700. refractionPlane: Plane;
  48701. /**
  48702. * Define how deep under the surface we should see.
  48703. */
  48704. depth: number;
  48705. /**
  48706. * Creates a refraction texture used by refraction channel of the standard material.
  48707. * It is like a mirror but to see through a material.
  48708. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48709. * @param name Define the texture name
  48710. * @param size Define the size of the underlying texture
  48711. * @param scene Define the scene the refraction belongs to
  48712. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48713. */
  48714. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48715. /**
  48716. * Clone the refraction texture.
  48717. * @returns the cloned texture
  48718. */
  48719. clone(): RefractionTexture;
  48720. /**
  48721. * Serialize the texture to a JSON representation you could use in Parse later on
  48722. * @returns the serialized JSON representation
  48723. */
  48724. serialize(): any;
  48725. }
  48726. }
  48727. declare module BABYLON {
  48728. /**
  48729. * Defines the options related to the creation of an HtmlElementTexture
  48730. */
  48731. export interface IHtmlElementTextureOptions {
  48732. /**
  48733. * Defines wether mip maps should be created or not.
  48734. */
  48735. generateMipMaps?: boolean;
  48736. /**
  48737. * Defines the sampling mode of the texture.
  48738. */
  48739. samplingMode?: number;
  48740. /**
  48741. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48742. */
  48743. engine: Nullable<Engine>;
  48744. /**
  48745. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48746. */
  48747. scene: Nullable<Scene>;
  48748. }
  48749. /**
  48750. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48751. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48752. * is automatically managed.
  48753. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48754. * in your application.
  48755. *
  48756. * As the update is not automatic, you need to call them manually.
  48757. */
  48758. export class HtmlElementTexture extends BaseTexture {
  48759. /**
  48760. * The texture URL.
  48761. */
  48762. element: HTMLVideoElement | HTMLCanvasElement;
  48763. private static readonly DefaultOptions;
  48764. private _textureMatrix;
  48765. private _engine;
  48766. private _isVideo;
  48767. private _generateMipMaps;
  48768. private _samplingMode;
  48769. /**
  48770. * Instantiates a HtmlElementTexture from the following parameters.
  48771. *
  48772. * @param name Defines the name of the texture
  48773. * @param element Defines the video or canvas the texture is filled with
  48774. * @param options Defines the other none mandatory texture creation options
  48775. */
  48776. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48777. private _createInternalTexture;
  48778. /**
  48779. * Returns the texture matrix used in most of the material.
  48780. */
  48781. getTextureMatrix(): Matrix;
  48782. /**
  48783. * Updates the content of the texture.
  48784. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48785. */
  48786. update(invertY?: Nullable<boolean>): void;
  48787. }
  48788. }
  48789. declare module BABYLON {
  48790. /**
  48791. * Helper class to push actions to a pool of workers.
  48792. */
  48793. export class WorkerPool implements IDisposable {
  48794. private _workerInfos;
  48795. private _pendingActions;
  48796. /**
  48797. * Constructor
  48798. * @param workers Array of workers to use for actions
  48799. */
  48800. constructor(workers: Array<Worker>);
  48801. /**
  48802. * Terminates all workers and clears any pending actions.
  48803. */
  48804. dispose(): void;
  48805. /**
  48806. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48807. * pended until a worker has completed its action.
  48808. * @param action The action to perform. Call onComplete when the action is complete.
  48809. */
  48810. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48811. private _execute;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /**
  48816. * Configuration for Draco compression
  48817. */
  48818. export interface IDracoCompressionConfiguration {
  48819. /**
  48820. * Configuration for the decoder.
  48821. */
  48822. decoder?: {
  48823. /**
  48824. * The url to the WebAssembly module.
  48825. */
  48826. wasmUrl?: string;
  48827. /**
  48828. * The url to the WebAssembly binary.
  48829. */
  48830. wasmBinaryUrl?: string;
  48831. /**
  48832. * The url to the fallback JavaScript module.
  48833. */
  48834. fallbackUrl?: string;
  48835. };
  48836. }
  48837. /**
  48838. * Draco compression (https://google.github.io/draco/)
  48839. *
  48840. * This class wraps the Draco module.
  48841. *
  48842. * **Encoder**
  48843. *
  48844. * The encoder is not currently implemented.
  48845. *
  48846. * **Decoder**
  48847. *
  48848. * 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.
  48849. *
  48850. * To update the configuration, use the following code:
  48851. * ```javascript
  48852. * DracoCompression.Configuration = {
  48853. * decoder: {
  48854. * wasmUrl: "<url to the WebAssembly library>",
  48855. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48856. * fallbackUrl: "<url to the fallback JavaScript library>",
  48857. * }
  48858. * };
  48859. * ```
  48860. *
  48861. * 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.
  48862. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48863. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48864. *
  48865. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48866. * ```javascript
  48867. * var dracoCompression = new DracoCompression();
  48868. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48869. * [VertexBuffer.PositionKind]: 0
  48870. * });
  48871. * ```
  48872. *
  48873. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48874. */
  48875. export class DracoCompression implements IDisposable {
  48876. private _workerPoolPromise;
  48877. /**
  48878. * The configuration. Defaults to the following urls:
  48879. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48880. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48881. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48882. */
  48883. static Configuration: IDracoCompressionConfiguration;
  48884. /**
  48885. * Returns true if the decoder is available.
  48886. */
  48887. static readonly DecoderAvailable: boolean;
  48888. /**
  48889. * Default number of workers to create when creating the draco compression object.
  48890. */
  48891. static DefaultNumWorkers: number;
  48892. private static GetDefaultNumWorkers;
  48893. /**
  48894. * Constructor
  48895. * @param numWorkers The number of workers for async operations
  48896. */
  48897. constructor(numWorkers?: number);
  48898. /**
  48899. * Stop all async operations and release resources.
  48900. */
  48901. dispose(): void;
  48902. /**
  48903. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  48904. * @returns a promise that resolves when ready
  48905. */
  48906. whenReadyAsync(): Promise<void>;
  48907. /**
  48908. * Decode Draco compressed mesh data to vertex data.
  48909. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48910. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48911. * @returns A promise that resolves with the decoded vertex data
  48912. */
  48913. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  48914. [kind: string]: number;
  48915. }): Promise<VertexData>;
  48916. /**
  48917. * The worker function that gets converted to a blob url to pass into a worker.
  48918. */
  48919. private static _Worker;
  48920. private _loadDecoderWasmBinaryAsync;
  48921. }
  48922. }
  48923. declare module BABYLON {
  48924. /**
  48925. * Class for building Constructive Solid Geometry
  48926. */
  48927. export class CSG {
  48928. private polygons;
  48929. /**
  48930. * The world matrix
  48931. */
  48932. matrix: Matrix;
  48933. /**
  48934. * Stores the position
  48935. */
  48936. position: Vector3;
  48937. /**
  48938. * Stores the rotation
  48939. */
  48940. rotation: Vector3;
  48941. /**
  48942. * Stores the rotation quaternion
  48943. */
  48944. rotationQuaternion: Nullable<Quaternion>;
  48945. /**
  48946. * Stores the scaling vector
  48947. */
  48948. scaling: Vector3;
  48949. /**
  48950. * Convert the Mesh to CSG
  48951. * @param mesh The Mesh to convert to CSG
  48952. * @returns A new CSG from the Mesh
  48953. */
  48954. static FromMesh(mesh: Mesh): CSG;
  48955. /**
  48956. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48957. * @param polygons Polygons used to construct a CSG solid
  48958. */
  48959. private static FromPolygons;
  48960. /**
  48961. * Clones, or makes a deep copy, of the CSG
  48962. * @returns A new CSG
  48963. */
  48964. clone(): CSG;
  48965. /**
  48966. * Unions this CSG with another CSG
  48967. * @param csg The CSG to union against this CSG
  48968. * @returns The unioned CSG
  48969. */
  48970. union(csg: CSG): CSG;
  48971. /**
  48972. * Unions this CSG with another CSG in place
  48973. * @param csg The CSG to union against this CSG
  48974. */
  48975. unionInPlace(csg: CSG): void;
  48976. /**
  48977. * Subtracts this CSG with another CSG
  48978. * @param csg The CSG to subtract against this CSG
  48979. * @returns A new CSG
  48980. */
  48981. subtract(csg: CSG): CSG;
  48982. /**
  48983. * Subtracts this CSG with another CSG in place
  48984. * @param csg The CSG to subtact against this CSG
  48985. */
  48986. subtractInPlace(csg: CSG): void;
  48987. /**
  48988. * Intersect this CSG with another CSG
  48989. * @param csg The CSG to intersect against this CSG
  48990. * @returns A new CSG
  48991. */
  48992. intersect(csg: CSG): CSG;
  48993. /**
  48994. * Intersects this CSG with another CSG in place
  48995. * @param csg The CSG to intersect against this CSG
  48996. */
  48997. intersectInPlace(csg: CSG): void;
  48998. /**
  48999. * Return a new CSG solid with solid and empty space switched. This solid is
  49000. * not modified.
  49001. * @returns A new CSG solid with solid and empty space switched
  49002. */
  49003. inverse(): CSG;
  49004. /**
  49005. * Inverses the CSG in place
  49006. */
  49007. inverseInPlace(): void;
  49008. /**
  49009. * This is used to keep meshes transformations so they can be restored
  49010. * when we build back a Babylon Mesh
  49011. * NB : All CSG operations are performed in world coordinates
  49012. * @param csg The CSG to copy the transform attributes from
  49013. * @returns This CSG
  49014. */
  49015. copyTransformAttributes(csg: CSG): CSG;
  49016. /**
  49017. * Build Raw mesh from CSG
  49018. * Coordinates here are in world space
  49019. * @param name The name of the mesh geometry
  49020. * @param scene The Scene
  49021. * @param keepSubMeshes Specifies if the submeshes should be kept
  49022. * @returns A new Mesh
  49023. */
  49024. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49025. /**
  49026. * Build Mesh from CSG taking material and transforms into account
  49027. * @param name The name of the Mesh
  49028. * @param material The material of the Mesh
  49029. * @param scene The Scene
  49030. * @param keepSubMeshes Specifies if submeshes should be kept
  49031. * @returns The new Mesh
  49032. */
  49033. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49034. }
  49035. }
  49036. declare module BABYLON {
  49037. /**
  49038. * Class used to create a trail following a mesh
  49039. */
  49040. export class TrailMesh extends Mesh {
  49041. private _generator;
  49042. private _autoStart;
  49043. private _running;
  49044. private _diameter;
  49045. private _length;
  49046. private _sectionPolygonPointsCount;
  49047. private _sectionVectors;
  49048. private _sectionNormalVectors;
  49049. private _beforeRenderObserver;
  49050. /**
  49051. * @constructor
  49052. * @param name The value used by scene.getMeshByName() to do a lookup.
  49053. * @param generator The mesh to generate a trail.
  49054. * @param scene The scene to add this mesh to.
  49055. * @param diameter Diameter of trailing mesh. Default is 1.
  49056. * @param length Length of trailing mesh. Default is 60.
  49057. * @param autoStart Automatically start trailing mesh. Default true.
  49058. */
  49059. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49060. /**
  49061. * "TrailMesh"
  49062. * @returns "TrailMesh"
  49063. */
  49064. getClassName(): string;
  49065. private _createMesh;
  49066. /**
  49067. * Start trailing mesh.
  49068. */
  49069. start(): void;
  49070. /**
  49071. * Stop trailing mesh.
  49072. */
  49073. stop(): void;
  49074. /**
  49075. * Update trailing mesh geometry.
  49076. */
  49077. update(): void;
  49078. /**
  49079. * Returns a new TrailMesh object.
  49080. * @param name is a string, the name given to the new mesh
  49081. * @param newGenerator use new generator object for cloned trail mesh
  49082. * @returns a new mesh
  49083. */
  49084. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49085. /**
  49086. * Serializes this trail mesh
  49087. * @param serializationObject object to write serialization to
  49088. */
  49089. serialize(serializationObject: any): void;
  49090. /**
  49091. * Parses a serialized trail mesh
  49092. * @param parsedMesh the serialized mesh
  49093. * @param scene the scene to create the trail mesh in
  49094. * @returns the created trail mesh
  49095. */
  49096. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49097. }
  49098. }
  49099. declare module BABYLON {
  49100. /**
  49101. * Class containing static functions to help procedurally build meshes
  49102. */
  49103. export class TorusKnotBuilder {
  49104. /**
  49105. * Creates a torus knot mesh
  49106. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49107. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49108. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49109. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49111. * * 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
  49112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49113. * @param name defines the name of the mesh
  49114. * @param options defines the options used to create the mesh
  49115. * @param scene defines the hosting scene
  49116. * @returns the torus knot mesh
  49117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49118. */
  49119. static CreateTorusKnot(name: string, options: {
  49120. radius?: number;
  49121. tube?: number;
  49122. radialSegments?: number;
  49123. tubularSegments?: number;
  49124. p?: number;
  49125. q?: number;
  49126. updatable?: boolean;
  49127. sideOrientation?: number;
  49128. frontUVs?: Vector4;
  49129. backUVs?: Vector4;
  49130. }, scene: any): Mesh;
  49131. }
  49132. }
  49133. declare module BABYLON {
  49134. /**
  49135. * Polygon
  49136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49137. */
  49138. export class Polygon {
  49139. /**
  49140. * Creates a rectangle
  49141. * @param xmin bottom X coord
  49142. * @param ymin bottom Y coord
  49143. * @param xmax top X coord
  49144. * @param ymax top Y coord
  49145. * @returns points that make the resulting rectation
  49146. */
  49147. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49148. /**
  49149. * Creates a circle
  49150. * @param radius radius of circle
  49151. * @param cx scale in x
  49152. * @param cy scale in y
  49153. * @param numberOfSides number of sides that make up the circle
  49154. * @returns points that make the resulting circle
  49155. */
  49156. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49157. /**
  49158. * Creates a polygon from input string
  49159. * @param input Input polygon data
  49160. * @returns the parsed points
  49161. */
  49162. static Parse(input: string): Vector2[];
  49163. /**
  49164. * Starts building a polygon from x and y coordinates
  49165. * @param x x coordinate
  49166. * @param y y coordinate
  49167. * @returns the started path2
  49168. */
  49169. static StartingAt(x: number, y: number): Path2;
  49170. }
  49171. /**
  49172. * Builds a polygon
  49173. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49174. */
  49175. export class PolygonMeshBuilder {
  49176. private _points;
  49177. private _outlinepoints;
  49178. private _holes;
  49179. private _name;
  49180. private _scene;
  49181. private _epoints;
  49182. private _eholes;
  49183. private _addToepoint;
  49184. /**
  49185. * Babylon reference to the earcut plugin.
  49186. */
  49187. bjsEarcut: any;
  49188. /**
  49189. * Creates a PolygonMeshBuilder
  49190. * @param name name of the builder
  49191. * @param contours Path of the polygon
  49192. * @param scene scene to add to when creating the mesh
  49193. * @param earcutInjection can be used to inject your own earcut reference
  49194. */
  49195. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49196. /**
  49197. * Adds a whole within the polygon
  49198. * @param hole Array of points defining the hole
  49199. * @returns this
  49200. */
  49201. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49202. /**
  49203. * Creates the polygon
  49204. * @param updatable If the mesh should be updatable
  49205. * @param depth The depth of the mesh created
  49206. * @returns the created mesh
  49207. */
  49208. build(updatable?: boolean, depth?: number): Mesh;
  49209. /**
  49210. * Creates the polygon
  49211. * @param depth The depth of the mesh created
  49212. * @returns the created VertexData
  49213. */
  49214. buildVertexData(depth?: number): VertexData;
  49215. /**
  49216. * Adds a side to the polygon
  49217. * @param positions points that make the polygon
  49218. * @param normals normals of the polygon
  49219. * @param uvs uvs of the polygon
  49220. * @param indices indices of the polygon
  49221. * @param bounds bounds of the polygon
  49222. * @param points points of the polygon
  49223. * @param depth depth of the polygon
  49224. * @param flip flip of the polygon
  49225. */
  49226. private addSide;
  49227. }
  49228. }
  49229. declare module BABYLON {
  49230. /**
  49231. * Class containing static functions to help procedurally build meshes
  49232. */
  49233. export class PolygonBuilder {
  49234. /**
  49235. * Creates a polygon mesh
  49236. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49237. * * 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
  49238. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49240. * * 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)
  49241. * * Remember you can only change the shape positions, not their number when updating a polygon
  49242. * @param name defines the name of the mesh
  49243. * @param options defines the options used to create the mesh
  49244. * @param scene defines the hosting scene
  49245. * @param earcutInjection can be used to inject your own earcut reference
  49246. * @returns the polygon mesh
  49247. */
  49248. static CreatePolygon(name: string, options: {
  49249. shape: Vector3[];
  49250. holes?: Vector3[][];
  49251. depth?: number;
  49252. faceUV?: Vector4[];
  49253. faceColors?: Color4[];
  49254. updatable?: boolean;
  49255. sideOrientation?: number;
  49256. frontUVs?: Vector4;
  49257. backUVs?: Vector4;
  49258. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49259. /**
  49260. * Creates an extruded polygon mesh, with depth in the Y direction.
  49261. * * 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)
  49262. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @param earcutInjection can be used to inject your own earcut reference
  49267. * @returns the polygon mesh
  49268. */
  49269. static ExtrudePolygon(name: string, options: {
  49270. shape: Vector3[];
  49271. holes?: Vector3[][];
  49272. depth?: number;
  49273. faceUV?: Vector4[];
  49274. faceColors?: Color4[];
  49275. updatable?: boolean;
  49276. sideOrientation?: number;
  49277. frontUVs?: Vector4;
  49278. backUVs?: Vector4;
  49279. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49280. }
  49281. }
  49282. declare module BABYLON {
  49283. /**
  49284. * Class containing static functions to help procedurally build meshes
  49285. */
  49286. export class LatheBuilder {
  49287. /**
  49288. * Creates lathe mesh.
  49289. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49290. * * 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
  49291. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49292. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49293. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49294. * * 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
  49295. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49296. * * 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
  49297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49298. * * 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
  49299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49301. * @param name defines the name of the mesh
  49302. * @param options defines the options used to create the mesh
  49303. * @param scene defines the hosting scene
  49304. * @returns the lathe mesh
  49305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49306. */
  49307. static CreateLathe(name: string, options: {
  49308. shape: Vector3[];
  49309. radius?: number;
  49310. tessellation?: number;
  49311. clip?: number;
  49312. arc?: number;
  49313. closed?: boolean;
  49314. updatable?: boolean;
  49315. sideOrientation?: number;
  49316. frontUVs?: Vector4;
  49317. backUVs?: Vector4;
  49318. cap?: number;
  49319. invertUV?: boolean;
  49320. }, scene?: Nullable<Scene>): Mesh;
  49321. }
  49322. }
  49323. declare module BABYLON {
  49324. /**
  49325. * Class containing static functions to help procedurally build meshes
  49326. */
  49327. export class TubeBuilder {
  49328. /**
  49329. * Creates a tube mesh.
  49330. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49331. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49332. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49333. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49334. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49335. * * 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)
  49336. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49337. * * 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
  49338. * * 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
  49339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49340. * * 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
  49341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49343. * @param name defines the name of the mesh
  49344. * @param options defines the options used to create the mesh
  49345. * @param scene defines the hosting scene
  49346. * @returns the tube mesh
  49347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49348. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49349. */
  49350. static CreateTube(name: string, options: {
  49351. path: Vector3[];
  49352. radius?: number;
  49353. tessellation?: number;
  49354. radiusFunction?: {
  49355. (i: number, distance: number): number;
  49356. };
  49357. cap?: number;
  49358. arc?: number;
  49359. updatable?: boolean;
  49360. sideOrientation?: number;
  49361. frontUVs?: Vector4;
  49362. backUVs?: Vector4;
  49363. instance?: Mesh;
  49364. invertUV?: boolean;
  49365. }, scene?: Nullable<Scene>): Mesh;
  49366. }
  49367. }
  49368. declare module BABYLON {
  49369. /**
  49370. * Class containing static functions to help procedurally build meshes
  49371. */
  49372. export class IcoSphereBuilder {
  49373. /**
  49374. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49375. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49376. * * 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`)
  49377. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49378. * * 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
  49379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49380. * * 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
  49381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49382. * @param name defines the name of the mesh
  49383. * @param options defines the options used to create the mesh
  49384. * @param scene defines the hosting scene
  49385. * @returns the icosahedron mesh
  49386. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49387. */
  49388. static CreateIcoSphere(name: string, options: {
  49389. radius?: number;
  49390. radiusX?: number;
  49391. radiusY?: number;
  49392. radiusZ?: number;
  49393. flat?: boolean;
  49394. subdivisions?: number;
  49395. sideOrientation?: number;
  49396. frontUVs?: Vector4;
  49397. backUVs?: Vector4;
  49398. updatable?: boolean;
  49399. }, scene?: Nullable<Scene>): Mesh;
  49400. }
  49401. }
  49402. declare module BABYLON {
  49403. /**
  49404. * Class containing static functions to help procedurally build meshes
  49405. */
  49406. export class DecalBuilder {
  49407. /**
  49408. * Creates a decal mesh.
  49409. * 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
  49410. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49411. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49412. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49413. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49414. * @param name defines the name of the mesh
  49415. * @param sourceMesh defines the mesh where the decal must be applied
  49416. * @param options defines the options used to create the mesh
  49417. * @param scene defines the hosting scene
  49418. * @returns the decal mesh
  49419. * @see https://doc.babylonjs.com/how_to/decals
  49420. */
  49421. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49422. position?: Vector3;
  49423. normal?: Vector3;
  49424. size?: Vector3;
  49425. angle?: number;
  49426. }): Mesh;
  49427. }
  49428. }
  49429. declare module BABYLON {
  49430. /**
  49431. * Class containing static functions to help procedurally build meshes
  49432. */
  49433. export class MeshBuilder {
  49434. /**
  49435. * Creates a box mesh
  49436. * * The parameter `size` sets the size (float) of each box side (default 1)
  49437. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49438. * * 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)
  49439. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49441. * * 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
  49442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49443. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49444. * @param name defines the name of the mesh
  49445. * @param options defines the options used to create the mesh
  49446. * @param scene defines the hosting scene
  49447. * @returns the box mesh
  49448. */
  49449. static CreateBox(name: string, options: {
  49450. size?: number;
  49451. width?: number;
  49452. height?: number;
  49453. depth?: number;
  49454. faceUV?: Vector4[];
  49455. faceColors?: Color4[];
  49456. sideOrientation?: number;
  49457. frontUVs?: Vector4;
  49458. backUVs?: Vector4;
  49459. updatable?: boolean;
  49460. }, scene?: Nullable<Scene>): Mesh;
  49461. /**
  49462. * Creates a sphere mesh
  49463. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49464. * * 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`)
  49465. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49466. * * 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
  49467. * * 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)
  49468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49469. * * 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
  49470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49471. * @param name defines the name of the mesh
  49472. * @param options defines the options used to create the mesh
  49473. * @param scene defines the hosting scene
  49474. * @returns the sphere mesh
  49475. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49476. */
  49477. static CreateSphere(name: string, options: {
  49478. segments?: number;
  49479. diameter?: number;
  49480. diameterX?: number;
  49481. diameterY?: number;
  49482. diameterZ?: number;
  49483. arc?: number;
  49484. slice?: number;
  49485. sideOrientation?: number;
  49486. frontUVs?: Vector4;
  49487. backUVs?: Vector4;
  49488. updatable?: boolean;
  49489. }, scene?: Nullable<Scene>): Mesh;
  49490. /**
  49491. * Creates a plane polygonal mesh. By default, this is a disc
  49492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49493. * * 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
  49494. * * 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
  49495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49496. * * 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
  49497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49498. * @param name defines the name of the mesh
  49499. * @param options defines the options used to create the mesh
  49500. * @param scene defines the hosting scene
  49501. * @returns the plane polygonal mesh
  49502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49503. */
  49504. static CreateDisc(name: string, options: {
  49505. radius?: number;
  49506. tessellation?: number;
  49507. arc?: number;
  49508. updatable?: boolean;
  49509. sideOrientation?: number;
  49510. frontUVs?: Vector4;
  49511. backUVs?: Vector4;
  49512. }, scene?: Nullable<Scene>): Mesh;
  49513. /**
  49514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49516. * * 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`)
  49517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49518. * * 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
  49519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49520. * * 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
  49521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49522. * @param name defines the name of the mesh
  49523. * @param options defines the options used to create the mesh
  49524. * @param scene defines the hosting scene
  49525. * @returns the icosahedron mesh
  49526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49527. */
  49528. static CreateIcoSphere(name: string, options: {
  49529. radius?: number;
  49530. radiusX?: number;
  49531. radiusY?: number;
  49532. radiusZ?: number;
  49533. flat?: boolean;
  49534. subdivisions?: number;
  49535. sideOrientation?: number;
  49536. frontUVs?: Vector4;
  49537. backUVs?: Vector4;
  49538. updatable?: boolean;
  49539. }, scene?: Nullable<Scene>): Mesh;
  49540. /**
  49541. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49542. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49543. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49544. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49545. * * 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
  49546. * * 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
  49547. * * 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
  49548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49549. * * 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
  49550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49551. * * 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
  49552. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49553. * * 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
  49554. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49556. * @param name defines the name of the mesh
  49557. * @param options defines the options used to create the mesh
  49558. * @param scene defines the hosting scene
  49559. * @returns the ribbon mesh
  49560. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49562. */
  49563. static CreateRibbon(name: string, options: {
  49564. pathArray: Vector3[][];
  49565. closeArray?: boolean;
  49566. closePath?: boolean;
  49567. offset?: number;
  49568. updatable?: boolean;
  49569. sideOrientation?: number;
  49570. frontUVs?: Vector4;
  49571. backUVs?: Vector4;
  49572. instance?: Mesh;
  49573. invertUV?: boolean;
  49574. uvs?: Vector2[];
  49575. colors?: Color4[];
  49576. }, scene?: Nullable<Scene>): Mesh;
  49577. /**
  49578. * Creates a cylinder or a cone mesh
  49579. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49580. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49581. * * 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.
  49582. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49583. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49584. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49585. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49586. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49587. * * 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).
  49588. * * 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
  49589. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49590. * * 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
  49591. * * 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.
  49592. * * If `enclose` is false, a ring surface is one element.
  49593. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49594. * * 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
  49595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49596. * * 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
  49597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49598. * @param name defines the name of the mesh
  49599. * @param options defines the options used to create the mesh
  49600. * @param scene defines the hosting scene
  49601. * @returns the cylinder mesh
  49602. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49603. */
  49604. static CreateCylinder(name: string, options: {
  49605. height?: number;
  49606. diameterTop?: number;
  49607. diameterBottom?: number;
  49608. diameter?: number;
  49609. tessellation?: number;
  49610. subdivisions?: number;
  49611. arc?: number;
  49612. faceColors?: Color4[];
  49613. faceUV?: Vector4[];
  49614. updatable?: boolean;
  49615. hasRings?: boolean;
  49616. enclose?: boolean;
  49617. sideOrientation?: number;
  49618. frontUVs?: Vector4;
  49619. backUVs?: Vector4;
  49620. }, scene?: Nullable<Scene>): Mesh;
  49621. /**
  49622. * Creates a torus mesh
  49623. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49624. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49625. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49627. * * 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
  49628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49629. * @param name defines the name of the mesh
  49630. * @param options defines the options used to create the mesh
  49631. * @param scene defines the hosting scene
  49632. * @returns the torus mesh
  49633. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49634. */
  49635. static CreateTorus(name: string, options: {
  49636. diameter?: number;
  49637. thickness?: number;
  49638. tessellation?: number;
  49639. updatable?: boolean;
  49640. sideOrientation?: number;
  49641. frontUVs?: Vector4;
  49642. backUVs?: Vector4;
  49643. }, scene?: Nullable<Scene>): Mesh;
  49644. /**
  49645. * Creates a torus knot mesh
  49646. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49647. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49648. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49649. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49651. * * 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
  49652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49653. * @param name defines the name of the mesh
  49654. * @param options defines the options used to create the mesh
  49655. * @param scene defines the hosting scene
  49656. * @returns the torus knot mesh
  49657. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49658. */
  49659. static CreateTorusKnot(name: string, options: {
  49660. radius?: number;
  49661. tube?: number;
  49662. radialSegments?: number;
  49663. tubularSegments?: number;
  49664. p?: number;
  49665. q?: number;
  49666. updatable?: boolean;
  49667. sideOrientation?: number;
  49668. frontUVs?: Vector4;
  49669. backUVs?: Vector4;
  49670. }, scene?: Nullable<Scene>): Mesh;
  49671. /**
  49672. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49673. * * 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
  49674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49675. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49676. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49677. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49678. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49679. * * 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
  49680. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49683. * @param name defines the name of the new line system
  49684. * @param options defines the options used to create the line system
  49685. * @param scene defines the hosting scene
  49686. * @returns a new line system mesh
  49687. */
  49688. static CreateLineSystem(name: string, options: {
  49689. lines: Vector3[][];
  49690. updatable?: boolean;
  49691. instance?: Nullable<LinesMesh>;
  49692. colors?: Nullable<Color4[][]>;
  49693. useVertexAlpha?: boolean;
  49694. }, scene: Nullable<Scene>): LinesMesh;
  49695. /**
  49696. * Creates a line mesh
  49697. * 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
  49698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49699. * * The parameter `points` is an array successive Vector3
  49700. * * 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
  49701. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49703. * * When updating an instance, remember that only point positions can change, not the number of points
  49704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49706. * @param name defines the name of the new line system
  49707. * @param options defines the options used to create the line system
  49708. * @param scene defines the hosting scene
  49709. * @returns a new line mesh
  49710. */
  49711. static CreateLines(name: string, options: {
  49712. points: Vector3[];
  49713. updatable?: boolean;
  49714. instance?: Nullable<LinesMesh>;
  49715. colors?: Color4[];
  49716. useVertexAlpha?: boolean;
  49717. }, scene?: Nullable<Scene>): LinesMesh;
  49718. /**
  49719. * Creates a dashed line mesh
  49720. * * 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
  49721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49722. * * The parameter `points` is an array successive Vector3
  49723. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49724. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49725. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49726. * * 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
  49727. * * When updating an instance, remember that only point positions can change, not the number of points
  49728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49729. * @param name defines the name of the mesh
  49730. * @param options defines the options used to create the mesh
  49731. * @param scene defines the hosting scene
  49732. * @returns the dashed line mesh
  49733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49734. */
  49735. static CreateDashedLines(name: string, options: {
  49736. points: Vector3[];
  49737. dashSize?: number;
  49738. gapSize?: number;
  49739. dashNb?: number;
  49740. updatable?: boolean;
  49741. instance?: LinesMesh;
  49742. }, scene?: Nullable<Scene>): LinesMesh;
  49743. /**
  49744. * 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.
  49745. * * 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.
  49746. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49747. * * 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.
  49748. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49749. * * 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
  49750. * * 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
  49751. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49753. * * 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
  49754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49756. * @param name defines the name of the mesh
  49757. * @param options defines the options used to create the mesh
  49758. * @param scene defines the hosting scene
  49759. * @returns the extruded shape mesh
  49760. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49762. */
  49763. static ExtrudeShape(name: string, options: {
  49764. shape: Vector3[];
  49765. path: Vector3[];
  49766. scale?: number;
  49767. rotation?: number;
  49768. cap?: number;
  49769. updatable?: boolean;
  49770. sideOrientation?: number;
  49771. frontUVs?: Vector4;
  49772. backUVs?: Vector4;
  49773. instance?: Mesh;
  49774. invertUV?: boolean;
  49775. }, scene?: Nullable<Scene>): Mesh;
  49776. /**
  49777. * Creates an custom extruded shape mesh.
  49778. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49779. * * 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.
  49780. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49781. * * 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
  49782. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49783. * * 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
  49784. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49785. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49786. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49787. * * 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
  49788. * * 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
  49789. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49791. * * 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
  49792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49794. * @param name defines the name of the mesh
  49795. * @param options defines the options used to create the mesh
  49796. * @param scene defines the hosting scene
  49797. * @returns the custom extruded shape mesh
  49798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49801. */
  49802. static ExtrudeShapeCustom(name: string, options: {
  49803. shape: Vector3[];
  49804. path: Vector3[];
  49805. scaleFunction?: any;
  49806. rotationFunction?: any;
  49807. ribbonCloseArray?: boolean;
  49808. ribbonClosePath?: boolean;
  49809. cap?: number;
  49810. updatable?: boolean;
  49811. sideOrientation?: number;
  49812. frontUVs?: Vector4;
  49813. backUVs?: Vector4;
  49814. instance?: Mesh;
  49815. invertUV?: boolean;
  49816. }, scene?: Nullable<Scene>): Mesh;
  49817. /**
  49818. * Creates lathe mesh.
  49819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49820. * * 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
  49821. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49822. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49823. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49824. * * 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
  49825. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49826. * * 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
  49827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49828. * * 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
  49829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49831. * @param name defines the name of the mesh
  49832. * @param options defines the options used to create the mesh
  49833. * @param scene defines the hosting scene
  49834. * @returns the lathe mesh
  49835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49836. */
  49837. static CreateLathe(name: string, options: {
  49838. shape: Vector3[];
  49839. radius?: number;
  49840. tessellation?: number;
  49841. clip?: number;
  49842. arc?: number;
  49843. closed?: boolean;
  49844. updatable?: boolean;
  49845. sideOrientation?: number;
  49846. frontUVs?: Vector4;
  49847. backUVs?: Vector4;
  49848. cap?: number;
  49849. invertUV?: boolean;
  49850. }, scene?: Nullable<Scene>): Mesh;
  49851. /**
  49852. * Creates a plane mesh
  49853. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49854. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49855. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49857. * * 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
  49858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49859. * @param name defines the name of the mesh
  49860. * @param options defines the options used to create the mesh
  49861. * @param scene defines the hosting scene
  49862. * @returns the plane mesh
  49863. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49864. */
  49865. static CreatePlane(name: string, options: {
  49866. size?: number;
  49867. width?: number;
  49868. height?: number;
  49869. sideOrientation?: number;
  49870. frontUVs?: Vector4;
  49871. backUVs?: Vector4;
  49872. updatable?: boolean;
  49873. sourcePlane?: Plane;
  49874. }, scene?: Nullable<Scene>): Mesh;
  49875. /**
  49876. * Creates a ground mesh
  49877. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49878. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49880. * @param name defines the name of the mesh
  49881. * @param options defines the options used to create the mesh
  49882. * @param scene defines the hosting scene
  49883. * @returns the ground mesh
  49884. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49885. */
  49886. static CreateGround(name: string, options: {
  49887. width?: number;
  49888. height?: number;
  49889. subdivisions?: number;
  49890. subdivisionsX?: number;
  49891. subdivisionsY?: number;
  49892. updatable?: boolean;
  49893. }, scene?: Nullable<Scene>): Mesh;
  49894. /**
  49895. * Creates a tiled ground mesh
  49896. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49897. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49898. * * 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
  49899. * * 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
  49900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49901. * @param name defines the name of the mesh
  49902. * @param options defines the options used to create the mesh
  49903. * @param scene defines the hosting scene
  49904. * @returns the tiled ground mesh
  49905. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49906. */
  49907. static CreateTiledGround(name: string, options: {
  49908. xmin: number;
  49909. zmin: number;
  49910. xmax: number;
  49911. zmax: number;
  49912. subdivisions?: {
  49913. w: number;
  49914. h: number;
  49915. };
  49916. precision?: {
  49917. w: number;
  49918. h: number;
  49919. };
  49920. updatable?: boolean;
  49921. }, scene?: Nullable<Scene>): Mesh;
  49922. /**
  49923. * Creates a ground mesh from a height map
  49924. * * The parameter `url` sets the URL of the height map image resource.
  49925. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49926. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49927. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49928. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49929. * * 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.
  49930. * * 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).
  49931. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49933. * @param name defines the name of the mesh
  49934. * @param url defines the url to the height map
  49935. * @param options defines the options used to create the mesh
  49936. * @param scene defines the hosting scene
  49937. * @returns the ground mesh
  49938. * @see https://doc.babylonjs.com/babylon101/height_map
  49939. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49940. */
  49941. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49942. width?: number;
  49943. height?: number;
  49944. subdivisions?: number;
  49945. minHeight?: number;
  49946. maxHeight?: number;
  49947. colorFilter?: Color3;
  49948. alphaFilter?: number;
  49949. updatable?: boolean;
  49950. onReady?: (mesh: GroundMesh) => void;
  49951. }, scene?: Nullable<Scene>): GroundMesh;
  49952. /**
  49953. * Creates a polygon mesh
  49954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49955. * * 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
  49956. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49958. * * 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)
  49959. * * Remember you can only change the shape positions, not their number when updating a polygon
  49960. * @param name defines the name of the mesh
  49961. * @param options defines the options used to create the mesh
  49962. * @param scene defines the hosting scene
  49963. * @param earcutInjection can be used to inject your own earcut reference
  49964. * @returns the polygon mesh
  49965. */
  49966. static CreatePolygon(name: string, options: {
  49967. shape: Vector3[];
  49968. holes?: Vector3[][];
  49969. depth?: number;
  49970. faceUV?: Vector4[];
  49971. faceColors?: Color4[];
  49972. updatable?: boolean;
  49973. sideOrientation?: number;
  49974. frontUVs?: Vector4;
  49975. backUVs?: Vector4;
  49976. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49977. /**
  49978. * Creates an extruded polygon mesh, with depth in the Y direction.
  49979. * * 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)
  49980. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49981. * @param name defines the name of the mesh
  49982. * @param options defines the options used to create the mesh
  49983. * @param scene defines the hosting scene
  49984. * @param earcutInjection can be used to inject your own earcut reference
  49985. * @returns the polygon mesh
  49986. */
  49987. static ExtrudePolygon(name: string, options: {
  49988. shape: Vector3[];
  49989. holes?: Vector3[][];
  49990. depth?: number;
  49991. faceUV?: Vector4[];
  49992. faceColors?: Color4[];
  49993. updatable?: boolean;
  49994. sideOrientation?: number;
  49995. frontUVs?: Vector4;
  49996. backUVs?: Vector4;
  49997. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49998. /**
  49999. * Creates a tube mesh.
  50000. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50001. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50002. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50003. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50004. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50005. * * 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)
  50006. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50007. * * 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
  50008. * * 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
  50009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50010. * * 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
  50011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50013. * @param name defines the name of the mesh
  50014. * @param options defines the options used to create the mesh
  50015. * @param scene defines the hosting scene
  50016. * @returns the tube mesh
  50017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50018. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50019. */
  50020. static CreateTube(name: string, options: {
  50021. path: Vector3[];
  50022. radius?: number;
  50023. tessellation?: number;
  50024. radiusFunction?: {
  50025. (i: number, distance: number): number;
  50026. };
  50027. cap?: number;
  50028. arc?: number;
  50029. updatable?: boolean;
  50030. sideOrientation?: number;
  50031. frontUVs?: Vector4;
  50032. backUVs?: Vector4;
  50033. instance?: Mesh;
  50034. invertUV?: boolean;
  50035. }, scene?: Nullable<Scene>): Mesh;
  50036. /**
  50037. * Creates a polyhedron mesh
  50038. * * 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
  50039. * * The parameter `size` (positive float, default 1) sets the polygon size
  50040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50041. * * 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`
  50042. * * 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
  50043. * * 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)`)
  50044. * * 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
  50045. * * 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
  50046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50047. * * 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
  50048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50049. * @param name defines the name of the mesh
  50050. * @param options defines the options used to create the mesh
  50051. * @param scene defines the hosting scene
  50052. * @returns the polyhedron mesh
  50053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50054. */
  50055. static CreatePolyhedron(name: string, options: {
  50056. type?: number;
  50057. size?: number;
  50058. sizeX?: number;
  50059. sizeY?: number;
  50060. sizeZ?: number;
  50061. custom?: any;
  50062. faceUV?: Vector4[];
  50063. faceColors?: Color4[];
  50064. flat?: boolean;
  50065. updatable?: boolean;
  50066. sideOrientation?: number;
  50067. frontUVs?: Vector4;
  50068. backUVs?: Vector4;
  50069. }, scene?: Nullable<Scene>): Mesh;
  50070. /**
  50071. * Creates a decal mesh.
  50072. * 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
  50073. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50074. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50075. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50076. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50077. * @param name defines the name of the mesh
  50078. * @param sourceMesh defines the mesh where the decal must be applied
  50079. * @param options defines the options used to create the mesh
  50080. * @param scene defines the hosting scene
  50081. * @returns the decal mesh
  50082. * @see https://doc.babylonjs.com/how_to/decals
  50083. */
  50084. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50085. position?: Vector3;
  50086. normal?: Vector3;
  50087. size?: Vector3;
  50088. angle?: number;
  50089. }): Mesh;
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * A simplifier interface for future simplification implementations
  50095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50096. */
  50097. export interface ISimplifier {
  50098. /**
  50099. * Simplification of a given mesh according to the given settings.
  50100. * Since this requires computation, it is assumed that the function runs async.
  50101. * @param settings The settings of the simplification, including quality and distance
  50102. * @param successCallback A callback that will be called after the mesh was simplified.
  50103. * @param errorCallback in case of an error, this callback will be called. optional.
  50104. */
  50105. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50106. }
  50107. /**
  50108. * Expected simplification settings.
  50109. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50111. */
  50112. export interface ISimplificationSettings {
  50113. /**
  50114. * Gets or sets the expected quality
  50115. */
  50116. quality: number;
  50117. /**
  50118. * Gets or sets the distance when this optimized version should be used
  50119. */
  50120. distance: number;
  50121. /**
  50122. * Gets an already optimized mesh
  50123. */
  50124. optimizeMesh?: boolean;
  50125. }
  50126. /**
  50127. * Class used to specify simplification options
  50128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50129. */
  50130. export class SimplificationSettings implements ISimplificationSettings {
  50131. /** expected quality */
  50132. quality: number;
  50133. /** distance when this optimized version should be used */
  50134. distance: number;
  50135. /** already optimized mesh */
  50136. optimizeMesh?: boolean | undefined;
  50137. /**
  50138. * Creates a SimplificationSettings
  50139. * @param quality expected quality
  50140. * @param distance distance when this optimized version should be used
  50141. * @param optimizeMesh already optimized mesh
  50142. */
  50143. constructor(
  50144. /** expected quality */
  50145. quality: number,
  50146. /** distance when this optimized version should be used */
  50147. distance: number,
  50148. /** already optimized mesh */
  50149. optimizeMesh?: boolean | undefined);
  50150. }
  50151. /**
  50152. * Interface used to define a simplification task
  50153. */
  50154. export interface ISimplificationTask {
  50155. /**
  50156. * Array of settings
  50157. */
  50158. settings: Array<ISimplificationSettings>;
  50159. /**
  50160. * Simplification type
  50161. */
  50162. simplificationType: SimplificationType;
  50163. /**
  50164. * Mesh to simplify
  50165. */
  50166. mesh: Mesh;
  50167. /**
  50168. * Callback called on success
  50169. */
  50170. successCallback?: () => void;
  50171. /**
  50172. * Defines if parallel processing can be used
  50173. */
  50174. parallelProcessing: boolean;
  50175. }
  50176. /**
  50177. * Queue used to order the simplification tasks
  50178. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50179. */
  50180. export class SimplificationQueue {
  50181. private _simplificationArray;
  50182. /**
  50183. * Gets a boolean indicating that the process is still running
  50184. */
  50185. running: boolean;
  50186. /**
  50187. * Creates a new queue
  50188. */
  50189. constructor();
  50190. /**
  50191. * Adds a new simplification task
  50192. * @param task defines a task to add
  50193. */
  50194. addTask(task: ISimplificationTask): void;
  50195. /**
  50196. * Execute next task
  50197. */
  50198. executeNext(): void;
  50199. /**
  50200. * Execute a simplification task
  50201. * @param task defines the task to run
  50202. */
  50203. runSimplification(task: ISimplificationTask): void;
  50204. private getSimplifier;
  50205. }
  50206. /**
  50207. * The implemented types of simplification
  50208. * At the moment only Quadratic Error Decimation is implemented
  50209. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50210. */
  50211. export enum SimplificationType {
  50212. /** Quadratic error decimation */
  50213. QUADRATIC = 0
  50214. }
  50215. }
  50216. declare module BABYLON {
  50217. interface Scene {
  50218. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50219. /**
  50220. * Gets or sets the simplification queue attached to the scene
  50221. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50222. */
  50223. simplificationQueue: SimplificationQueue;
  50224. }
  50225. interface Mesh {
  50226. /**
  50227. * Simplify the mesh according to the given array of settings.
  50228. * Function will return immediately and will simplify async
  50229. * @param settings a collection of simplification settings
  50230. * @param parallelProcessing should all levels calculate parallel or one after the other
  50231. * @param simplificationType the type of simplification to run
  50232. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50233. * @returns the current mesh
  50234. */
  50235. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50236. }
  50237. /**
  50238. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50239. * created in a scene
  50240. */
  50241. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50242. /**
  50243. * The component name helpfull to identify the component in the list of scene components.
  50244. */
  50245. readonly name: string;
  50246. /**
  50247. * The scene the component belongs to.
  50248. */
  50249. scene: Scene;
  50250. /**
  50251. * Creates a new instance of the component for the given scene
  50252. * @param scene Defines the scene to register the component in
  50253. */
  50254. constructor(scene: Scene);
  50255. /**
  50256. * Registers the component in a given scene
  50257. */
  50258. register(): void;
  50259. /**
  50260. * Rebuilds the elements related to this component in case of
  50261. * context lost for instance.
  50262. */
  50263. rebuild(): void;
  50264. /**
  50265. * Disposes the component and the associated ressources
  50266. */
  50267. dispose(): void;
  50268. private _beforeCameraUpdate;
  50269. }
  50270. }
  50271. declare module BABYLON {
  50272. /**
  50273. * Class used to enable access to IndexedDB
  50274. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50275. */
  50276. export class Database implements IOfflineProvider {
  50277. private _callbackManifestChecked;
  50278. private _currentSceneUrl;
  50279. private _db;
  50280. private _enableSceneOffline;
  50281. private _enableTexturesOffline;
  50282. private _manifestVersionFound;
  50283. private _mustUpdateRessources;
  50284. private _hasReachedQuota;
  50285. private _isSupported;
  50286. private _idbFactory;
  50287. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50288. private static IsUASupportingBlobStorage;
  50289. /**
  50290. * Gets a boolean indicating if Database storate is enabled (off by default)
  50291. */
  50292. static IDBStorageEnabled: boolean;
  50293. /**
  50294. * Gets a boolean indicating if scene must be saved in the database
  50295. */
  50296. readonly enableSceneOffline: boolean;
  50297. /**
  50298. * Gets a boolean indicating if textures must be saved in the database
  50299. */
  50300. readonly enableTexturesOffline: boolean;
  50301. /**
  50302. * Creates a new Database
  50303. * @param urlToScene defines the url to load the scene
  50304. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50305. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50306. */
  50307. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50308. private static _ParseURL;
  50309. private static _ReturnFullUrlLocation;
  50310. private _checkManifestFile;
  50311. /**
  50312. * Open the database and make it available
  50313. * @param successCallback defines the callback to call on success
  50314. * @param errorCallback defines the callback to call on error
  50315. */
  50316. open(successCallback: () => void, errorCallback: () => void): void;
  50317. /**
  50318. * Loads an image from the database
  50319. * @param url defines the url to load from
  50320. * @param image defines the target DOM image
  50321. */
  50322. loadImage(url: string, image: HTMLImageElement): void;
  50323. private _loadImageFromDBAsync;
  50324. private _saveImageIntoDBAsync;
  50325. private _checkVersionFromDB;
  50326. private _loadVersionFromDBAsync;
  50327. private _saveVersionIntoDBAsync;
  50328. /**
  50329. * Loads a file from database
  50330. * @param url defines the URL to load from
  50331. * @param sceneLoaded defines a callback to call on success
  50332. * @param progressCallBack defines a callback to call when progress changed
  50333. * @param errorCallback defines a callback to call on error
  50334. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50335. */
  50336. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50337. private _loadFileAsync;
  50338. private _saveFileAsync;
  50339. /**
  50340. * Validates if xhr data is correct
  50341. * @param xhr defines the request to validate
  50342. * @param dataType defines the expected data type
  50343. * @returns true if data is correct
  50344. */
  50345. private static _ValidateXHRData;
  50346. }
  50347. }
  50348. declare module BABYLON {
  50349. /** @hidden */
  50350. export var gpuUpdateParticlesPixelShader: {
  50351. name: string;
  50352. shader: string;
  50353. };
  50354. }
  50355. declare module BABYLON {
  50356. /** @hidden */
  50357. export var gpuUpdateParticlesVertexShader: {
  50358. name: string;
  50359. shader: string;
  50360. };
  50361. }
  50362. declare module BABYLON {
  50363. /** @hidden */
  50364. export var clipPlaneFragmentDeclaration2: {
  50365. name: string;
  50366. shader: string;
  50367. };
  50368. }
  50369. declare module BABYLON {
  50370. /** @hidden */
  50371. export var gpuRenderParticlesPixelShader: {
  50372. name: string;
  50373. shader: string;
  50374. };
  50375. }
  50376. declare module BABYLON {
  50377. /** @hidden */
  50378. export var clipPlaneVertexDeclaration2: {
  50379. name: string;
  50380. shader: string;
  50381. };
  50382. }
  50383. declare module BABYLON {
  50384. /** @hidden */
  50385. export var gpuRenderParticlesVertexShader: {
  50386. name: string;
  50387. shader: string;
  50388. };
  50389. }
  50390. declare module BABYLON {
  50391. /**
  50392. * This represents a GPU particle system in Babylon
  50393. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50394. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50395. */
  50396. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50397. /**
  50398. * The layer mask we are rendering the particles through.
  50399. */
  50400. layerMask: number;
  50401. private _capacity;
  50402. private _activeCount;
  50403. private _currentActiveCount;
  50404. private _accumulatedCount;
  50405. private _renderEffect;
  50406. private _updateEffect;
  50407. private _buffer0;
  50408. private _buffer1;
  50409. private _spriteBuffer;
  50410. private _updateVAO;
  50411. private _renderVAO;
  50412. private _targetIndex;
  50413. private _sourceBuffer;
  50414. private _targetBuffer;
  50415. private _engine;
  50416. private _currentRenderId;
  50417. private _started;
  50418. private _stopped;
  50419. private _timeDelta;
  50420. private _randomTexture;
  50421. private _randomTexture2;
  50422. private _attributesStrideSize;
  50423. private _updateEffectOptions;
  50424. private _randomTextureSize;
  50425. private _actualFrame;
  50426. private readonly _rawTextureWidth;
  50427. /**
  50428. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50429. */
  50430. static readonly IsSupported: boolean;
  50431. /**
  50432. * An event triggered when the system is disposed.
  50433. */
  50434. onDisposeObservable: Observable<GPUParticleSystem>;
  50435. /**
  50436. * Gets the maximum number of particles active at the same time.
  50437. * @returns The max number of active particles.
  50438. */
  50439. getCapacity(): number;
  50440. /**
  50441. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50442. * to override the particles.
  50443. */
  50444. forceDepthWrite: boolean;
  50445. /**
  50446. * Gets or set the number of active particles
  50447. */
  50448. activeParticleCount: number;
  50449. private _preWarmDone;
  50450. /**
  50451. * Is this system ready to be used/rendered
  50452. * @return true if the system is ready
  50453. */
  50454. isReady(): boolean;
  50455. /**
  50456. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50457. * @returns True if it has been started, otherwise false.
  50458. */
  50459. isStarted(): boolean;
  50460. /**
  50461. * Starts the particle system and begins to emit
  50462. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50463. */
  50464. start(delay?: number): void;
  50465. /**
  50466. * Stops the particle system.
  50467. */
  50468. stop(): void;
  50469. /**
  50470. * Remove all active particles
  50471. */
  50472. reset(): void;
  50473. /**
  50474. * Returns the string "GPUParticleSystem"
  50475. * @returns a string containing the class name
  50476. */
  50477. getClassName(): string;
  50478. private _colorGradientsTexture;
  50479. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50480. /**
  50481. * Adds a new color gradient
  50482. * @param gradient defines the gradient to use (between 0 and 1)
  50483. * @param color1 defines the color to affect to the specified gradient
  50484. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50485. * @returns the current particle system
  50486. */
  50487. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50488. /**
  50489. * Remove a specific color gradient
  50490. * @param gradient defines the gradient to remove
  50491. * @returns the current particle system
  50492. */
  50493. removeColorGradient(gradient: number): GPUParticleSystem;
  50494. private _angularSpeedGradientsTexture;
  50495. private _sizeGradientsTexture;
  50496. private _velocityGradientsTexture;
  50497. private _limitVelocityGradientsTexture;
  50498. private _dragGradientsTexture;
  50499. private _addFactorGradient;
  50500. /**
  50501. * Adds a new size gradient
  50502. * @param gradient defines the gradient to use (between 0 and 1)
  50503. * @param factor defines the size factor to affect to the specified gradient
  50504. * @returns the current particle system
  50505. */
  50506. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50507. /**
  50508. * Remove a specific size gradient
  50509. * @param gradient defines the gradient to remove
  50510. * @returns the current particle system
  50511. */
  50512. removeSizeGradient(gradient: number): GPUParticleSystem;
  50513. /**
  50514. * Adds a new angular speed gradient
  50515. * @param gradient defines the gradient to use (between 0 and 1)
  50516. * @param factor defines the angular speed to affect to the specified gradient
  50517. * @returns the current particle system
  50518. */
  50519. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50520. /**
  50521. * Remove a specific angular speed gradient
  50522. * @param gradient defines the gradient to remove
  50523. * @returns the current particle system
  50524. */
  50525. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50526. /**
  50527. * Adds a new velocity gradient
  50528. * @param gradient defines the gradient to use (between 0 and 1)
  50529. * @param factor defines the velocity to affect to the specified gradient
  50530. * @returns the current particle system
  50531. */
  50532. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50533. /**
  50534. * Remove a specific velocity gradient
  50535. * @param gradient defines the gradient to remove
  50536. * @returns the current particle system
  50537. */
  50538. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50539. /**
  50540. * Adds a new limit velocity gradient
  50541. * @param gradient defines the gradient to use (between 0 and 1)
  50542. * @param factor defines the limit velocity value to affect to the specified gradient
  50543. * @returns the current particle system
  50544. */
  50545. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50546. /**
  50547. * Remove a specific limit velocity gradient
  50548. * @param gradient defines the gradient to remove
  50549. * @returns the current particle system
  50550. */
  50551. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50552. /**
  50553. * Adds a new drag gradient
  50554. * @param gradient defines the gradient to use (between 0 and 1)
  50555. * @param factor defines the drag value to affect to the specified gradient
  50556. * @returns the current particle system
  50557. */
  50558. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50559. /**
  50560. * Remove a specific drag gradient
  50561. * @param gradient defines the gradient to remove
  50562. * @returns the current particle system
  50563. */
  50564. removeDragGradient(gradient: number): GPUParticleSystem;
  50565. /**
  50566. * Not supported by GPUParticleSystem
  50567. * @param gradient defines the gradient to use (between 0 and 1)
  50568. * @param factor defines the emit rate value to affect to the specified gradient
  50569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50570. * @returns the current particle system
  50571. */
  50572. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50573. /**
  50574. * Not supported by GPUParticleSystem
  50575. * @param gradient defines the gradient to remove
  50576. * @returns the current particle system
  50577. */
  50578. removeEmitRateGradient(gradient: number): IParticleSystem;
  50579. /**
  50580. * Not supported by GPUParticleSystem
  50581. * @param gradient defines the gradient to use (between 0 and 1)
  50582. * @param factor defines the start size value to affect to the specified gradient
  50583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50584. * @returns the current particle system
  50585. */
  50586. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50587. /**
  50588. * Not supported by GPUParticleSystem
  50589. * @param gradient defines the gradient to remove
  50590. * @returns the current particle system
  50591. */
  50592. removeStartSizeGradient(gradient: number): IParticleSystem;
  50593. /**
  50594. * Not supported by GPUParticleSystem
  50595. * @param gradient defines the gradient to use (between 0 and 1)
  50596. * @param min defines the color remap minimal range
  50597. * @param max defines the color remap maximal range
  50598. * @returns the current particle system
  50599. */
  50600. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50601. /**
  50602. * Not supported by GPUParticleSystem
  50603. * @param gradient defines the gradient to remove
  50604. * @returns the current particle system
  50605. */
  50606. removeColorRemapGradient(): IParticleSystem;
  50607. /**
  50608. * Not supported by GPUParticleSystem
  50609. * @param gradient defines the gradient to use (between 0 and 1)
  50610. * @param min defines the alpha remap minimal range
  50611. * @param max defines the alpha remap maximal range
  50612. * @returns the current particle system
  50613. */
  50614. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50615. /**
  50616. * Not supported by GPUParticleSystem
  50617. * @param gradient defines the gradient to remove
  50618. * @returns the current particle system
  50619. */
  50620. removeAlphaRemapGradient(): IParticleSystem;
  50621. /**
  50622. * Not supported by GPUParticleSystem
  50623. * @param gradient defines the gradient to use (between 0 and 1)
  50624. * @param color defines the color to affect to the specified gradient
  50625. * @returns the current particle system
  50626. */
  50627. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50628. /**
  50629. * Not supported by GPUParticleSystem
  50630. * @param gradient defines the gradient to remove
  50631. * @returns the current particle system
  50632. */
  50633. removeRampGradient(): IParticleSystem;
  50634. /**
  50635. * Not supported by GPUParticleSystem
  50636. * @returns the list of ramp gradients
  50637. */
  50638. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50639. /**
  50640. * Not supported by GPUParticleSystem
  50641. * Gets or sets a boolean indicating that ramp gradients must be used
  50642. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50643. */
  50644. useRampGradients: boolean;
  50645. /**
  50646. * Not supported by GPUParticleSystem
  50647. * @param gradient defines the gradient to use (between 0 and 1)
  50648. * @param factor defines the life time factor to affect to the specified gradient
  50649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50650. * @returns the current particle system
  50651. */
  50652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50653. /**
  50654. * Not supported by GPUParticleSystem
  50655. * @param gradient defines the gradient to remove
  50656. * @returns the current particle system
  50657. */
  50658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50659. /**
  50660. * Instantiates a GPU particle system.
  50661. * 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.
  50662. * @param name The name of the particle system
  50663. * @param options The options used to create the system
  50664. * @param scene The scene the particle system belongs to
  50665. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50666. */
  50667. constructor(name: string, options: Partial<{
  50668. capacity: number;
  50669. randomTextureSize: number;
  50670. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50671. protected _reset(): void;
  50672. private _createUpdateVAO;
  50673. private _createRenderVAO;
  50674. private _initialize;
  50675. /** @hidden */ recreateUpdateEffect(): void;
  50676. /** @hidden */ recreateRenderEffect(): void;
  50677. /**
  50678. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50679. * @param preWarm defines if we are in the pre-warmimg phase
  50680. */
  50681. animate(preWarm?: boolean): void;
  50682. private _createFactorGradientTexture;
  50683. private _createSizeGradientTexture;
  50684. private _createAngularSpeedGradientTexture;
  50685. private _createVelocityGradientTexture;
  50686. private _createLimitVelocityGradientTexture;
  50687. private _createDragGradientTexture;
  50688. private _createColorGradientTexture;
  50689. /**
  50690. * Renders the particle system in its current state
  50691. * @param preWarm defines if the system should only update the particles but not render them
  50692. * @returns the current number of particles
  50693. */
  50694. render(preWarm?: boolean): number;
  50695. /**
  50696. * Rebuilds the particle system
  50697. */
  50698. rebuild(): void;
  50699. private _releaseBuffers;
  50700. private _releaseVAOs;
  50701. /**
  50702. * Disposes the particle system and free the associated resources
  50703. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50704. */
  50705. dispose(disposeTexture?: boolean): void;
  50706. /**
  50707. * Clones the particle system.
  50708. * @param name The name of the cloned object
  50709. * @param newEmitter The new emitter to use
  50710. * @returns the cloned particle system
  50711. */
  50712. clone(name: string, newEmitter: any): GPUParticleSystem;
  50713. /**
  50714. * Serializes the particle system to a JSON object.
  50715. * @returns the JSON object
  50716. */
  50717. serialize(): any;
  50718. /**
  50719. * Parses a JSON object to create a GPU particle system.
  50720. * @param parsedParticleSystem The JSON object to parse
  50721. * @param scene The scene to create the particle system in
  50722. * @param rootUrl The root url to use to load external dependencies like texture
  50723. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50724. * @returns the parsed GPU particle system
  50725. */
  50726. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50727. }
  50728. }
  50729. declare module BABYLON {
  50730. /**
  50731. * Represents a set of particle systems working together to create a specific effect
  50732. */
  50733. export class ParticleSystemSet implements IDisposable {
  50734. private _emitterCreationOptions;
  50735. private _emitterNode;
  50736. /**
  50737. * Gets the particle system list
  50738. */
  50739. systems: IParticleSystem[];
  50740. /**
  50741. * Gets the emitter node used with this set
  50742. */
  50743. readonly emitterNode: Nullable<TransformNode>;
  50744. /**
  50745. * Creates a new emitter mesh as a sphere
  50746. * @param options defines the options used to create the sphere
  50747. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50748. * @param scene defines the hosting scene
  50749. */
  50750. setEmitterAsSphere(options: {
  50751. diameter: number;
  50752. segments: number;
  50753. color: Color3;
  50754. }, renderingGroupId: number, scene: Scene): void;
  50755. /**
  50756. * Starts all particle systems of the set
  50757. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50758. */
  50759. start(emitter?: AbstractMesh): void;
  50760. /**
  50761. * Release all associated resources
  50762. */
  50763. dispose(): void;
  50764. /**
  50765. * Serialize the set into a JSON compatible object
  50766. * @returns a JSON compatible representation of the set
  50767. */
  50768. serialize(): any;
  50769. /**
  50770. * Parse a new ParticleSystemSet from a serialized source
  50771. * @param data defines a JSON compatible representation of the set
  50772. * @param scene defines the hosting scene
  50773. * @param gpu defines if we want GPU particles or CPU particles
  50774. * @returns a new ParticleSystemSet
  50775. */
  50776. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50777. }
  50778. }
  50779. declare module BABYLON {
  50780. /**
  50781. * This class is made for on one-liner static method to help creating particle system set.
  50782. */
  50783. export class ParticleHelper {
  50784. /**
  50785. * Gets or sets base Assets URL
  50786. */
  50787. static BaseAssetsUrl: string;
  50788. /**
  50789. * Create a default particle system that you can tweak
  50790. * @param emitter defines the emitter to use
  50791. * @param capacity defines the system capacity (default is 500 particles)
  50792. * @param scene defines the hosting scene
  50793. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50794. * @returns the new Particle system
  50795. */
  50796. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50797. /**
  50798. * This is the main static method (one-liner) of this helper to create different particle systems
  50799. * @param type This string represents the type to the particle system to create
  50800. * @param scene The scene where the particle system should live
  50801. * @param gpu If the system will use gpu
  50802. * @returns the ParticleSystemSet created
  50803. */
  50804. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50805. /**
  50806. * Static function used to export a particle system to a ParticleSystemSet variable.
  50807. * Please note that the emitter shape is not exported
  50808. * @param systems defines the particle systems to export
  50809. * @returns the created particle system set
  50810. */
  50811. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50812. }
  50813. }
  50814. declare module BABYLON {
  50815. interface Engine {
  50816. /**
  50817. * Create an effect to use with particle systems.
  50818. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50819. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50820. * @param uniformsNames defines a list of attribute names
  50821. * @param samplers defines an array of string used to represent textures
  50822. * @param defines defines the string containing the defines to use to compile the shaders
  50823. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50824. * @param onCompiled defines a function to call when the effect creation is successful
  50825. * @param onError defines a function to call when the effect creation has failed
  50826. * @returns the new Effect
  50827. */
  50828. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50829. }
  50830. interface Mesh {
  50831. /**
  50832. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50833. * @returns an array of IParticleSystem
  50834. */
  50835. getEmittedParticleSystems(): IParticleSystem[];
  50836. /**
  50837. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50838. * @returns an array of IParticleSystem
  50839. */
  50840. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50841. }
  50842. /**
  50843. * @hidden
  50844. */
  50845. export var _IDoNeedToBeInTheBuild: number;
  50846. }
  50847. declare module BABYLON {
  50848. interface Scene {
  50849. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50850. /**
  50851. * Gets the current physics engine
  50852. * @returns a IPhysicsEngine or null if none attached
  50853. */
  50854. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50855. /**
  50856. * Enables physics to the current scene
  50857. * @param gravity defines the scene's gravity for the physics engine
  50858. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50859. * @return a boolean indicating if the physics engine was initialized
  50860. */
  50861. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50862. /**
  50863. * Disables and disposes the physics engine associated with the scene
  50864. */
  50865. disablePhysicsEngine(): void;
  50866. /**
  50867. * Gets a boolean indicating if there is an active physics engine
  50868. * @returns a boolean indicating if there is an active physics engine
  50869. */
  50870. isPhysicsEnabled(): boolean;
  50871. /**
  50872. * Deletes a physics compound impostor
  50873. * @param compound defines the compound to delete
  50874. */
  50875. deleteCompoundImpostor(compound: any): void;
  50876. /**
  50877. * An event triggered when physic simulation is about to be run
  50878. */
  50879. onBeforePhysicsObservable: Observable<Scene>;
  50880. /**
  50881. * An event triggered when physic simulation has been done
  50882. */
  50883. onAfterPhysicsObservable: Observable<Scene>;
  50884. }
  50885. interface AbstractMesh {
  50886. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50887. /**
  50888. * Gets or sets impostor used for physic simulation
  50889. * @see http://doc.babylonjs.com/features/physics_engine
  50890. */
  50891. physicsImpostor: Nullable<PhysicsImpostor>;
  50892. /**
  50893. * Gets the current physics impostor
  50894. * @see http://doc.babylonjs.com/features/physics_engine
  50895. * @returns a physics impostor or null
  50896. */
  50897. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50898. /** Apply a physic impulse to the mesh
  50899. * @param force defines the force to apply
  50900. * @param contactPoint defines where to apply the force
  50901. * @returns the current mesh
  50902. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50903. */
  50904. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50905. /**
  50906. * Creates a physic joint between two meshes
  50907. * @param otherMesh defines the other mesh to use
  50908. * @param pivot1 defines the pivot to use on this mesh
  50909. * @param pivot2 defines the pivot to use on the other mesh
  50910. * @param options defines additional options (can be plugin dependent)
  50911. * @returns the current mesh
  50912. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50913. */
  50914. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50915. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50916. }
  50917. /**
  50918. * Defines the physics engine scene component responsible to manage a physics engine
  50919. */
  50920. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50921. /**
  50922. * The component name helpful to identify the component in the list of scene components.
  50923. */
  50924. readonly name: string;
  50925. /**
  50926. * The scene the component belongs to.
  50927. */
  50928. scene: Scene;
  50929. /**
  50930. * Creates a new instance of the component for the given scene
  50931. * @param scene Defines the scene to register the component in
  50932. */
  50933. constructor(scene: Scene);
  50934. /**
  50935. * Registers the component in a given scene
  50936. */
  50937. register(): void;
  50938. /**
  50939. * Rebuilds the elements related to this component in case of
  50940. * context lost for instance.
  50941. */
  50942. rebuild(): void;
  50943. /**
  50944. * Disposes the component and the associated ressources
  50945. */
  50946. dispose(): void;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * A helper for physics simulations
  50952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50953. */
  50954. export class PhysicsHelper {
  50955. private _scene;
  50956. private _physicsEngine;
  50957. /**
  50958. * Initializes the Physics helper
  50959. * @param scene Babylon.js scene
  50960. */
  50961. constructor(scene: Scene);
  50962. /**
  50963. * Applies a radial explosion impulse
  50964. * @param origin the origin of the explosion
  50965. * @param radiusOrEventOptions the radius or the options of radial explosion
  50966. * @param strength the explosion strength
  50967. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50968. * @returns A physics radial explosion event, or null
  50969. */
  50970. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50971. /**
  50972. * Applies a radial explosion force
  50973. * @param origin the origin of the explosion
  50974. * @param radiusOrEventOptions the radius or the options of radial explosion
  50975. * @param strength the explosion strength
  50976. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50977. * @returns A physics radial explosion event, or null
  50978. */
  50979. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50980. /**
  50981. * Creates a gravitational field
  50982. * @param origin the origin of the explosion
  50983. * @param radiusOrEventOptions the radius or the options of radial explosion
  50984. * @param strength the explosion strength
  50985. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50986. * @returns A physics gravitational field event, or null
  50987. */
  50988. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50989. /**
  50990. * Creates a physics updraft event
  50991. * @param origin the origin of the updraft
  50992. * @param radiusOrEventOptions the radius or the options of the updraft
  50993. * @param strength the strength of the updraft
  50994. * @param height the height of the updraft
  50995. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50996. * @returns A physics updraft event, or null
  50997. */
  50998. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50999. /**
  51000. * Creates a physics vortex event
  51001. * @param origin the of the vortex
  51002. * @param radiusOrEventOptions the radius or the options of the vortex
  51003. * @param strength the strength of the vortex
  51004. * @param height the height of the vortex
  51005. * @returns a Physics vortex event, or null
  51006. * A physics vortex event or null
  51007. */
  51008. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51009. }
  51010. /**
  51011. * Represents a physics radial explosion event
  51012. */
  51013. class PhysicsRadialExplosionEvent {
  51014. private _scene;
  51015. private _options;
  51016. private _sphere;
  51017. private _dataFetched;
  51018. /**
  51019. * Initializes a radial explosioin event
  51020. * @param _scene BabylonJS scene
  51021. * @param _options The options for the vortex event
  51022. */
  51023. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51024. /**
  51025. * Returns the data related to the radial explosion event (sphere).
  51026. * @returns The radial explosion event data
  51027. */
  51028. getData(): PhysicsRadialExplosionEventData;
  51029. /**
  51030. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51031. * @param impostor A physics imposter
  51032. * @param origin the origin of the explosion
  51033. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51034. */
  51035. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51036. /**
  51037. * Triggers affecterd impostors callbacks
  51038. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51039. */
  51040. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51041. /**
  51042. * Disposes the sphere.
  51043. * @param force Specifies if the sphere should be disposed by force
  51044. */
  51045. dispose(force?: boolean): void;
  51046. /*** Helpers ***/
  51047. private _prepareSphere;
  51048. private _intersectsWithSphere;
  51049. }
  51050. /**
  51051. * Represents a gravitational field event
  51052. */
  51053. class PhysicsGravitationalFieldEvent {
  51054. private _physicsHelper;
  51055. private _scene;
  51056. private _origin;
  51057. private _options;
  51058. private _tickCallback;
  51059. private _sphere;
  51060. private _dataFetched;
  51061. /**
  51062. * Initializes the physics gravitational field event
  51063. * @param _physicsHelper A physics helper
  51064. * @param _scene BabylonJS scene
  51065. * @param _origin The origin position of the gravitational field event
  51066. * @param _options The options for the vortex event
  51067. */
  51068. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51069. /**
  51070. * Returns the data related to the gravitational field event (sphere).
  51071. * @returns A gravitational field event
  51072. */
  51073. getData(): PhysicsGravitationalFieldEventData;
  51074. /**
  51075. * Enables the gravitational field.
  51076. */
  51077. enable(): void;
  51078. /**
  51079. * Disables the gravitational field.
  51080. */
  51081. disable(): void;
  51082. /**
  51083. * Disposes the sphere.
  51084. * @param force The force to dispose from the gravitational field event
  51085. */
  51086. dispose(force?: boolean): void;
  51087. private _tick;
  51088. }
  51089. /**
  51090. * Represents a physics updraft event
  51091. */
  51092. class PhysicsUpdraftEvent {
  51093. private _scene;
  51094. private _origin;
  51095. private _options;
  51096. private _physicsEngine;
  51097. private _originTop;
  51098. private _originDirection;
  51099. private _tickCallback;
  51100. private _cylinder;
  51101. private _cylinderPosition;
  51102. private _dataFetched;
  51103. /**
  51104. * Initializes the physics updraft event
  51105. * @param _scene BabylonJS scene
  51106. * @param _origin The origin position of the updraft
  51107. * @param _options The options for the updraft event
  51108. */
  51109. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51110. /**
  51111. * Returns the data related to the updraft event (cylinder).
  51112. * @returns A physics updraft event
  51113. */
  51114. getData(): PhysicsUpdraftEventData;
  51115. /**
  51116. * Enables the updraft.
  51117. */
  51118. enable(): void;
  51119. /**
  51120. * Disables the updraft.
  51121. */
  51122. disable(): void;
  51123. /**
  51124. * Disposes the cylinder.
  51125. * @param force Specifies if the updraft should be disposed by force
  51126. */
  51127. dispose(force?: boolean): void;
  51128. private getImpostorHitData;
  51129. private _tick;
  51130. /*** Helpers ***/
  51131. private _prepareCylinder;
  51132. private _intersectsWithCylinder;
  51133. }
  51134. /**
  51135. * Represents a physics vortex event
  51136. */
  51137. class PhysicsVortexEvent {
  51138. private _scene;
  51139. private _origin;
  51140. private _options;
  51141. private _physicsEngine;
  51142. private _originTop;
  51143. private _tickCallback;
  51144. private _cylinder;
  51145. private _cylinderPosition;
  51146. private _dataFetched;
  51147. /**
  51148. * Initializes the physics vortex event
  51149. * @param _scene The BabylonJS scene
  51150. * @param _origin The origin position of the vortex
  51151. * @param _options The options for the vortex event
  51152. */
  51153. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51154. /**
  51155. * Returns the data related to the vortex event (cylinder).
  51156. * @returns The physics vortex event data
  51157. */
  51158. getData(): PhysicsVortexEventData;
  51159. /**
  51160. * Enables the vortex.
  51161. */
  51162. enable(): void;
  51163. /**
  51164. * Disables the cortex.
  51165. */
  51166. disable(): void;
  51167. /**
  51168. * Disposes the sphere.
  51169. * @param force
  51170. */
  51171. dispose(force?: boolean): void;
  51172. private getImpostorHitData;
  51173. private _tick;
  51174. /*** Helpers ***/
  51175. private _prepareCylinder;
  51176. private _intersectsWithCylinder;
  51177. }
  51178. /**
  51179. * Options fot the radial explosion event
  51180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51181. */
  51182. export class PhysicsRadialExplosionEventOptions {
  51183. /**
  51184. * The radius of the sphere for the radial explosion.
  51185. */
  51186. radius: number;
  51187. /**
  51188. * The strenth of the explosion.
  51189. */
  51190. strength: number;
  51191. /**
  51192. * The strenght of the force in correspondence to the distance of the affected object
  51193. */
  51194. falloff: PhysicsRadialImpulseFalloff;
  51195. /**
  51196. * Sphere options for the radial explosion.
  51197. */
  51198. sphere: {
  51199. segments: number;
  51200. diameter: number;
  51201. };
  51202. /**
  51203. * Sphere options for the radial explosion.
  51204. */
  51205. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51206. }
  51207. /**
  51208. * Options fot the updraft event
  51209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51210. */
  51211. export class PhysicsUpdraftEventOptions {
  51212. /**
  51213. * The radius of the cylinder for the vortex
  51214. */
  51215. radius: number;
  51216. /**
  51217. * The strenth of the updraft.
  51218. */
  51219. strength: number;
  51220. /**
  51221. * The height of the cylinder for the updraft.
  51222. */
  51223. height: number;
  51224. /**
  51225. * The mode for the the updraft.
  51226. */
  51227. updraftMode: PhysicsUpdraftMode;
  51228. }
  51229. /**
  51230. * Options fot the vortex event
  51231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51232. */
  51233. export class PhysicsVortexEventOptions {
  51234. /**
  51235. * The radius of the cylinder for the vortex
  51236. */
  51237. radius: number;
  51238. /**
  51239. * The strenth of the vortex.
  51240. */
  51241. strength: number;
  51242. /**
  51243. * The height of the cylinder for the vortex.
  51244. */
  51245. height: number;
  51246. /**
  51247. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51248. */
  51249. centripetalForceThreshold: number;
  51250. /**
  51251. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51252. */
  51253. centripetalForceMultiplier: number;
  51254. /**
  51255. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51256. */
  51257. centrifugalForceMultiplier: number;
  51258. /**
  51259. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51260. */
  51261. updraftForceMultiplier: number;
  51262. }
  51263. /**
  51264. * The strenght of the force in correspondence to the distance of the affected object
  51265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51266. */
  51267. export enum PhysicsRadialImpulseFalloff {
  51268. /** Defines that impulse is constant in strength across it's whole radius */
  51269. Constant = 0,
  51270. /** Defines that impulse gets weaker if it's further from the origin */
  51271. Linear = 1
  51272. }
  51273. /**
  51274. * The strength of the force in correspondence to the distance of the affected object
  51275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51276. */
  51277. export enum PhysicsUpdraftMode {
  51278. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51279. Center = 0,
  51280. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51281. Perpendicular = 1
  51282. }
  51283. /**
  51284. * Interface for a physics hit data
  51285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51286. */
  51287. export interface PhysicsHitData {
  51288. /**
  51289. * The force applied at the contact point
  51290. */
  51291. force: Vector3;
  51292. /**
  51293. * The contact point
  51294. */
  51295. contactPoint: Vector3;
  51296. /**
  51297. * The distance from the origin to the contact point
  51298. */
  51299. distanceFromOrigin: number;
  51300. }
  51301. /**
  51302. * Interface for radial explosion event data
  51303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51304. */
  51305. export interface PhysicsRadialExplosionEventData {
  51306. /**
  51307. * A sphere used for the radial explosion event
  51308. */
  51309. sphere: Mesh;
  51310. }
  51311. /**
  51312. * Interface for gravitational field event data
  51313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51314. */
  51315. export interface PhysicsGravitationalFieldEventData {
  51316. /**
  51317. * A sphere mesh used for the gravitational field event
  51318. */
  51319. sphere: Mesh;
  51320. }
  51321. /**
  51322. * Interface for updraft event data
  51323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51324. */
  51325. export interface PhysicsUpdraftEventData {
  51326. /**
  51327. * A cylinder used for the updraft event
  51328. */
  51329. cylinder: Mesh;
  51330. }
  51331. /**
  51332. * Interface for vortex event data
  51333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51334. */
  51335. export interface PhysicsVortexEventData {
  51336. /**
  51337. * A cylinder used for the vortex event
  51338. */
  51339. cylinder: Mesh;
  51340. }
  51341. /**
  51342. * Interface for an affected physics impostor
  51343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51344. */
  51345. export interface PhysicsAffectedImpostorWithData {
  51346. /**
  51347. * The impostor affected by the effect
  51348. */
  51349. impostor: PhysicsImpostor;
  51350. /**
  51351. * The data about the hit/horce from the explosion
  51352. */
  51353. hitData: PhysicsHitData;
  51354. }
  51355. }
  51356. declare module BABYLON {
  51357. /** @hidden */
  51358. export var blackAndWhitePixelShader: {
  51359. name: string;
  51360. shader: string;
  51361. };
  51362. }
  51363. declare module BABYLON {
  51364. /**
  51365. * Post process used to render in black and white
  51366. */
  51367. export class BlackAndWhitePostProcess extends PostProcess {
  51368. /**
  51369. * Linear about to convert he result to black and white (default: 1)
  51370. */
  51371. degree: number;
  51372. /**
  51373. * Creates a black and white post process
  51374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51375. * @param name The name of the effect.
  51376. * @param options The required width/height ratio to downsize to before computing the render pass.
  51377. * @param camera The camera to apply the render pass to.
  51378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51379. * @param engine The engine which the post process will be applied. (default: current engine)
  51380. * @param reusable If the post process can be reused on the same frame. (default: false)
  51381. */
  51382. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51383. }
  51384. }
  51385. declare module BABYLON {
  51386. /**
  51387. * This represents a set of one or more post processes in Babylon.
  51388. * A post process can be used to apply a shader to a texture after it is rendered.
  51389. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51390. */
  51391. export class PostProcessRenderEffect {
  51392. private _postProcesses;
  51393. private _getPostProcesses;
  51394. private _singleInstance;
  51395. private _cameras;
  51396. private _indicesForCamera;
  51397. /**
  51398. * Name of the effect
  51399. * @hidden
  51400. */ name: string;
  51401. /**
  51402. * Instantiates a post process render effect.
  51403. * A post process can be used to apply a shader to a texture after it is rendered.
  51404. * @param engine The engine the effect is tied to
  51405. * @param name The name of the effect
  51406. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51407. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51408. */
  51409. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51410. /**
  51411. * Checks if all the post processes in the effect are supported.
  51412. */
  51413. readonly isSupported: boolean;
  51414. /**
  51415. * Updates the current state of the effect
  51416. * @hidden
  51417. */ update(): void;
  51418. /**
  51419. * Attaches the effect on cameras
  51420. * @param cameras The camera to attach to.
  51421. * @hidden
  51422. */ attachCameras(cameras: Camera): void;
  51423. /**
  51424. * Attaches the effect on cameras
  51425. * @param cameras The camera to attach to.
  51426. * @hidden
  51427. */ attachCameras(cameras: Camera[]): void;
  51428. /**
  51429. * Detaches the effect on cameras
  51430. * @param cameras The camera to detatch from.
  51431. * @hidden
  51432. */ detachCameras(cameras: Camera): void;
  51433. /**
  51434. * Detatches the effect on cameras
  51435. * @param cameras The camera to detatch from.
  51436. * @hidden
  51437. */ detachCameras(cameras: Camera[]): void;
  51438. /**
  51439. * Enables the effect on given cameras
  51440. * @param cameras The camera to enable.
  51441. * @hidden
  51442. */ enable(cameras: Camera): void;
  51443. /**
  51444. * Enables the effect on given cameras
  51445. * @param cameras The camera to enable.
  51446. * @hidden
  51447. */ enable(cameras: Nullable<Camera[]>): void;
  51448. /**
  51449. * Disables the effect on the given cameras
  51450. * @param cameras The camera to disable.
  51451. * @hidden
  51452. */ disable(cameras: Camera): void;
  51453. /**
  51454. * Disables the effect on the given cameras
  51455. * @param cameras The camera to disable.
  51456. * @hidden
  51457. */ disable(cameras: Nullable<Camera[]>): void;
  51458. /**
  51459. * Gets a list of the post processes contained in the effect.
  51460. * @param camera The camera to get the post processes on.
  51461. * @returns The list of the post processes in the effect.
  51462. */
  51463. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51464. }
  51465. }
  51466. declare module BABYLON {
  51467. /** @hidden */
  51468. export var extractHighlightsPixelShader: {
  51469. name: string;
  51470. shader: string;
  51471. };
  51472. }
  51473. declare module BABYLON {
  51474. /**
  51475. * 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.
  51476. */
  51477. export class ExtractHighlightsPostProcess extends PostProcess {
  51478. /**
  51479. * The luminance threshold, pixels below this value will be set to black.
  51480. */
  51481. threshold: number;
  51482. /** @hidden */ exposure: number;
  51483. /**
  51484. * Post process which has the input texture to be used when performing highlight extraction
  51485. * @hidden
  51486. */ inputPostProcess: Nullable<PostProcess>;
  51487. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51488. }
  51489. }
  51490. declare module BABYLON {
  51491. /** @hidden */
  51492. export var bloomMergePixelShader: {
  51493. name: string;
  51494. shader: string;
  51495. };
  51496. }
  51497. declare module BABYLON {
  51498. /**
  51499. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51500. */
  51501. export class BloomMergePostProcess extends PostProcess {
  51502. /** Weight of the bloom to be added to the original input. */
  51503. weight: number;
  51504. /**
  51505. * Creates a new instance of @see BloomMergePostProcess
  51506. * @param name The name of the effect.
  51507. * @param originalFromInput Post process which's input will be used for the merge.
  51508. * @param blurred Blurred highlights post process which's output will be used.
  51509. * @param weight Weight of the bloom to be added to the original input.
  51510. * @param options The required width/height ratio to downsize to before computing the render pass.
  51511. * @param camera The camera to apply the render pass to.
  51512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51513. * @param engine The engine which the post process will be applied. (default: current engine)
  51514. * @param reusable If the post process can be reused on the same frame. (default: false)
  51515. * @param textureType Type of textures used when performing the post process. (default: 0)
  51516. * @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)
  51517. */
  51518. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51519. /** Weight of the bloom to be added to the original input. */
  51520. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51521. }
  51522. }
  51523. declare module BABYLON {
  51524. /**
  51525. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51526. */
  51527. export class BloomEffect extends PostProcessRenderEffect {
  51528. private bloomScale;
  51529. /**
  51530. * @hidden Internal
  51531. */ effects: Array<PostProcess>;
  51532. /**
  51533. * @hidden Internal
  51534. */ downscale: ExtractHighlightsPostProcess;
  51535. private _blurX;
  51536. private _blurY;
  51537. private _merge;
  51538. /**
  51539. * The luminance threshold to find bright areas of the image to bloom.
  51540. */
  51541. threshold: number;
  51542. /**
  51543. * The strength of the bloom.
  51544. */
  51545. weight: number;
  51546. /**
  51547. * Specifies the size of the bloom blur kernel, relative to the final output size
  51548. */
  51549. kernel: number;
  51550. /**
  51551. * Creates a new instance of @see BloomEffect
  51552. * @param scene The scene the effect belongs to.
  51553. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51554. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51555. * @param bloomWeight The the strength of bloom.
  51556. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51557. * @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)
  51558. */
  51559. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51560. /**
  51561. * Disposes each of the internal effects for a given camera.
  51562. * @param camera The camera to dispose the effect on.
  51563. */
  51564. disposeEffects(camera: Camera): void;
  51565. /**
  51566. * @hidden Internal
  51567. */ updateEffects(): void;
  51568. /**
  51569. * Internal
  51570. * @returns if all the contained post processes are ready.
  51571. * @hidden
  51572. */ isReady(): boolean;
  51573. }
  51574. }
  51575. declare module BABYLON {
  51576. /** @hidden */
  51577. export var chromaticAberrationPixelShader: {
  51578. name: string;
  51579. shader: string;
  51580. };
  51581. }
  51582. declare module BABYLON {
  51583. /**
  51584. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51585. */
  51586. export class ChromaticAberrationPostProcess extends PostProcess {
  51587. /**
  51588. * The amount of seperation of rgb channels (default: 30)
  51589. */
  51590. aberrationAmount: number;
  51591. /**
  51592. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51593. */
  51594. radialIntensity: number;
  51595. /**
  51596. * 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))
  51597. */
  51598. direction: Vector2;
  51599. /**
  51600. * 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))
  51601. */
  51602. centerPosition: Vector2;
  51603. /**
  51604. * Creates a new instance ChromaticAberrationPostProcess
  51605. * @param name The name of the effect.
  51606. * @param screenWidth The width of the screen to apply the effect on.
  51607. * @param screenHeight The height of the screen to apply the effect on.
  51608. * @param options The required width/height ratio to downsize to before computing the render pass.
  51609. * @param camera The camera to apply the render pass to.
  51610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51611. * @param engine The engine which the post process will be applied. (default: current engine)
  51612. * @param reusable If the post process can be reused on the same frame. (default: false)
  51613. * @param textureType Type of textures used when performing the post process. (default: 0)
  51614. * @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)
  51615. */
  51616. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51617. }
  51618. }
  51619. declare module BABYLON {
  51620. /** @hidden */
  51621. export var circleOfConfusionPixelShader: {
  51622. name: string;
  51623. shader: string;
  51624. };
  51625. }
  51626. declare module BABYLON {
  51627. /**
  51628. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51629. */
  51630. export class CircleOfConfusionPostProcess extends PostProcess {
  51631. /**
  51632. * 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.
  51633. */
  51634. lensSize: number;
  51635. /**
  51636. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51637. */
  51638. fStop: number;
  51639. /**
  51640. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51641. */
  51642. focusDistance: number;
  51643. /**
  51644. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51645. */
  51646. focalLength: number;
  51647. private _depthTexture;
  51648. /**
  51649. * Creates a new instance CircleOfConfusionPostProcess
  51650. * @param name The name of the effect.
  51651. * @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.
  51652. * @param options The required width/height ratio to downsize to before computing the render pass.
  51653. * @param camera The camera to apply the render pass to.
  51654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51655. * @param engine The engine which the post process will be applied. (default: current engine)
  51656. * @param reusable If the post process can be reused on the same frame. (default: false)
  51657. * @param textureType Type of textures used when performing the post process. (default: 0)
  51658. * @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)
  51659. */
  51660. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51661. /**
  51662. * 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.
  51663. */
  51664. depthTexture: RenderTargetTexture;
  51665. }
  51666. }
  51667. declare module BABYLON {
  51668. /** @hidden */
  51669. export var colorCorrectionPixelShader: {
  51670. name: string;
  51671. shader: string;
  51672. };
  51673. }
  51674. declare module BABYLON {
  51675. /**
  51676. *
  51677. * This post-process allows the modification of rendered colors by using
  51678. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51679. *
  51680. * The object needs to be provided an url to a texture containing the color
  51681. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51682. * Use an image editing software to tweak the LUT to match your needs.
  51683. *
  51684. * For an example of a color LUT, see here:
  51685. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51686. * For explanations on color grading, see here:
  51687. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51688. *
  51689. */
  51690. export class ColorCorrectionPostProcess extends PostProcess {
  51691. private _colorTableTexture;
  51692. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51693. }
  51694. }
  51695. declare module BABYLON {
  51696. /** @hidden */
  51697. export var convolutionPixelShader: {
  51698. name: string;
  51699. shader: string;
  51700. };
  51701. }
  51702. declare module BABYLON {
  51703. /**
  51704. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51705. * input texture to perform effects such as edge detection or sharpening
  51706. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51707. */
  51708. export class ConvolutionPostProcess extends PostProcess {
  51709. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51710. kernel: number[];
  51711. /**
  51712. * Creates a new instance ConvolutionPostProcess
  51713. * @param name The name of the effect.
  51714. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51715. * @param options The required width/height ratio to downsize to before computing the render pass.
  51716. * @param camera The camera to apply the render pass to.
  51717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51718. * @param engine The engine which the post process will be applied. (default: current engine)
  51719. * @param reusable If the post process can be reused on the same frame. (default: false)
  51720. * @param textureType Type of textures used when performing the post process. (default: 0)
  51721. */
  51722. constructor(name: string,
  51723. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51724. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51725. /**
  51726. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51727. */
  51728. static EdgeDetect0Kernel: number[];
  51729. /**
  51730. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51731. */
  51732. static EdgeDetect1Kernel: number[];
  51733. /**
  51734. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51735. */
  51736. static EdgeDetect2Kernel: number[];
  51737. /**
  51738. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51739. */
  51740. static SharpenKernel: number[];
  51741. /**
  51742. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51743. */
  51744. static EmbossKernel: number[];
  51745. /**
  51746. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51747. */
  51748. static GaussianKernel: number[];
  51749. }
  51750. }
  51751. declare module BABYLON {
  51752. /**
  51753. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51754. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51755. * based on samples that have a large difference in distance than the center pixel.
  51756. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51757. */
  51758. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51759. direction: Vector2;
  51760. /**
  51761. * Creates a new instance CircleOfConfusionPostProcess
  51762. * @param name The name of the effect.
  51763. * @param scene The scene the effect belongs to.
  51764. * @param direction The direction the blur should be applied.
  51765. * @param kernel The size of the kernel used to blur.
  51766. * @param options The required width/height ratio to downsize to before computing the render pass.
  51767. * @param camera The camera to apply the render pass to.
  51768. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51769. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51771. * @param engine The engine which the post process will be applied. (default: current engine)
  51772. * @param reusable If the post process can be reused on the same frame. (default: false)
  51773. * @param textureType Type of textures used when performing the post process. (default: 0)
  51774. * @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)
  51775. */
  51776. 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);
  51777. }
  51778. }
  51779. declare module BABYLON {
  51780. /** @hidden */
  51781. export var depthOfFieldMergePixelShader: {
  51782. name: string;
  51783. shader: string;
  51784. };
  51785. }
  51786. declare module BABYLON {
  51787. /**
  51788. * Options to be set when merging outputs from the default pipeline.
  51789. */
  51790. export class DepthOfFieldMergePostProcessOptions {
  51791. /**
  51792. * The original image to merge on top of
  51793. */
  51794. originalFromInput: PostProcess;
  51795. /**
  51796. * Parameters to perform the merge of the depth of field effect
  51797. */
  51798. depthOfField?: {
  51799. circleOfConfusion: PostProcess;
  51800. blurSteps: Array<PostProcess>;
  51801. };
  51802. /**
  51803. * Parameters to perform the merge of bloom effect
  51804. */
  51805. bloom?: {
  51806. blurred: PostProcess;
  51807. weight: number;
  51808. };
  51809. }
  51810. /**
  51811. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51812. */
  51813. export class DepthOfFieldMergePostProcess extends PostProcess {
  51814. private blurSteps;
  51815. /**
  51816. * Creates a new instance of DepthOfFieldMergePostProcess
  51817. * @param name The name of the effect.
  51818. * @param originalFromInput Post process which's input will be used for the merge.
  51819. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51820. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51821. * @param options The required width/height ratio to downsize to before computing the render pass.
  51822. * @param camera The camera to apply the render pass to.
  51823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51824. * @param engine The engine which the post process will be applied. (default: current engine)
  51825. * @param reusable If the post process can be reused on the same frame. (default: false)
  51826. * @param textureType Type of textures used when performing the post process. (default: 0)
  51827. * @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)
  51828. */
  51829. 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);
  51830. /**
  51831. * Updates the effect with the current post process compile time values and recompiles the shader.
  51832. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51833. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51834. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51835. * @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
  51836. * @param onCompiled Called when the shader has been compiled.
  51837. * @param onError Called if there is an error when compiling a shader.
  51838. */
  51839. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51840. }
  51841. }
  51842. declare module BABYLON {
  51843. /**
  51844. * Specifies the level of max blur that should be applied when using the depth of field effect
  51845. */
  51846. export enum DepthOfFieldEffectBlurLevel {
  51847. /**
  51848. * Subtle blur
  51849. */
  51850. Low = 0,
  51851. /**
  51852. * Medium blur
  51853. */
  51854. Medium = 1,
  51855. /**
  51856. * Large blur
  51857. */
  51858. High = 2
  51859. }
  51860. /**
  51861. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51862. */
  51863. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51864. private _circleOfConfusion;
  51865. /**
  51866. * @hidden Internal, blurs from high to low
  51867. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51868. private _depthOfFieldBlurY;
  51869. private _dofMerge;
  51870. /**
  51871. * @hidden Internal post processes in depth of field effect
  51872. */ effects: Array<PostProcess>;
  51873. /**
  51874. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51875. */
  51876. focalLength: number;
  51877. /**
  51878. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51879. */
  51880. fStop: number;
  51881. /**
  51882. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51883. */
  51884. focusDistance: number;
  51885. /**
  51886. * 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.
  51887. */
  51888. lensSize: number;
  51889. /**
  51890. * Creates a new instance DepthOfFieldEffect
  51891. * @param scene The scene the effect belongs to.
  51892. * @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.
  51893. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51894. * @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)
  51895. */
  51896. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51897. /**
  51898. * Get the current class name of the current effet
  51899. * @returns "DepthOfFieldEffect"
  51900. */
  51901. getClassName(): string;
  51902. /**
  51903. * 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.
  51904. */
  51905. depthTexture: RenderTargetTexture;
  51906. /**
  51907. * Disposes each of the internal effects for a given camera.
  51908. * @param camera The camera to dispose the effect on.
  51909. */
  51910. disposeEffects(camera: Camera): void;
  51911. /**
  51912. * @hidden Internal
  51913. */ updateEffects(): void;
  51914. /**
  51915. * Internal
  51916. * @returns if all the contained post processes are ready.
  51917. * @hidden
  51918. */ isReady(): boolean;
  51919. }
  51920. }
  51921. declare module BABYLON {
  51922. /** @hidden */
  51923. export var displayPassPixelShader: {
  51924. name: string;
  51925. shader: string;
  51926. };
  51927. }
  51928. declare module BABYLON {
  51929. /**
  51930. * DisplayPassPostProcess which produces an output the same as it's input
  51931. */
  51932. export class DisplayPassPostProcess extends PostProcess {
  51933. /**
  51934. * Creates the DisplayPassPostProcess
  51935. * @param name The name of the effect.
  51936. * @param options The required width/height ratio to downsize to before computing the render pass.
  51937. * @param camera The camera to apply the render pass to.
  51938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51939. * @param engine The engine which the post process will be applied. (default: current engine)
  51940. * @param reusable If the post process can be reused on the same frame. (default: false)
  51941. */
  51942. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51943. }
  51944. }
  51945. declare module BABYLON {
  51946. /** @hidden */
  51947. export var filterPixelShader: {
  51948. name: string;
  51949. shader: string;
  51950. };
  51951. }
  51952. declare module BABYLON {
  51953. /**
  51954. * Applies a kernel filter to the image
  51955. */
  51956. export class FilterPostProcess extends PostProcess {
  51957. /** The matrix to be applied to the image */
  51958. kernelMatrix: Matrix;
  51959. /**
  51960. *
  51961. * @param name The name of the effect.
  51962. * @param kernelMatrix The matrix to be applied to the image
  51963. * @param options The required width/height ratio to downsize to before computing the render pass.
  51964. * @param camera The camera to apply the render pass to.
  51965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51966. * @param engine The engine which the post process will be applied. (default: current engine)
  51967. * @param reusable If the post process can be reused on the same frame. (default: false)
  51968. */
  51969. constructor(name: string,
  51970. /** The matrix to be applied to the image */
  51971. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51972. }
  51973. }
  51974. declare module BABYLON {
  51975. /** @hidden */
  51976. export var fxaaPixelShader: {
  51977. name: string;
  51978. shader: string;
  51979. };
  51980. }
  51981. declare module BABYLON {
  51982. /** @hidden */
  51983. export var fxaaVertexShader: {
  51984. name: string;
  51985. shader: string;
  51986. };
  51987. }
  51988. declare module BABYLON {
  51989. /**
  51990. * Fxaa post process
  51991. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51992. */
  51993. export class FxaaPostProcess extends PostProcess {
  51994. /** @hidden */
  51995. texelWidth: number;
  51996. /** @hidden */
  51997. texelHeight: number;
  51998. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51999. private _getDefines;
  52000. }
  52001. }
  52002. declare module BABYLON {
  52003. /** @hidden */
  52004. export var grainPixelShader: {
  52005. name: string;
  52006. shader: string;
  52007. };
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * The GrainPostProcess adds noise to the image at mid luminance levels
  52012. */
  52013. export class GrainPostProcess extends PostProcess {
  52014. /**
  52015. * The intensity of the grain added (default: 30)
  52016. */
  52017. intensity: number;
  52018. /**
  52019. * If the grain should be randomized on every frame
  52020. */
  52021. animated: boolean;
  52022. /**
  52023. * Creates a new instance of @see GrainPostProcess
  52024. * @param name The name of the effect.
  52025. * @param options The required width/height ratio to downsize to before computing the render pass.
  52026. * @param camera The camera to apply the render pass to.
  52027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52028. * @param engine The engine which the post process will be applied. (default: current engine)
  52029. * @param reusable If the post process can be reused on the same frame. (default: false)
  52030. * @param textureType Type of textures used when performing the post process. (default: 0)
  52031. * @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)
  52032. */
  52033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52034. }
  52035. }
  52036. declare module BABYLON {
  52037. /** @hidden */
  52038. export var highlightsPixelShader: {
  52039. name: string;
  52040. shader: string;
  52041. };
  52042. }
  52043. declare module BABYLON {
  52044. /**
  52045. * Extracts highlights from the image
  52046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52047. */
  52048. export class HighlightsPostProcess extends PostProcess {
  52049. /**
  52050. * Extracts highlights from the image
  52051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52052. * @param name The name of the effect.
  52053. * @param options The required width/height ratio to downsize to before computing the render pass.
  52054. * @param camera The camera to apply the render pass to.
  52055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52056. * @param engine The engine which the post process will be applied. (default: current engine)
  52057. * @param reusable If the post process can be reused on the same frame. (default: false)
  52058. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52059. */
  52060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52061. }
  52062. }
  52063. declare module BABYLON {
  52064. /** @hidden */
  52065. export var mrtFragmentDeclaration: {
  52066. name: string;
  52067. shader: string;
  52068. };
  52069. }
  52070. declare module BABYLON {
  52071. /** @hidden */
  52072. export var geometryPixelShader: {
  52073. name: string;
  52074. shader: string;
  52075. };
  52076. }
  52077. declare module BABYLON {
  52078. /** @hidden */
  52079. export var geometryVertexShader: {
  52080. name: string;
  52081. shader: string;
  52082. };
  52083. }
  52084. declare module BABYLON {
  52085. /**
  52086. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52087. */
  52088. export class GeometryBufferRenderer {
  52089. /**
  52090. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52091. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52092. */
  52093. static readonly POSITION_TEXTURE_TYPE: number;
  52094. /**
  52095. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52096. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52097. */
  52098. static readonly VELOCITY_TEXTURE_TYPE: number;
  52099. /**
  52100. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52101. * in order to compute objects velocities when enableVelocity is set to "true"
  52102. * @hidden
  52103. */ previousTransformationMatrices: {
  52104. [index: number]: Matrix;
  52105. };
  52106. private _scene;
  52107. private _multiRenderTarget;
  52108. private _ratio;
  52109. private _enablePosition;
  52110. private _enableVelocity;
  52111. private _positionIndex;
  52112. private _velocityIndex;
  52113. protected _effect: Effect;
  52114. protected _cachedDefines: string;
  52115. /**
  52116. * Set the render list (meshes to be rendered) used in the G buffer.
  52117. */
  52118. renderList: Mesh[];
  52119. /**
  52120. * Gets wether or not G buffer are supported by the running hardware.
  52121. * This requires draw buffer supports
  52122. */
  52123. readonly isSupported: boolean;
  52124. /**
  52125. * Returns the index of the given texture type in the G-Buffer textures array
  52126. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52127. * @returns the index of the given texture type in the G-Buffer textures array
  52128. */
  52129. getTextureIndex(textureType: number): number;
  52130. /**
  52131. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52132. */
  52133. /**
  52134. * Sets whether or not objects positions are enabled for the G buffer.
  52135. */
  52136. enablePosition: boolean;
  52137. /**
  52138. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52139. */
  52140. /**
  52141. * Sets wether or not objects velocities are enabled for the G buffer.
  52142. */
  52143. enableVelocity: boolean;
  52144. /**
  52145. * Gets the scene associated with the buffer.
  52146. */
  52147. readonly scene: Scene;
  52148. /**
  52149. * Gets the ratio used by the buffer during its creation.
  52150. * How big is the buffer related to the main canvas.
  52151. */
  52152. readonly ratio: number;
  52153. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52154. /**
  52155. * Creates a new G Buffer for the scene
  52156. * @param scene The scene the buffer belongs to
  52157. * @param ratio How big is the buffer related to the main canvas.
  52158. */
  52159. constructor(scene: Scene, ratio?: number);
  52160. /**
  52161. * Checks wether everything is ready to render a submesh to the G buffer.
  52162. * @param subMesh the submesh to check readiness for
  52163. * @param useInstances is the mesh drawn using instance or not
  52164. * @returns true if ready otherwise false
  52165. */
  52166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52167. /**
  52168. * Gets the current underlying G Buffer.
  52169. * @returns the buffer
  52170. */
  52171. getGBuffer(): MultiRenderTarget;
  52172. /**
  52173. * Gets the number of samples used to render the buffer (anti aliasing).
  52174. */
  52175. /**
  52176. * Sets the number of samples used to render the buffer (anti aliasing).
  52177. */
  52178. samples: number;
  52179. /**
  52180. * Disposes the renderer and frees up associated resources.
  52181. */
  52182. dispose(): void;
  52183. protected _createRenderTargets(): void;
  52184. }
  52185. }
  52186. declare module BABYLON {
  52187. interface Scene {
  52188. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52189. /**
  52190. * Gets or Sets the current geometry buffer associated to the scene.
  52191. */
  52192. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52193. /**
  52194. * Enables a GeometryBufferRender and associates it with the scene
  52195. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52196. * @returns the GeometryBufferRenderer
  52197. */
  52198. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52199. /**
  52200. * Disables the GeometryBufferRender associated with the scene
  52201. */
  52202. disableGeometryBufferRenderer(): void;
  52203. }
  52204. /**
  52205. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52206. * in several rendering techniques.
  52207. */
  52208. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52209. /**
  52210. * The component name helpful to identify the component in the list of scene components.
  52211. */
  52212. readonly name: string;
  52213. /**
  52214. * The scene the component belongs to.
  52215. */
  52216. scene: Scene;
  52217. /**
  52218. * Creates a new instance of the component for the given scene
  52219. * @param scene Defines the scene to register the component in
  52220. */
  52221. constructor(scene: Scene);
  52222. /**
  52223. * Registers the component in a given scene
  52224. */
  52225. register(): void;
  52226. /**
  52227. * Rebuilds the elements related to this component in case of
  52228. * context lost for instance.
  52229. */
  52230. rebuild(): void;
  52231. /**
  52232. * Disposes the component and the associated ressources
  52233. */
  52234. dispose(): void;
  52235. private _gatherRenderTargets;
  52236. }
  52237. }
  52238. declare module BABYLON {
  52239. /** @hidden */
  52240. export var motionBlurPixelShader: {
  52241. name: string;
  52242. shader: string;
  52243. };
  52244. }
  52245. declare module BABYLON {
  52246. /**
  52247. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52248. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52249. * As an example, all you have to do is to create the post-process:
  52250. * var mb = new BABYLON.MotionBlurPostProcess(
  52251. * 'mb', // The name of the effect.
  52252. * scene, // The scene containing the objects to blur according to their velocity.
  52253. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52254. * camera // The camera to apply the render pass to.
  52255. * );
  52256. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52257. */
  52258. export class MotionBlurPostProcess extends PostProcess {
  52259. /**
  52260. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52261. */
  52262. motionStrength: number;
  52263. /**
  52264. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52265. */
  52266. /**
  52267. * Sets the number of iterations to be used for motion blur quality
  52268. */
  52269. motionBlurSamples: number;
  52270. private _motionBlurSamples;
  52271. private _geometryBufferRenderer;
  52272. /**
  52273. * Creates a new instance MotionBlurPostProcess
  52274. * @param name The name of the effect.
  52275. * @param scene The scene containing the objects to blur according to their velocity.
  52276. * @param options The required width/height ratio to downsize to before computing the render pass.
  52277. * @param camera The camera to apply the render pass to.
  52278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52279. * @param engine The engine which the post process will be applied. (default: current engine)
  52280. * @param reusable If the post process can be reused on the same frame. (default: false)
  52281. * @param textureType Type of textures used when performing the post process. (default: 0)
  52282. * @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)
  52283. */
  52284. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52285. /**
  52286. * Disposes the post process.
  52287. * @param camera The camera to dispose the post process on.
  52288. */
  52289. dispose(camera?: Camera): void;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /** @hidden */
  52294. export var refractionPixelShader: {
  52295. name: string;
  52296. shader: string;
  52297. };
  52298. }
  52299. declare module BABYLON {
  52300. /**
  52301. * Post process which applies a refractin texture
  52302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52303. */
  52304. export class RefractionPostProcess extends PostProcess {
  52305. /** the base color of the refraction (used to taint the rendering) */
  52306. color: Color3;
  52307. /** simulated refraction depth */
  52308. depth: number;
  52309. /** the coefficient of the base color (0 to remove base color tainting) */
  52310. colorLevel: number;
  52311. private _refTexture;
  52312. private _ownRefractionTexture;
  52313. /**
  52314. * Gets or sets the refraction texture
  52315. * Please note that you are responsible for disposing the texture if you set it manually
  52316. */
  52317. refractionTexture: Texture;
  52318. /**
  52319. * Initializes the RefractionPostProcess
  52320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52321. * @param name The name of the effect.
  52322. * @param refractionTextureUrl Url of the refraction texture to use
  52323. * @param color the base color of the refraction (used to taint the rendering)
  52324. * @param depth simulated refraction depth
  52325. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52326. * @param camera The camera to apply the render pass to.
  52327. * @param options The required width/height ratio to downsize to before computing the render pass.
  52328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52329. * @param engine The engine which the post process will be applied. (default: current engine)
  52330. * @param reusable If the post process can be reused on the same frame. (default: false)
  52331. */
  52332. constructor(name: string, refractionTextureUrl: string,
  52333. /** the base color of the refraction (used to taint the rendering) */
  52334. color: Color3,
  52335. /** simulated refraction depth */
  52336. depth: number,
  52337. /** the coefficient of the base color (0 to remove base color tainting) */
  52338. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52339. /**
  52340. * Disposes of the post process
  52341. * @param camera Camera to dispose post process on
  52342. */
  52343. dispose(camera: Camera): void;
  52344. }
  52345. }
  52346. declare module BABYLON {
  52347. /** @hidden */
  52348. export var sharpenPixelShader: {
  52349. name: string;
  52350. shader: string;
  52351. };
  52352. }
  52353. declare module BABYLON {
  52354. /**
  52355. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52356. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52357. */
  52358. export class SharpenPostProcess extends PostProcess {
  52359. /**
  52360. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52361. */
  52362. colorAmount: number;
  52363. /**
  52364. * How much sharpness should be applied (default: 0.3)
  52365. */
  52366. edgeAmount: number;
  52367. /**
  52368. * Creates a new instance ConvolutionPostProcess
  52369. * @param name The name of the effect.
  52370. * @param options The required width/height ratio to downsize to before computing the render pass.
  52371. * @param camera The camera to apply the render pass to.
  52372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52373. * @param engine The engine which the post process will be applied. (default: current engine)
  52374. * @param reusable If the post process can be reused on the same frame. (default: false)
  52375. * @param textureType Type of textures used when performing the post process. (default: 0)
  52376. * @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)
  52377. */
  52378. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52379. }
  52380. }
  52381. declare module BABYLON {
  52382. /**
  52383. * PostProcessRenderPipeline
  52384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52385. */
  52386. export class PostProcessRenderPipeline {
  52387. private engine;
  52388. private _renderEffects;
  52389. private _renderEffectsForIsolatedPass;
  52390. /**
  52391. * List of inspectable custom properties (used by the Inspector)
  52392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52393. */
  52394. inspectableCustomProperties: IInspectable[];
  52395. /**
  52396. * @hidden
  52397. */
  52398. protected _cameras: Camera[];
  52399. /** @hidden */ name: string;
  52400. /**
  52401. * Gets pipeline name
  52402. */
  52403. readonly name: string;
  52404. /**
  52405. * Initializes a PostProcessRenderPipeline
  52406. * @param engine engine to add the pipeline to
  52407. * @param name name of the pipeline
  52408. */
  52409. constructor(engine: Engine, name: string);
  52410. /**
  52411. * Gets the class name
  52412. * @returns "PostProcessRenderPipeline"
  52413. */
  52414. getClassName(): string;
  52415. /**
  52416. * If all the render effects in the pipeline are supported
  52417. */
  52418. readonly isSupported: boolean;
  52419. /**
  52420. * Adds an effect to the pipeline
  52421. * @param renderEffect the effect to add
  52422. */
  52423. addEffect(renderEffect: PostProcessRenderEffect): void;
  52424. /** @hidden */ rebuild(): void;
  52425. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52426. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52427. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52428. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52429. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52430. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52431. /** @hidden */ detachCameras(cameras: Camera): void;
  52432. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52433. /** @hidden */ update(): void;
  52434. /** @hidden */ reset(): void;
  52435. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52436. /**
  52437. * Disposes of the pipeline
  52438. */
  52439. dispose(): void;
  52440. }
  52441. }
  52442. declare module BABYLON {
  52443. /**
  52444. * PostProcessRenderPipelineManager class
  52445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52446. */
  52447. export class PostProcessRenderPipelineManager {
  52448. private _renderPipelines;
  52449. /**
  52450. * Initializes a PostProcessRenderPipelineManager
  52451. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52452. */
  52453. constructor();
  52454. /**
  52455. * Gets the list of supported render pipelines
  52456. */
  52457. readonly supportedPipelines: PostProcessRenderPipeline[];
  52458. /**
  52459. * Adds a pipeline to the manager
  52460. * @param renderPipeline The pipeline to add
  52461. */
  52462. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52463. /**
  52464. * Attaches a camera to the pipeline
  52465. * @param renderPipelineName The name of the pipeline to attach to
  52466. * @param cameras the camera to attach
  52467. * @param unique if the camera can be attached multiple times to the pipeline
  52468. */
  52469. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52470. /**
  52471. * Detaches a camera from the pipeline
  52472. * @param renderPipelineName The name of the pipeline to detach from
  52473. * @param cameras the camera to detach
  52474. */
  52475. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52476. /**
  52477. * Enables an effect by name on a pipeline
  52478. * @param renderPipelineName the name of the pipeline to enable the effect in
  52479. * @param renderEffectName the name of the effect to enable
  52480. * @param cameras the cameras that the effect should be enabled on
  52481. */
  52482. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52483. /**
  52484. * Disables an effect by name on a pipeline
  52485. * @param renderPipelineName the name of the pipeline to disable the effect in
  52486. * @param renderEffectName the name of the effect to disable
  52487. * @param cameras the cameras that the effect should be disabled on
  52488. */
  52489. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52490. /**
  52491. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52492. */
  52493. update(): void;
  52494. /** @hidden */ rebuild(): void;
  52495. /**
  52496. * Disposes of the manager and pipelines
  52497. */
  52498. dispose(): void;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. interface Scene {
  52503. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52504. /**
  52505. * Gets the postprocess render pipeline manager
  52506. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52507. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52508. */
  52509. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52510. }
  52511. /**
  52512. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52513. */
  52514. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52515. /**
  52516. * The component name helpfull to identify the component in the list of scene components.
  52517. */
  52518. readonly name: string;
  52519. /**
  52520. * The scene the component belongs to.
  52521. */
  52522. scene: Scene;
  52523. /**
  52524. * Creates a new instance of the component for the given scene
  52525. * @param scene Defines the scene to register the component in
  52526. */
  52527. constructor(scene: Scene);
  52528. /**
  52529. * Registers the component in a given scene
  52530. */
  52531. register(): void;
  52532. /**
  52533. * Rebuilds the elements related to this component in case of
  52534. * context lost for instance.
  52535. */
  52536. rebuild(): void;
  52537. /**
  52538. * Disposes the component and the associated ressources
  52539. */
  52540. dispose(): void;
  52541. private _gatherRenderTargets;
  52542. }
  52543. }
  52544. declare module BABYLON {
  52545. /**
  52546. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52547. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52548. */
  52549. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52550. private _scene;
  52551. private _camerasToBeAttached;
  52552. /**
  52553. * ID of the sharpen post process,
  52554. */
  52555. private readonly SharpenPostProcessId;
  52556. /**
  52557. * @ignore
  52558. * ID of the image processing post process;
  52559. */
  52560. readonly ImageProcessingPostProcessId: string;
  52561. /**
  52562. * @ignore
  52563. * ID of the Fast Approximate Anti-Aliasing post process;
  52564. */
  52565. readonly FxaaPostProcessId: string;
  52566. /**
  52567. * ID of the chromatic aberration post process,
  52568. */
  52569. private readonly ChromaticAberrationPostProcessId;
  52570. /**
  52571. * ID of the grain post process
  52572. */
  52573. private readonly GrainPostProcessId;
  52574. /**
  52575. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52576. */
  52577. sharpen: SharpenPostProcess;
  52578. private _sharpenEffect;
  52579. private bloom;
  52580. /**
  52581. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52582. */
  52583. depthOfField: DepthOfFieldEffect;
  52584. /**
  52585. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52586. */
  52587. fxaa: FxaaPostProcess;
  52588. /**
  52589. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52590. */
  52591. imageProcessing: ImageProcessingPostProcess;
  52592. /**
  52593. * Chromatic aberration post process which will shift rgb colors in the image
  52594. */
  52595. chromaticAberration: ChromaticAberrationPostProcess;
  52596. private _chromaticAberrationEffect;
  52597. /**
  52598. * Grain post process which add noise to the image
  52599. */
  52600. grain: GrainPostProcess;
  52601. private _grainEffect;
  52602. /**
  52603. * Glow post process which adds a glow to emissive areas of the image
  52604. */
  52605. private _glowLayer;
  52606. /**
  52607. * Animations which can be used to tweak settings over a period of time
  52608. */
  52609. animations: Animation[];
  52610. private _imageProcessingConfigurationObserver;
  52611. private _sharpenEnabled;
  52612. private _bloomEnabled;
  52613. private _depthOfFieldEnabled;
  52614. private _depthOfFieldBlurLevel;
  52615. private _fxaaEnabled;
  52616. private _imageProcessingEnabled;
  52617. private _defaultPipelineTextureType;
  52618. private _bloomScale;
  52619. private _chromaticAberrationEnabled;
  52620. private _grainEnabled;
  52621. private _buildAllowed;
  52622. /**
  52623. * Gets active scene
  52624. */
  52625. readonly scene: Scene;
  52626. /**
  52627. * Enable or disable the sharpen process from the pipeline
  52628. */
  52629. sharpenEnabled: boolean;
  52630. private _resizeObserver;
  52631. private _hardwareScaleLevel;
  52632. private _bloomKernel;
  52633. /**
  52634. * Specifies the size of the bloom blur kernel, relative to the final output size
  52635. */
  52636. bloomKernel: number;
  52637. /**
  52638. * Specifies the weight of the bloom in the final rendering
  52639. */
  52640. private _bloomWeight;
  52641. /**
  52642. * Specifies the luma threshold for the area that will be blurred by the bloom
  52643. */
  52644. private _bloomThreshold;
  52645. private _hdr;
  52646. /**
  52647. * The strength of the bloom.
  52648. */
  52649. bloomWeight: number;
  52650. /**
  52651. * The strength of the bloom.
  52652. */
  52653. bloomThreshold: number;
  52654. /**
  52655. * The scale of the bloom, lower value will provide better performance.
  52656. */
  52657. bloomScale: number;
  52658. /**
  52659. * Enable or disable the bloom from the pipeline
  52660. */
  52661. bloomEnabled: boolean;
  52662. private _rebuildBloom;
  52663. /**
  52664. * If the depth of field is enabled.
  52665. */
  52666. depthOfFieldEnabled: boolean;
  52667. /**
  52668. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52669. */
  52670. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52671. /**
  52672. * If the anti aliasing is enabled.
  52673. */
  52674. fxaaEnabled: boolean;
  52675. private _samples;
  52676. /**
  52677. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52678. */
  52679. samples: number;
  52680. /**
  52681. * If image processing is enabled.
  52682. */
  52683. imageProcessingEnabled: boolean;
  52684. /**
  52685. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52686. */
  52687. glowLayerEnabled: boolean;
  52688. /**
  52689. * Enable or disable the chromaticAberration process from the pipeline
  52690. */
  52691. chromaticAberrationEnabled: boolean;
  52692. /**
  52693. * Enable or disable the grain process from the pipeline
  52694. */
  52695. grainEnabled: boolean;
  52696. /**
  52697. * @constructor
  52698. * @param name - The rendering pipeline name (default: "")
  52699. * @param hdr - If high dynamic range textures should be used (default: true)
  52700. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52701. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52702. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52703. */
  52704. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52705. /**
  52706. * Get the class name
  52707. * @returns "DefaultRenderingPipeline"
  52708. */
  52709. getClassName(): string;
  52710. /**
  52711. * Force the compilation of the entire pipeline.
  52712. */
  52713. prepare(): void;
  52714. private _hasCleared;
  52715. private _prevPostProcess;
  52716. private _prevPrevPostProcess;
  52717. private _setAutoClearAndTextureSharing;
  52718. private _depthOfFieldSceneObserver;
  52719. private _buildPipeline;
  52720. private _disposePostProcesses;
  52721. /**
  52722. * Adds a camera to the pipeline
  52723. * @param camera the camera to be added
  52724. */
  52725. addCamera(camera: Camera): void;
  52726. /**
  52727. * Removes a camera from the pipeline
  52728. * @param camera the camera to remove
  52729. */
  52730. removeCamera(camera: Camera): void;
  52731. /**
  52732. * Dispose of the pipeline and stop all post processes
  52733. */
  52734. dispose(): void;
  52735. /**
  52736. * Serialize the rendering pipeline (Used when exporting)
  52737. * @returns the serialized object
  52738. */
  52739. serialize(): any;
  52740. /**
  52741. * Parse the serialized pipeline
  52742. * @param source Source pipeline.
  52743. * @param scene The scene to load the pipeline to.
  52744. * @param rootUrl The URL of the serialized pipeline.
  52745. * @returns An instantiated pipeline from the serialized object.
  52746. */
  52747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52748. }
  52749. }
  52750. declare module BABYLON {
  52751. /** @hidden */
  52752. export var lensHighlightsPixelShader: {
  52753. name: string;
  52754. shader: string;
  52755. };
  52756. }
  52757. declare module BABYLON {
  52758. /** @hidden */
  52759. export var depthOfFieldPixelShader: {
  52760. name: string;
  52761. shader: string;
  52762. };
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * BABYLON.JS Chromatic Aberration GLSL Shader
  52767. * Author: Olivier Guyot
  52768. * Separates very slightly R, G and B colors on the edges of the screen
  52769. * Inspired by Francois Tarlier & Martins Upitis
  52770. */
  52771. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52772. /**
  52773. * @ignore
  52774. * The chromatic aberration PostProcess id in the pipeline
  52775. */
  52776. LensChromaticAberrationEffect: string;
  52777. /**
  52778. * @ignore
  52779. * The highlights enhancing PostProcess id in the pipeline
  52780. */
  52781. HighlightsEnhancingEffect: string;
  52782. /**
  52783. * @ignore
  52784. * The depth-of-field PostProcess id in the pipeline
  52785. */
  52786. LensDepthOfFieldEffect: string;
  52787. private _scene;
  52788. private _depthTexture;
  52789. private _grainTexture;
  52790. private _chromaticAberrationPostProcess;
  52791. private _highlightsPostProcess;
  52792. private _depthOfFieldPostProcess;
  52793. private _edgeBlur;
  52794. private _grainAmount;
  52795. private _chromaticAberration;
  52796. private _distortion;
  52797. private _highlightsGain;
  52798. private _highlightsThreshold;
  52799. private _dofDistance;
  52800. private _dofAperture;
  52801. private _dofDarken;
  52802. private _dofPentagon;
  52803. private _blurNoise;
  52804. /**
  52805. * @constructor
  52806. *
  52807. * Effect parameters are as follow:
  52808. * {
  52809. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52810. * edge_blur: number; // from 0 to x (1 for realism)
  52811. * distortion: number; // from 0 to x (1 for realism)
  52812. * grain_amount: number; // from 0 to 1
  52813. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52814. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52815. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52816. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52817. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52818. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52819. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52820. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52821. * }
  52822. * Note: if an effect parameter is unset, effect is disabled
  52823. *
  52824. * @param name The rendering pipeline name
  52825. * @param parameters - An object containing all parameters (see above)
  52826. * @param scene The scene linked to this pipeline
  52827. * @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)
  52828. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52829. */
  52830. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52831. /**
  52832. * Get the class name
  52833. * @returns "LensRenderingPipeline"
  52834. */
  52835. getClassName(): string;
  52836. /**
  52837. * Gets associated scene
  52838. */
  52839. readonly scene: Scene;
  52840. /**
  52841. * Gets or sets the edge blur
  52842. */
  52843. edgeBlur: number;
  52844. /**
  52845. * Gets or sets the grain amount
  52846. */
  52847. grainAmount: number;
  52848. /**
  52849. * Gets or sets the chromatic aberration amount
  52850. */
  52851. chromaticAberration: number;
  52852. /**
  52853. * Gets or sets the depth of field aperture
  52854. */
  52855. dofAperture: number;
  52856. /**
  52857. * Gets or sets the edge distortion
  52858. */
  52859. edgeDistortion: number;
  52860. /**
  52861. * Gets or sets the depth of field distortion
  52862. */
  52863. dofDistortion: number;
  52864. /**
  52865. * Gets or sets the darken out of focus amount
  52866. */
  52867. darkenOutOfFocus: number;
  52868. /**
  52869. * Gets or sets a boolean indicating if blur noise is enabled
  52870. */
  52871. blurNoise: boolean;
  52872. /**
  52873. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52874. */
  52875. pentagonBokeh: boolean;
  52876. /**
  52877. * Gets or sets the highlight grain amount
  52878. */
  52879. highlightsGain: number;
  52880. /**
  52881. * Gets or sets the highlight threshold
  52882. */
  52883. highlightsThreshold: number;
  52884. /**
  52885. * Sets the amount of blur at the edges
  52886. * @param amount blur amount
  52887. */
  52888. setEdgeBlur(amount: number): void;
  52889. /**
  52890. * Sets edge blur to 0
  52891. */
  52892. disableEdgeBlur(): void;
  52893. /**
  52894. * Sets the amout of grain
  52895. * @param amount Amount of grain
  52896. */
  52897. setGrainAmount(amount: number): void;
  52898. /**
  52899. * Set grain amount to 0
  52900. */
  52901. disableGrain(): void;
  52902. /**
  52903. * Sets the chromatic aberration amount
  52904. * @param amount amount of chromatic aberration
  52905. */
  52906. setChromaticAberration(amount: number): void;
  52907. /**
  52908. * Sets chromatic aberration amount to 0
  52909. */
  52910. disableChromaticAberration(): void;
  52911. /**
  52912. * Sets the EdgeDistortion amount
  52913. * @param amount amount of EdgeDistortion
  52914. */
  52915. setEdgeDistortion(amount: number): void;
  52916. /**
  52917. * Sets edge distortion to 0
  52918. */
  52919. disableEdgeDistortion(): void;
  52920. /**
  52921. * Sets the FocusDistance amount
  52922. * @param amount amount of FocusDistance
  52923. */
  52924. setFocusDistance(amount: number): void;
  52925. /**
  52926. * Disables depth of field
  52927. */
  52928. disableDepthOfField(): void;
  52929. /**
  52930. * Sets the Aperture amount
  52931. * @param amount amount of Aperture
  52932. */
  52933. setAperture(amount: number): void;
  52934. /**
  52935. * Sets the DarkenOutOfFocus amount
  52936. * @param amount amount of DarkenOutOfFocus
  52937. */
  52938. setDarkenOutOfFocus(amount: number): void;
  52939. private _pentagonBokehIsEnabled;
  52940. /**
  52941. * Creates a pentagon bokeh effect
  52942. */
  52943. enablePentagonBokeh(): void;
  52944. /**
  52945. * Disables the pentagon bokeh effect
  52946. */
  52947. disablePentagonBokeh(): void;
  52948. /**
  52949. * Enables noise blur
  52950. */
  52951. enableNoiseBlur(): void;
  52952. /**
  52953. * Disables noise blur
  52954. */
  52955. disableNoiseBlur(): void;
  52956. /**
  52957. * Sets the HighlightsGain amount
  52958. * @param amount amount of HighlightsGain
  52959. */
  52960. setHighlightsGain(amount: number): void;
  52961. /**
  52962. * Sets the HighlightsThreshold amount
  52963. * @param amount amount of HighlightsThreshold
  52964. */
  52965. setHighlightsThreshold(amount: number): void;
  52966. /**
  52967. * Disables highlights
  52968. */
  52969. disableHighlights(): void;
  52970. /**
  52971. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52972. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52973. */
  52974. dispose(disableDepthRender?: boolean): void;
  52975. private _createChromaticAberrationPostProcess;
  52976. private _createHighlightsPostProcess;
  52977. private _createDepthOfFieldPostProcess;
  52978. private _createGrainTexture;
  52979. }
  52980. }
  52981. declare module BABYLON {
  52982. /** @hidden */
  52983. export var ssao2PixelShader: {
  52984. name: string;
  52985. shader: string;
  52986. };
  52987. }
  52988. declare module BABYLON {
  52989. /** @hidden */
  52990. export var ssaoCombinePixelShader: {
  52991. name: string;
  52992. shader: string;
  52993. };
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * Render pipeline to produce ssao effect
  52998. */
  52999. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53000. /**
  53001. * @ignore
  53002. * The PassPostProcess id in the pipeline that contains the original scene color
  53003. */
  53004. SSAOOriginalSceneColorEffect: string;
  53005. /**
  53006. * @ignore
  53007. * The SSAO PostProcess id in the pipeline
  53008. */
  53009. SSAORenderEffect: string;
  53010. /**
  53011. * @ignore
  53012. * The horizontal blur PostProcess id in the pipeline
  53013. */
  53014. SSAOBlurHRenderEffect: string;
  53015. /**
  53016. * @ignore
  53017. * The vertical blur PostProcess id in the pipeline
  53018. */
  53019. SSAOBlurVRenderEffect: string;
  53020. /**
  53021. * @ignore
  53022. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53023. */
  53024. SSAOCombineRenderEffect: string;
  53025. /**
  53026. * The output strength of the SSAO post-process. Default value is 1.0.
  53027. */
  53028. totalStrength: number;
  53029. /**
  53030. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53031. */
  53032. maxZ: number;
  53033. /**
  53034. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53035. */
  53036. minZAspect: number;
  53037. private _samples;
  53038. /**
  53039. * Number of samples used for the SSAO calculations. Default value is 8
  53040. */
  53041. samples: number;
  53042. private _textureSamples;
  53043. /**
  53044. * Number of samples to use for antialiasing
  53045. */
  53046. textureSamples: number;
  53047. /**
  53048. * Ratio object used for SSAO ratio and blur ratio
  53049. */
  53050. private _ratio;
  53051. /**
  53052. * Dynamically generated sphere sampler.
  53053. */
  53054. private _sampleSphere;
  53055. /**
  53056. * Blur filter offsets
  53057. */
  53058. private _samplerOffsets;
  53059. private _expensiveBlur;
  53060. /**
  53061. * If bilateral blur should be used
  53062. */
  53063. expensiveBlur: boolean;
  53064. /**
  53065. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53066. */
  53067. radius: number;
  53068. /**
  53069. * The base color of the SSAO post-process
  53070. * The final result is "base + ssao" between [0, 1]
  53071. */
  53072. base: number;
  53073. /**
  53074. * Support test.
  53075. */
  53076. static readonly IsSupported: boolean;
  53077. private _scene;
  53078. private _depthTexture;
  53079. private _normalTexture;
  53080. private _randomTexture;
  53081. private _originalColorPostProcess;
  53082. private _ssaoPostProcess;
  53083. private _blurHPostProcess;
  53084. private _blurVPostProcess;
  53085. private _ssaoCombinePostProcess;
  53086. private _firstUpdate;
  53087. /**
  53088. * Gets active scene
  53089. */
  53090. readonly scene: Scene;
  53091. /**
  53092. * @constructor
  53093. * @param name The rendering pipeline name
  53094. * @param scene The scene linked to this pipeline
  53095. * @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 }
  53096. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53097. */
  53098. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53099. /**
  53100. * Get the class name
  53101. * @returns "SSAO2RenderingPipeline"
  53102. */
  53103. getClassName(): string;
  53104. /**
  53105. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53106. */
  53107. dispose(disableGeometryBufferRenderer?: boolean): void;
  53108. private _createBlurPostProcess;
  53109. /** @hidden */ rebuild(): void;
  53110. private _bits;
  53111. private _radicalInverse_VdC;
  53112. private _hammersley;
  53113. private _hemisphereSample_uniform;
  53114. private _generateHemisphere;
  53115. private _createSSAOPostProcess;
  53116. private _createSSAOCombinePostProcess;
  53117. private _createRandomTexture;
  53118. /**
  53119. * Serialize the rendering pipeline (Used when exporting)
  53120. * @returns the serialized object
  53121. */
  53122. serialize(): any;
  53123. /**
  53124. * Parse the serialized pipeline
  53125. * @param source Source pipeline.
  53126. * @param scene The scene to load the pipeline to.
  53127. * @param rootUrl The URL of the serialized pipeline.
  53128. * @returns An instantiated pipeline from the serialized object.
  53129. */
  53130. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53131. }
  53132. }
  53133. declare module BABYLON {
  53134. /** @hidden */
  53135. export var ssaoPixelShader: {
  53136. name: string;
  53137. shader: string;
  53138. };
  53139. }
  53140. declare module BABYLON {
  53141. /**
  53142. * Render pipeline to produce ssao effect
  53143. */
  53144. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53145. /**
  53146. * @ignore
  53147. * The PassPostProcess id in the pipeline that contains the original scene color
  53148. */
  53149. SSAOOriginalSceneColorEffect: string;
  53150. /**
  53151. * @ignore
  53152. * The SSAO PostProcess id in the pipeline
  53153. */
  53154. SSAORenderEffect: string;
  53155. /**
  53156. * @ignore
  53157. * The horizontal blur PostProcess id in the pipeline
  53158. */
  53159. SSAOBlurHRenderEffect: string;
  53160. /**
  53161. * @ignore
  53162. * The vertical blur PostProcess id in the pipeline
  53163. */
  53164. SSAOBlurVRenderEffect: string;
  53165. /**
  53166. * @ignore
  53167. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53168. */
  53169. SSAOCombineRenderEffect: string;
  53170. /**
  53171. * The output strength of the SSAO post-process. Default value is 1.0.
  53172. */
  53173. totalStrength: number;
  53174. /**
  53175. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53176. */
  53177. radius: number;
  53178. /**
  53179. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53180. * Must not be equal to fallOff and superior to fallOff.
  53181. * Default value is 0.0075
  53182. */
  53183. area: number;
  53184. /**
  53185. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53186. * Must not be equal to area and inferior to area.
  53187. * Default value is 0.000001
  53188. */
  53189. fallOff: number;
  53190. /**
  53191. * The base color of the SSAO post-process
  53192. * The final result is "base + ssao" between [0, 1]
  53193. */
  53194. base: number;
  53195. private _scene;
  53196. private _depthTexture;
  53197. private _randomTexture;
  53198. private _originalColorPostProcess;
  53199. private _ssaoPostProcess;
  53200. private _blurHPostProcess;
  53201. private _blurVPostProcess;
  53202. private _ssaoCombinePostProcess;
  53203. private _firstUpdate;
  53204. /**
  53205. * Gets active scene
  53206. */
  53207. readonly scene: Scene;
  53208. /**
  53209. * @constructor
  53210. * @param name - The rendering pipeline name
  53211. * @param scene - The scene linked to this pipeline
  53212. * @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 }
  53213. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53214. */
  53215. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53216. /**
  53217. * Get the class name
  53218. * @returns "SSAORenderingPipeline"
  53219. */
  53220. getClassName(): string;
  53221. /**
  53222. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53223. */
  53224. dispose(disableDepthRender?: boolean): void;
  53225. private _createBlurPostProcess;
  53226. /** @hidden */ rebuild(): void;
  53227. private _createSSAOPostProcess;
  53228. private _createSSAOCombinePostProcess;
  53229. private _createRandomTexture;
  53230. }
  53231. }
  53232. declare module BABYLON {
  53233. /** @hidden */
  53234. export var standardPixelShader: {
  53235. name: string;
  53236. shader: string;
  53237. };
  53238. }
  53239. declare module BABYLON {
  53240. /**
  53241. * Standard rendering pipeline
  53242. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53243. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53244. */
  53245. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53246. /**
  53247. * Public members
  53248. */
  53249. /**
  53250. * Post-process which contains the original scene color before the pipeline applies all the effects
  53251. */
  53252. originalPostProcess: Nullable<PostProcess>;
  53253. /**
  53254. * Post-process used to down scale an image x4
  53255. */
  53256. downSampleX4PostProcess: Nullable<PostProcess>;
  53257. /**
  53258. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53259. */
  53260. brightPassPostProcess: Nullable<PostProcess>;
  53261. /**
  53262. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53263. */
  53264. blurHPostProcesses: PostProcess[];
  53265. /**
  53266. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53267. */
  53268. blurVPostProcesses: PostProcess[];
  53269. /**
  53270. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53271. */
  53272. textureAdderPostProcess: Nullable<PostProcess>;
  53273. /**
  53274. * Post-process used to create volumetric lighting effect
  53275. */
  53276. volumetricLightPostProcess: Nullable<PostProcess>;
  53277. /**
  53278. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53279. */
  53280. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53281. /**
  53282. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53283. */
  53284. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53285. /**
  53286. * Post-process used to merge the volumetric light effect and the real scene color
  53287. */
  53288. volumetricLightMergePostProces: Nullable<PostProcess>;
  53289. /**
  53290. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53291. */
  53292. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53293. /**
  53294. * Base post-process used to calculate the average luminance of the final image for HDR
  53295. */
  53296. luminancePostProcess: Nullable<PostProcess>;
  53297. /**
  53298. * Post-processes used to create down sample post-processes in order to get
  53299. * the average luminance of the final image for HDR
  53300. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53301. */
  53302. luminanceDownSamplePostProcesses: PostProcess[];
  53303. /**
  53304. * Post-process used to create a HDR effect (light adaptation)
  53305. */
  53306. hdrPostProcess: Nullable<PostProcess>;
  53307. /**
  53308. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53309. */
  53310. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53311. /**
  53312. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53313. */
  53314. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53315. /**
  53316. * Post-process used to merge the final HDR post-process and the real scene color
  53317. */
  53318. hdrFinalPostProcess: Nullable<PostProcess>;
  53319. /**
  53320. * Post-process used to create a lens flare effect
  53321. */
  53322. lensFlarePostProcess: Nullable<PostProcess>;
  53323. /**
  53324. * Post-process that merges the result of the lens flare post-process and the real scene color
  53325. */
  53326. lensFlareComposePostProcess: Nullable<PostProcess>;
  53327. /**
  53328. * Post-process used to create a motion blur effect
  53329. */
  53330. motionBlurPostProcess: Nullable<PostProcess>;
  53331. /**
  53332. * Post-process used to create a depth of field effect
  53333. */
  53334. depthOfFieldPostProcess: Nullable<PostProcess>;
  53335. /**
  53336. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53337. */
  53338. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53339. /**
  53340. * Represents the brightness threshold in order to configure the illuminated surfaces
  53341. */
  53342. brightThreshold: number;
  53343. /**
  53344. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53345. */
  53346. blurWidth: number;
  53347. /**
  53348. * Sets if the blur for highlighted surfaces must be only horizontal
  53349. */
  53350. horizontalBlur: boolean;
  53351. /**
  53352. * Gets the overall exposure used by the pipeline
  53353. */
  53354. /**
  53355. * Sets the overall exposure used by the pipeline
  53356. */
  53357. exposure: number;
  53358. /**
  53359. * Texture used typically to simulate "dirty" on camera lens
  53360. */
  53361. lensTexture: Nullable<Texture>;
  53362. /**
  53363. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53364. */
  53365. volumetricLightCoefficient: number;
  53366. /**
  53367. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53368. */
  53369. volumetricLightPower: number;
  53370. /**
  53371. * Used the set the blur intensity to smooth the volumetric lights
  53372. */
  53373. volumetricLightBlurScale: number;
  53374. /**
  53375. * Light (spot or directional) used to generate the volumetric lights rays
  53376. * The source light must have a shadow generate so the pipeline can get its
  53377. * depth map
  53378. */
  53379. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53380. /**
  53381. * For eye adaptation, represents the minimum luminance the eye can see
  53382. */
  53383. hdrMinimumLuminance: number;
  53384. /**
  53385. * For eye adaptation, represents the decrease luminance speed
  53386. */
  53387. hdrDecreaseRate: number;
  53388. /**
  53389. * For eye adaptation, represents the increase luminance speed
  53390. */
  53391. hdrIncreaseRate: number;
  53392. /**
  53393. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53394. */
  53395. /**
  53396. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53397. */
  53398. hdrAutoExposure: boolean;
  53399. /**
  53400. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53401. */
  53402. lensColorTexture: Nullable<Texture>;
  53403. /**
  53404. * The overall strengh for the lens flare effect
  53405. */
  53406. lensFlareStrength: number;
  53407. /**
  53408. * Dispersion coefficient for lens flare ghosts
  53409. */
  53410. lensFlareGhostDispersal: number;
  53411. /**
  53412. * Main lens flare halo width
  53413. */
  53414. lensFlareHaloWidth: number;
  53415. /**
  53416. * Based on the lens distortion effect, defines how much the lens flare result
  53417. * is distorted
  53418. */
  53419. lensFlareDistortionStrength: number;
  53420. /**
  53421. * Lens star texture must be used to simulate rays on the flares and is available
  53422. * in the documentation
  53423. */
  53424. lensStarTexture: Nullable<Texture>;
  53425. /**
  53426. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53427. * flare effect by taking account of the dirt texture
  53428. */
  53429. lensFlareDirtTexture: Nullable<Texture>;
  53430. /**
  53431. * Represents the focal length for the depth of field effect
  53432. */
  53433. depthOfFieldDistance: number;
  53434. /**
  53435. * Represents the blur intensity for the blurred part of the depth of field effect
  53436. */
  53437. depthOfFieldBlurWidth: number;
  53438. /**
  53439. * For motion blur, defines how much the image is blurred by the movement
  53440. */
  53441. motionStrength: number;
  53442. /**
  53443. * List of animations for the pipeline (IAnimatable implementation)
  53444. */
  53445. animations: Animation[];
  53446. /**
  53447. * Private members
  53448. */
  53449. private _scene;
  53450. private _currentDepthOfFieldSource;
  53451. private _basePostProcess;
  53452. private _fixedExposure;
  53453. private _currentExposure;
  53454. private _hdrAutoExposure;
  53455. private _hdrCurrentLuminance;
  53456. private _floatTextureType;
  53457. private _ratio;
  53458. private _bloomEnabled;
  53459. private _depthOfFieldEnabled;
  53460. private _vlsEnabled;
  53461. private _lensFlareEnabled;
  53462. private _hdrEnabled;
  53463. private _motionBlurEnabled;
  53464. private _fxaaEnabled;
  53465. private _motionBlurSamples;
  53466. private _volumetricLightStepsCount;
  53467. private _samples;
  53468. /**
  53469. * @ignore
  53470. * Specifies if the bloom pipeline is enabled
  53471. */
  53472. BloomEnabled: boolean;
  53473. /**
  53474. * @ignore
  53475. * Specifies if the depth of field pipeline is enabed
  53476. */
  53477. DepthOfFieldEnabled: boolean;
  53478. /**
  53479. * @ignore
  53480. * Specifies if the lens flare pipeline is enabed
  53481. */
  53482. LensFlareEnabled: boolean;
  53483. /**
  53484. * @ignore
  53485. * Specifies if the HDR pipeline is enabled
  53486. */
  53487. HDREnabled: boolean;
  53488. /**
  53489. * @ignore
  53490. * Specifies if the volumetric lights scattering effect is enabled
  53491. */
  53492. VLSEnabled: boolean;
  53493. /**
  53494. * @ignore
  53495. * Specifies if the motion blur effect is enabled
  53496. */
  53497. MotionBlurEnabled: boolean;
  53498. /**
  53499. * Specifies if anti-aliasing is enabled
  53500. */
  53501. fxaaEnabled: boolean;
  53502. /**
  53503. * Specifies the number of steps used to calculate the volumetric lights
  53504. * Typically in interval [50, 200]
  53505. */
  53506. volumetricLightStepsCount: number;
  53507. /**
  53508. * Specifies the number of samples used for the motion blur effect
  53509. * Typically in interval [16, 64]
  53510. */
  53511. motionBlurSamples: number;
  53512. /**
  53513. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53514. */
  53515. samples: number;
  53516. /**
  53517. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53518. * @constructor
  53519. * @param name The rendering pipeline name
  53520. * @param scene The scene linked to this pipeline
  53521. * @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)
  53522. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53523. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53524. */
  53525. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53526. private _buildPipeline;
  53527. private _createDownSampleX4PostProcess;
  53528. private _createBrightPassPostProcess;
  53529. private _createBlurPostProcesses;
  53530. private _createTextureAdderPostProcess;
  53531. private _createVolumetricLightPostProcess;
  53532. private _createLuminancePostProcesses;
  53533. private _createHdrPostProcess;
  53534. private _createLensFlarePostProcess;
  53535. private _createDepthOfFieldPostProcess;
  53536. private _createMotionBlurPostProcess;
  53537. private _getDepthTexture;
  53538. private _disposePostProcesses;
  53539. /**
  53540. * Dispose of the pipeline and stop all post processes
  53541. */
  53542. dispose(): void;
  53543. /**
  53544. * Serialize the rendering pipeline (Used when exporting)
  53545. * @returns the serialized object
  53546. */
  53547. serialize(): any;
  53548. /**
  53549. * Parse the serialized pipeline
  53550. * @param source Source pipeline.
  53551. * @param scene The scene to load the pipeline to.
  53552. * @param rootUrl The URL of the serialized pipeline.
  53553. * @returns An instantiated pipeline from the serialized object.
  53554. */
  53555. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53556. /**
  53557. * Luminance steps
  53558. */
  53559. static LuminanceSteps: number;
  53560. }
  53561. }
  53562. declare module BABYLON {
  53563. /** @hidden */
  53564. export var tonemapPixelShader: {
  53565. name: string;
  53566. shader: string;
  53567. };
  53568. }
  53569. declare module BABYLON {
  53570. /** Defines operator used for tonemapping */
  53571. export enum TonemappingOperator {
  53572. /** Hable */
  53573. Hable = 0,
  53574. /** Reinhard */
  53575. Reinhard = 1,
  53576. /** HejiDawson */
  53577. HejiDawson = 2,
  53578. /** Photographic */
  53579. Photographic = 3
  53580. }
  53581. /**
  53582. * Defines a post process to apply tone mapping
  53583. */
  53584. export class TonemapPostProcess extends PostProcess {
  53585. private _operator;
  53586. /** Defines the required exposure adjustement */
  53587. exposureAdjustment: number;
  53588. /**
  53589. * Creates a new TonemapPostProcess
  53590. * @param name defines the name of the postprocess
  53591. * @param _operator defines the operator to use
  53592. * @param exposureAdjustment defines the required exposure adjustement
  53593. * @param camera defines the camera to use (can be null)
  53594. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53595. * @param engine defines the hosting engine (can be ignore if camera is set)
  53596. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53597. */
  53598. constructor(name: string, _operator: TonemappingOperator,
  53599. /** Defines the required exposure adjustement */
  53600. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53601. }
  53602. }
  53603. declare module BABYLON {
  53604. /** @hidden */
  53605. export var depthVertexShader: {
  53606. name: string;
  53607. shader: string;
  53608. };
  53609. }
  53610. declare module BABYLON {
  53611. /** @hidden */
  53612. export var volumetricLightScatteringPixelShader: {
  53613. name: string;
  53614. shader: string;
  53615. };
  53616. }
  53617. declare module BABYLON {
  53618. /** @hidden */
  53619. export var volumetricLightScatteringPassPixelShader: {
  53620. name: string;
  53621. shader: string;
  53622. };
  53623. }
  53624. declare module BABYLON {
  53625. /**
  53626. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53627. */
  53628. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53629. private _volumetricLightScatteringPass;
  53630. private _volumetricLightScatteringRTT;
  53631. private _viewPort;
  53632. private _screenCoordinates;
  53633. private _cachedDefines;
  53634. /**
  53635. * If not undefined, the mesh position is computed from the attached node position
  53636. */
  53637. attachedNode: {
  53638. position: Vector3;
  53639. };
  53640. /**
  53641. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53642. */
  53643. customMeshPosition: Vector3;
  53644. /**
  53645. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53646. */
  53647. useCustomMeshPosition: boolean;
  53648. /**
  53649. * If the post-process should inverse the light scattering direction
  53650. */
  53651. invert: boolean;
  53652. /**
  53653. * The internal mesh used by the post-process
  53654. */
  53655. mesh: Mesh;
  53656. /**
  53657. * @hidden
  53658. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53659. */
  53660. useDiffuseColor: boolean;
  53661. /**
  53662. * Array containing the excluded meshes not rendered in the internal pass
  53663. */
  53664. excludedMeshes: AbstractMesh[];
  53665. /**
  53666. * Controls the overall intensity of the post-process
  53667. */
  53668. exposure: number;
  53669. /**
  53670. * Dissipates each sample's contribution in range [0, 1]
  53671. */
  53672. decay: number;
  53673. /**
  53674. * Controls the overall intensity of each sample
  53675. */
  53676. weight: number;
  53677. /**
  53678. * Controls the density of each sample
  53679. */
  53680. density: number;
  53681. /**
  53682. * @constructor
  53683. * @param name The post-process name
  53684. * @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)
  53685. * @param camera The camera that the post-process will be attached to
  53686. * @param mesh The mesh used to create the light scattering
  53687. * @param samples The post-process quality, default 100
  53688. * @param samplingModeThe post-process filtering mode
  53689. * @param engine The babylon engine
  53690. * @param reusable If the post-process is reusable
  53691. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53692. */
  53693. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53694. /**
  53695. * Returns the string "VolumetricLightScatteringPostProcess"
  53696. * @returns "VolumetricLightScatteringPostProcess"
  53697. */
  53698. getClassName(): string;
  53699. private _isReady;
  53700. /**
  53701. * Sets the new light position for light scattering effect
  53702. * @param position The new custom light position
  53703. */
  53704. setCustomMeshPosition(position: Vector3): void;
  53705. /**
  53706. * Returns the light position for light scattering effect
  53707. * @return Vector3 The custom light position
  53708. */
  53709. getCustomMeshPosition(): Vector3;
  53710. /**
  53711. * Disposes the internal assets and detaches the post-process from the camera
  53712. */
  53713. dispose(camera: Camera): void;
  53714. /**
  53715. * Returns the render target texture used by the post-process
  53716. * @return the render target texture used by the post-process
  53717. */
  53718. getPass(): RenderTargetTexture;
  53719. private _meshExcluded;
  53720. private _createPass;
  53721. private _updateMeshScreenCoordinates;
  53722. /**
  53723. * Creates a default mesh for the Volumeric Light Scattering post-process
  53724. * @param name The mesh name
  53725. * @param scene The scene where to create the mesh
  53726. * @return the default mesh
  53727. */
  53728. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53729. }
  53730. }
  53731. declare module BABYLON {
  53732. interface Scene {
  53733. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53734. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53735. /**
  53736. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53737. */
  53738. forceShowBoundingBoxes: boolean;
  53739. /**
  53740. * Gets the bounding box renderer associated with the scene
  53741. * @returns a BoundingBoxRenderer
  53742. */
  53743. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53744. }
  53745. interface AbstractMesh {
  53746. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53747. /**
  53748. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53749. */
  53750. showBoundingBox: boolean;
  53751. }
  53752. /**
  53753. * Component responsible of rendering the bounding box of the meshes in a scene.
  53754. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53755. */
  53756. export class BoundingBoxRenderer implements ISceneComponent {
  53757. /**
  53758. * The component name helpfull to identify the component in the list of scene components.
  53759. */
  53760. readonly name: string;
  53761. /**
  53762. * The scene the component belongs to.
  53763. */
  53764. scene: Scene;
  53765. /**
  53766. * Color of the bounding box lines placed in front of an object
  53767. */
  53768. frontColor: Color3;
  53769. /**
  53770. * Color of the bounding box lines placed behind an object
  53771. */
  53772. backColor: Color3;
  53773. /**
  53774. * Defines if the renderer should show the back lines or not
  53775. */
  53776. showBackLines: boolean;
  53777. /**
  53778. * @hidden
  53779. */
  53780. renderList: SmartArray<BoundingBox>;
  53781. private _colorShader;
  53782. private _vertexBuffers;
  53783. private _indexBuffer;
  53784. /**
  53785. * Instantiates a new bounding box renderer in a scene.
  53786. * @param scene the scene the renderer renders in
  53787. */
  53788. constructor(scene: Scene);
  53789. /**
  53790. * Registers the component in a given scene
  53791. */
  53792. register(): void;
  53793. private _evaluateSubMesh;
  53794. private _activeMesh;
  53795. private _prepareRessources;
  53796. private _createIndexBuffer;
  53797. /**
  53798. * Rebuilds the elements related to this component in case of
  53799. * context lost for instance.
  53800. */
  53801. rebuild(): void;
  53802. /**
  53803. * @hidden
  53804. */
  53805. reset(): void;
  53806. /**
  53807. * Render the bounding boxes of a specific rendering group
  53808. * @param renderingGroupId defines the rendering group to render
  53809. */
  53810. render(renderingGroupId: number): void;
  53811. /**
  53812. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53813. * @param mesh Define the mesh to render the occlusion bounding box for
  53814. */
  53815. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53816. /**
  53817. * Dispose and release the resources attached to this renderer.
  53818. */
  53819. dispose(): void;
  53820. }
  53821. }
  53822. declare module BABYLON {
  53823. /** @hidden */
  53824. export var depthPixelShader: {
  53825. name: string;
  53826. shader: string;
  53827. };
  53828. }
  53829. declare module BABYLON {
  53830. /**
  53831. * This represents a depth renderer in Babylon.
  53832. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53833. */
  53834. export class DepthRenderer {
  53835. private _scene;
  53836. private _depthMap;
  53837. private _effect;
  53838. private _cachedDefines;
  53839. private _camera;
  53840. /**
  53841. * Specifiess that the depth renderer will only be used within
  53842. * the camera it is created for.
  53843. * This can help forcing its rendering during the camera processing.
  53844. */
  53845. useOnlyInActiveCamera: boolean;
  53846. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53847. /**
  53848. * Instantiates a depth renderer
  53849. * @param scene The scene the renderer belongs to
  53850. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53851. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53852. */
  53853. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53854. /**
  53855. * Creates the depth rendering effect and checks if the effect is ready.
  53856. * @param subMesh The submesh to be used to render the depth map of
  53857. * @param useInstances If multiple world instances should be used
  53858. * @returns if the depth renderer is ready to render the depth map
  53859. */
  53860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53861. /**
  53862. * Gets the texture which the depth map will be written to.
  53863. * @returns The depth map texture
  53864. */
  53865. getDepthMap(): RenderTargetTexture;
  53866. /**
  53867. * Disposes of the depth renderer.
  53868. */
  53869. dispose(): void;
  53870. }
  53871. }
  53872. declare module BABYLON {
  53873. interface Scene {
  53874. /** @hidden (Backing field) */ depthRenderer: {
  53875. [id: string]: DepthRenderer;
  53876. };
  53877. /**
  53878. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53879. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53880. * @returns the created depth renderer
  53881. */
  53882. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53883. /**
  53884. * Disables a depth renderer for a given camera
  53885. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53886. */
  53887. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53888. }
  53889. /**
  53890. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53891. * in several rendering techniques.
  53892. */
  53893. export class DepthRendererSceneComponent implements ISceneComponent {
  53894. /**
  53895. * The component name helpfull to identify the component in the list of scene components.
  53896. */
  53897. readonly name: string;
  53898. /**
  53899. * The scene the component belongs to.
  53900. */
  53901. scene: Scene;
  53902. /**
  53903. * Creates a new instance of the component for the given scene
  53904. * @param scene Defines the scene to register the component in
  53905. */
  53906. constructor(scene: Scene);
  53907. /**
  53908. * Registers the component in a given scene
  53909. */
  53910. register(): void;
  53911. /**
  53912. * Rebuilds the elements related to this component in case of
  53913. * context lost for instance.
  53914. */
  53915. rebuild(): void;
  53916. /**
  53917. * Disposes the component and the associated ressources
  53918. */
  53919. dispose(): void;
  53920. private _gatherRenderTargets;
  53921. private _gatherActiveCameraRenderTargets;
  53922. }
  53923. }
  53924. declare module BABYLON {
  53925. /** @hidden */
  53926. export var outlinePixelShader: {
  53927. name: string;
  53928. shader: string;
  53929. };
  53930. }
  53931. declare module BABYLON {
  53932. /** @hidden */
  53933. export var outlineVertexShader: {
  53934. name: string;
  53935. shader: string;
  53936. };
  53937. }
  53938. declare module BABYLON {
  53939. interface Scene {
  53940. /** @hidden */ outlineRenderer: OutlineRenderer;
  53941. /**
  53942. * Gets the outline renderer associated with the scene
  53943. * @returns a OutlineRenderer
  53944. */
  53945. getOutlineRenderer(): OutlineRenderer;
  53946. }
  53947. interface AbstractMesh {
  53948. /** @hidden (Backing field) */ renderOutline: boolean;
  53949. /**
  53950. * Gets or sets a boolean indicating if the outline must be rendered as well
  53951. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53952. */
  53953. renderOutline: boolean;
  53954. /** @hidden (Backing field) */ renderOverlay: boolean;
  53955. /**
  53956. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53957. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53958. */
  53959. renderOverlay: boolean;
  53960. }
  53961. /**
  53962. * This class is responsible to draw bothe outline/overlay of meshes.
  53963. * It should not be used directly but through the available method on mesh.
  53964. */
  53965. export class OutlineRenderer implements ISceneComponent {
  53966. /**
  53967. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53968. */
  53969. private static _StencilReference;
  53970. /**
  53971. * The name of the component. Each component must have a unique name.
  53972. */
  53973. name: string;
  53974. /**
  53975. * The scene the component belongs to.
  53976. */
  53977. scene: Scene;
  53978. /**
  53979. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53980. */
  53981. zOffset: number;
  53982. private _engine;
  53983. private _effect;
  53984. private _cachedDefines;
  53985. private _savedDepthWrite;
  53986. /**
  53987. * Instantiates a new outline renderer. (There could be only one per scene).
  53988. * @param scene Defines the scene it belongs to
  53989. */
  53990. constructor(scene: Scene);
  53991. /**
  53992. * Register the component to one instance of a scene.
  53993. */
  53994. register(): void;
  53995. /**
  53996. * Rebuilds the elements related to this component in case of
  53997. * context lost for instance.
  53998. */
  53999. rebuild(): void;
  54000. /**
  54001. * Disposes the component and the associated ressources.
  54002. */
  54003. dispose(): void;
  54004. /**
  54005. * Renders the outline in the canvas.
  54006. * @param subMesh Defines the sumesh to render
  54007. * @param batch Defines the batch of meshes in case of instances
  54008. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54009. */
  54010. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54011. /**
  54012. * Returns whether or not the outline renderer is ready for a given submesh.
  54013. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54014. * @param subMesh Defines the submesh to check readyness for
  54015. * @param useInstances Defines wheter wee are trying to render instances or not
  54016. * @returns true if ready otherwise false
  54017. */
  54018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54019. private _beforeRenderingMesh;
  54020. private _afterRenderingMesh;
  54021. }
  54022. }
  54023. declare module BABYLON {
  54024. /**
  54025. * Defines the list of states available for a task inside a AssetsManager
  54026. */
  54027. export enum AssetTaskState {
  54028. /**
  54029. * Initialization
  54030. */
  54031. INIT = 0,
  54032. /**
  54033. * Running
  54034. */
  54035. RUNNING = 1,
  54036. /**
  54037. * Done
  54038. */
  54039. DONE = 2,
  54040. /**
  54041. * Error
  54042. */
  54043. ERROR = 3
  54044. }
  54045. /**
  54046. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54047. */
  54048. export abstract class AbstractAssetTask {
  54049. /**
  54050. * Task name
  54051. */ name: string;
  54052. /**
  54053. * Callback called when the task is successful
  54054. */
  54055. onSuccess: (task: any) => void;
  54056. /**
  54057. * Callback called when the task is not successful
  54058. */
  54059. onError: (task: any, message?: string, exception?: any) => void;
  54060. /**
  54061. * Creates a new AssetsManager
  54062. * @param name defines the name of the task
  54063. */
  54064. constructor(
  54065. /**
  54066. * Task name
  54067. */ name: string);
  54068. private _isCompleted;
  54069. private _taskState;
  54070. private _errorObject;
  54071. /**
  54072. * Get if the task is completed
  54073. */
  54074. readonly isCompleted: boolean;
  54075. /**
  54076. * Gets the current state of the task
  54077. */
  54078. readonly taskState: AssetTaskState;
  54079. /**
  54080. * Gets the current error object (if task is in error)
  54081. */
  54082. readonly errorObject: {
  54083. message?: string;
  54084. exception?: any;
  54085. };
  54086. /**
  54087. * Internal only
  54088. * @hidden
  54089. */ setErrorObject(message?: string, exception?: any): void;
  54090. /**
  54091. * Execute the current task
  54092. * @param scene defines the scene where you want your assets to be loaded
  54093. * @param onSuccess is a callback called when the task is successfully executed
  54094. * @param onError is a callback called if an error occurs
  54095. */
  54096. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54097. /**
  54098. * Execute the current task
  54099. * @param scene defines the scene where you want your assets to be loaded
  54100. * @param onSuccess is a callback called when the task is successfully executed
  54101. * @param onError is a callback called if an error occurs
  54102. */
  54103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54104. /**
  54105. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54106. * This can be used with failed tasks that have the reason for failure fixed.
  54107. */
  54108. reset(): void;
  54109. private onErrorCallback;
  54110. private onDoneCallback;
  54111. }
  54112. /**
  54113. * Define the interface used by progress events raised during assets loading
  54114. */
  54115. export interface IAssetsProgressEvent {
  54116. /**
  54117. * Defines the number of remaining tasks to process
  54118. */
  54119. remainingCount: number;
  54120. /**
  54121. * Defines the total number of tasks
  54122. */
  54123. totalCount: number;
  54124. /**
  54125. * Defines the task that was just processed
  54126. */
  54127. task: AbstractAssetTask;
  54128. }
  54129. /**
  54130. * Class used to share progress information about assets loading
  54131. */
  54132. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54133. /**
  54134. * Defines the number of remaining tasks to process
  54135. */
  54136. remainingCount: number;
  54137. /**
  54138. * Defines the total number of tasks
  54139. */
  54140. totalCount: number;
  54141. /**
  54142. * Defines the task that was just processed
  54143. */
  54144. task: AbstractAssetTask;
  54145. /**
  54146. * Creates a AssetsProgressEvent
  54147. * @param remainingCount defines the number of remaining tasks to process
  54148. * @param totalCount defines the total number of tasks
  54149. * @param task defines the task that was just processed
  54150. */
  54151. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54152. }
  54153. /**
  54154. * Define a task used by AssetsManager to load meshes
  54155. */
  54156. export class MeshAssetTask extends AbstractAssetTask {
  54157. /**
  54158. * Defines the name of the task
  54159. */
  54160. name: string;
  54161. /**
  54162. * Defines the list of mesh's names you want to load
  54163. */
  54164. meshesNames: any;
  54165. /**
  54166. * Defines the root url to use as a base to load your meshes and associated resources
  54167. */
  54168. rootUrl: string;
  54169. /**
  54170. * Defines the filename of the scene to load from
  54171. */
  54172. sceneFilename: string;
  54173. /**
  54174. * Gets the list of loaded meshes
  54175. */
  54176. loadedMeshes: Array<AbstractMesh>;
  54177. /**
  54178. * Gets the list of loaded particle systems
  54179. */
  54180. loadedParticleSystems: Array<IParticleSystem>;
  54181. /**
  54182. * Gets the list of loaded skeletons
  54183. */
  54184. loadedSkeletons: Array<Skeleton>;
  54185. /**
  54186. * Gets the list of loaded animation groups
  54187. */
  54188. loadedAnimationGroups: Array<AnimationGroup>;
  54189. /**
  54190. * Callback called when the task is successful
  54191. */
  54192. onSuccess: (task: MeshAssetTask) => void;
  54193. /**
  54194. * Callback called when the task is successful
  54195. */
  54196. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54197. /**
  54198. * Creates a new MeshAssetTask
  54199. * @param name defines the name of the task
  54200. * @param meshesNames defines the list of mesh's names you want to load
  54201. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54202. * @param sceneFilename defines the filename of the scene to load from
  54203. */
  54204. constructor(
  54205. /**
  54206. * Defines the name of the task
  54207. */
  54208. name: string,
  54209. /**
  54210. * Defines the list of mesh's names you want to load
  54211. */
  54212. meshesNames: any,
  54213. /**
  54214. * Defines the root url to use as a base to load your meshes and associated resources
  54215. */
  54216. rootUrl: string,
  54217. /**
  54218. * Defines the filename of the scene to load from
  54219. */
  54220. sceneFilename: string);
  54221. /**
  54222. * Execute the current task
  54223. * @param scene defines the scene where you want your assets to be loaded
  54224. * @param onSuccess is a callback called when the task is successfully executed
  54225. * @param onError is a callback called if an error occurs
  54226. */
  54227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54228. }
  54229. /**
  54230. * Define a task used by AssetsManager to load text content
  54231. */
  54232. export class TextFileAssetTask extends AbstractAssetTask {
  54233. /**
  54234. * Defines the name of the task
  54235. */
  54236. name: string;
  54237. /**
  54238. * Defines the location of the file to load
  54239. */
  54240. url: string;
  54241. /**
  54242. * Gets the loaded text string
  54243. */
  54244. text: string;
  54245. /**
  54246. * Callback called when the task is successful
  54247. */
  54248. onSuccess: (task: TextFileAssetTask) => void;
  54249. /**
  54250. * Callback called when the task is successful
  54251. */
  54252. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54253. /**
  54254. * Creates a new TextFileAssetTask object
  54255. * @param name defines the name of the task
  54256. * @param url defines the location of the file to load
  54257. */
  54258. constructor(
  54259. /**
  54260. * Defines the name of the task
  54261. */
  54262. name: string,
  54263. /**
  54264. * Defines the location of the file to load
  54265. */
  54266. url: string);
  54267. /**
  54268. * Execute the current task
  54269. * @param scene defines the scene where you want your assets to be loaded
  54270. * @param onSuccess is a callback called when the task is successfully executed
  54271. * @param onError is a callback called if an error occurs
  54272. */
  54273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54274. }
  54275. /**
  54276. * Define a task used by AssetsManager to load binary data
  54277. */
  54278. export class BinaryFileAssetTask extends AbstractAssetTask {
  54279. /**
  54280. * Defines the name of the task
  54281. */
  54282. name: string;
  54283. /**
  54284. * Defines the location of the file to load
  54285. */
  54286. url: string;
  54287. /**
  54288. * Gets the lodaded data (as an array buffer)
  54289. */
  54290. data: ArrayBuffer;
  54291. /**
  54292. * Callback called when the task is successful
  54293. */
  54294. onSuccess: (task: BinaryFileAssetTask) => void;
  54295. /**
  54296. * Callback called when the task is successful
  54297. */
  54298. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54299. /**
  54300. * Creates a new BinaryFileAssetTask object
  54301. * @param name defines the name of the new task
  54302. * @param url defines the location of the file to load
  54303. */
  54304. constructor(
  54305. /**
  54306. * Defines the name of the task
  54307. */
  54308. name: string,
  54309. /**
  54310. * Defines the location of the file to load
  54311. */
  54312. url: string);
  54313. /**
  54314. * Execute the current task
  54315. * @param scene defines the scene where you want your assets to be loaded
  54316. * @param onSuccess is a callback called when the task is successfully executed
  54317. * @param onError is a callback called if an error occurs
  54318. */
  54319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54320. }
  54321. /**
  54322. * Define a task used by AssetsManager to load images
  54323. */
  54324. export class ImageAssetTask extends AbstractAssetTask {
  54325. /**
  54326. * Defines the name of the task
  54327. */
  54328. name: string;
  54329. /**
  54330. * Defines the location of the image to load
  54331. */
  54332. url: string;
  54333. /**
  54334. * Gets the loaded images
  54335. */
  54336. image: HTMLImageElement;
  54337. /**
  54338. * Callback called when the task is successful
  54339. */
  54340. onSuccess: (task: ImageAssetTask) => void;
  54341. /**
  54342. * Callback called when the task is successful
  54343. */
  54344. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54345. /**
  54346. * Creates a new ImageAssetTask
  54347. * @param name defines the name of the task
  54348. * @param url defines the location of the image to load
  54349. */
  54350. constructor(
  54351. /**
  54352. * Defines the name of the task
  54353. */
  54354. name: string,
  54355. /**
  54356. * Defines the location of the image to load
  54357. */
  54358. url: string);
  54359. /**
  54360. * Execute the current task
  54361. * @param scene defines the scene where you want your assets to be loaded
  54362. * @param onSuccess is a callback called when the task is successfully executed
  54363. * @param onError is a callback called if an error occurs
  54364. */
  54365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54366. }
  54367. /**
  54368. * Defines the interface used by texture loading tasks
  54369. */
  54370. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54371. /**
  54372. * Gets the loaded texture
  54373. */
  54374. texture: TEX;
  54375. }
  54376. /**
  54377. * Define a task used by AssetsManager to load 2D textures
  54378. */
  54379. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54380. /**
  54381. * Defines the name of the task
  54382. */
  54383. name: string;
  54384. /**
  54385. * Defines the location of the file to load
  54386. */
  54387. url: string;
  54388. /**
  54389. * Defines if mipmap should not be generated (default is false)
  54390. */
  54391. noMipmap?: boolean | undefined;
  54392. /**
  54393. * Defines if texture must be inverted on Y axis (default is false)
  54394. */
  54395. invertY?: boolean | undefined;
  54396. /**
  54397. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54398. */
  54399. samplingMode: number;
  54400. /**
  54401. * Gets the loaded texture
  54402. */
  54403. texture: Texture;
  54404. /**
  54405. * Callback called when the task is successful
  54406. */
  54407. onSuccess: (task: TextureAssetTask) => void;
  54408. /**
  54409. * Callback called when the task is successful
  54410. */
  54411. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54412. /**
  54413. * Creates a new TextureAssetTask object
  54414. * @param name defines the name of the task
  54415. * @param url defines the location of the file to load
  54416. * @param noMipmap defines if mipmap should not be generated (default is false)
  54417. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54418. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54419. */
  54420. constructor(
  54421. /**
  54422. * Defines the name of the task
  54423. */
  54424. name: string,
  54425. /**
  54426. * Defines the location of the file to load
  54427. */
  54428. url: string,
  54429. /**
  54430. * Defines if mipmap should not be generated (default is false)
  54431. */
  54432. noMipmap?: boolean | undefined,
  54433. /**
  54434. * Defines if texture must be inverted on Y axis (default is false)
  54435. */
  54436. invertY?: boolean | undefined,
  54437. /**
  54438. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54439. */
  54440. samplingMode?: number);
  54441. /**
  54442. * Execute the current task
  54443. * @param scene defines the scene where you want your assets to be loaded
  54444. * @param onSuccess is a callback called when the task is successfully executed
  54445. * @param onError is a callback called if an error occurs
  54446. */
  54447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54448. }
  54449. /**
  54450. * Define a task used by AssetsManager to load cube textures
  54451. */
  54452. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54453. /**
  54454. * Defines the name of the task
  54455. */
  54456. name: string;
  54457. /**
  54458. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54459. */
  54460. url: string;
  54461. /**
  54462. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54463. */
  54464. extensions?: string[] | undefined;
  54465. /**
  54466. * Defines if mipmaps should not be generated (default is false)
  54467. */
  54468. noMipmap?: boolean | undefined;
  54469. /**
  54470. * Defines the explicit list of files (undefined by default)
  54471. */
  54472. files?: string[] | undefined;
  54473. /**
  54474. * Gets the loaded texture
  54475. */
  54476. texture: CubeTexture;
  54477. /**
  54478. * Callback called when the task is successful
  54479. */
  54480. onSuccess: (task: CubeTextureAssetTask) => void;
  54481. /**
  54482. * Callback called when the task is successful
  54483. */
  54484. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54485. /**
  54486. * Creates a new CubeTextureAssetTask
  54487. * @param name defines the name of the task
  54488. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54489. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54490. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54491. * @param files defines the explicit list of files (undefined by default)
  54492. */
  54493. constructor(
  54494. /**
  54495. * Defines the name of the task
  54496. */
  54497. name: string,
  54498. /**
  54499. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54500. */
  54501. url: string,
  54502. /**
  54503. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54504. */
  54505. extensions?: string[] | undefined,
  54506. /**
  54507. * Defines if mipmaps should not be generated (default is false)
  54508. */
  54509. noMipmap?: boolean | undefined,
  54510. /**
  54511. * Defines the explicit list of files (undefined by default)
  54512. */
  54513. files?: string[] | undefined);
  54514. /**
  54515. * Execute the current task
  54516. * @param scene defines the scene where you want your assets to be loaded
  54517. * @param onSuccess is a callback called when the task is successfully executed
  54518. * @param onError is a callback called if an error occurs
  54519. */
  54520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54521. }
  54522. /**
  54523. * Define a task used by AssetsManager to load HDR cube textures
  54524. */
  54525. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54526. /**
  54527. * Defines the name of the task
  54528. */
  54529. name: string;
  54530. /**
  54531. * Defines the location of the file to load
  54532. */
  54533. url: string;
  54534. /**
  54535. * Defines the desired size (the more it increases the longer the generation will be)
  54536. */
  54537. size: number;
  54538. /**
  54539. * Defines if mipmaps should not be generated (default is false)
  54540. */
  54541. noMipmap: boolean;
  54542. /**
  54543. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54544. */
  54545. generateHarmonics: boolean;
  54546. /**
  54547. * 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)
  54548. */
  54549. gammaSpace: boolean;
  54550. /**
  54551. * Internal Use Only
  54552. */
  54553. reserved: boolean;
  54554. /**
  54555. * Gets the loaded texture
  54556. */
  54557. texture: HDRCubeTexture;
  54558. /**
  54559. * Callback called when the task is successful
  54560. */
  54561. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54562. /**
  54563. * Callback called when the task is successful
  54564. */
  54565. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54566. /**
  54567. * Creates a new HDRCubeTextureAssetTask object
  54568. * @param name defines the name of the task
  54569. * @param url defines the location of the file to load
  54570. * @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.
  54571. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54572. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54573. * @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)
  54574. * @param reserved Internal use only
  54575. */
  54576. constructor(
  54577. /**
  54578. * Defines the name of the task
  54579. */
  54580. name: string,
  54581. /**
  54582. * Defines the location of the file to load
  54583. */
  54584. url: string,
  54585. /**
  54586. * Defines the desired size (the more it increases the longer the generation will be)
  54587. */
  54588. size: number,
  54589. /**
  54590. * Defines if mipmaps should not be generated (default is false)
  54591. */
  54592. noMipmap?: boolean,
  54593. /**
  54594. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54595. */
  54596. generateHarmonics?: boolean,
  54597. /**
  54598. * 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)
  54599. */
  54600. gammaSpace?: boolean,
  54601. /**
  54602. * Internal Use Only
  54603. */
  54604. reserved?: boolean);
  54605. /**
  54606. * Execute the current task
  54607. * @param scene defines the scene where you want your assets to be loaded
  54608. * @param onSuccess is a callback called when the task is successfully executed
  54609. * @param onError is a callback called if an error occurs
  54610. */
  54611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54612. }
  54613. /**
  54614. * Define a task used by AssetsManager to load Equirectangular cube textures
  54615. */
  54616. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54617. /**
  54618. * Defines the name of the task
  54619. */
  54620. name: string;
  54621. /**
  54622. * Defines the location of the file to load
  54623. */
  54624. url: string;
  54625. /**
  54626. * Defines the desired size (the more it increases the longer the generation will be)
  54627. */
  54628. size: number;
  54629. /**
  54630. * Defines if mipmaps should not be generated (default is false)
  54631. */
  54632. noMipmap: boolean;
  54633. /**
  54634. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54635. * but the standard material would require them in Gamma space) (default is true)
  54636. */
  54637. gammaSpace: boolean;
  54638. /**
  54639. * Gets the loaded texture
  54640. */
  54641. texture: EquiRectangularCubeTexture;
  54642. /**
  54643. * Callback called when the task is successful
  54644. */
  54645. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54646. /**
  54647. * Callback called when the task is successful
  54648. */
  54649. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54650. /**
  54651. * Creates a new EquiRectangularCubeTextureAssetTask object
  54652. * @param name defines the name of the task
  54653. * @param url defines the location of the file to load
  54654. * @param size defines the desired size (the more it increases the longer the generation will be)
  54655. * If the size is omitted this implies you are using a preprocessed cubemap.
  54656. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54657. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54658. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54659. * (default is true)
  54660. */
  54661. constructor(
  54662. /**
  54663. * Defines the name of the task
  54664. */
  54665. name: string,
  54666. /**
  54667. * Defines the location of the file to load
  54668. */
  54669. url: string,
  54670. /**
  54671. * Defines the desired size (the more it increases the longer the generation will be)
  54672. */
  54673. size: number,
  54674. /**
  54675. * Defines if mipmaps should not be generated (default is false)
  54676. */
  54677. noMipmap?: boolean,
  54678. /**
  54679. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54680. * but the standard material would require them in Gamma space) (default is true)
  54681. */
  54682. gammaSpace?: boolean);
  54683. /**
  54684. * Execute the current task
  54685. * @param scene defines the scene where you want your assets to be loaded
  54686. * @param onSuccess is a callback called when the task is successfully executed
  54687. * @param onError is a callback called if an error occurs
  54688. */
  54689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54690. }
  54691. /**
  54692. * This class can be used to easily import assets into a scene
  54693. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54694. */
  54695. export class AssetsManager {
  54696. private _scene;
  54697. private _isLoading;
  54698. protected _tasks: AbstractAssetTask[];
  54699. protected _waitingTasksCount: number;
  54700. protected _totalTasksCount: number;
  54701. /**
  54702. * Callback called when all tasks are processed
  54703. */
  54704. onFinish: (tasks: AbstractAssetTask[]) => void;
  54705. /**
  54706. * Callback called when a task is successful
  54707. */
  54708. onTaskSuccess: (task: AbstractAssetTask) => void;
  54709. /**
  54710. * Callback called when a task had an error
  54711. */
  54712. onTaskError: (task: AbstractAssetTask) => void;
  54713. /**
  54714. * Callback called when a task is done (whatever the result is)
  54715. */
  54716. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54717. /**
  54718. * Observable called when all tasks are processed
  54719. */
  54720. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54721. /**
  54722. * Observable called when a task had an error
  54723. */
  54724. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54725. /**
  54726. * Observable called when all tasks were executed
  54727. */
  54728. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54729. /**
  54730. * Observable called when a task is done (whatever the result is)
  54731. */
  54732. onProgressObservable: Observable<IAssetsProgressEvent>;
  54733. /**
  54734. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54735. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54736. */
  54737. useDefaultLoadingScreen: boolean;
  54738. /**
  54739. * Creates a new AssetsManager
  54740. * @param scene defines the scene to work on
  54741. */
  54742. constructor(scene: Scene);
  54743. /**
  54744. * Add a MeshAssetTask to the list of active tasks
  54745. * @param taskName defines the name of the new task
  54746. * @param meshesNames defines the name of meshes to load
  54747. * @param rootUrl defines the root url to use to locate files
  54748. * @param sceneFilename defines the filename of the scene file
  54749. * @returns a new MeshAssetTask object
  54750. */
  54751. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54752. /**
  54753. * Add a TextFileAssetTask to the list of active tasks
  54754. * @param taskName defines the name of the new task
  54755. * @param url defines the url of the file to load
  54756. * @returns a new TextFileAssetTask object
  54757. */
  54758. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54759. /**
  54760. * Add a BinaryFileAssetTask to the list of active tasks
  54761. * @param taskName defines the name of the new task
  54762. * @param url defines the url of the file to load
  54763. * @returns a new BinaryFileAssetTask object
  54764. */
  54765. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54766. /**
  54767. * Add a ImageAssetTask to the list of active tasks
  54768. * @param taskName defines the name of the new task
  54769. * @param url defines the url of the file to load
  54770. * @returns a new ImageAssetTask object
  54771. */
  54772. addImageTask(taskName: string, url: string): ImageAssetTask;
  54773. /**
  54774. * Add a TextureAssetTask to the list of active tasks
  54775. * @param taskName defines the name of the new task
  54776. * @param url defines the url of the file to load
  54777. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54778. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54779. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54780. * @returns a new TextureAssetTask object
  54781. */
  54782. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54783. /**
  54784. * Add a CubeTextureAssetTask to the list of active tasks
  54785. * @param taskName defines the name of the new task
  54786. * @param url defines the url of the file to load
  54787. * @param extensions defines the extension to use to load the cube map (can be null)
  54788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54789. * @param files defines the list of files to load (can be null)
  54790. * @returns a new CubeTextureAssetTask object
  54791. */
  54792. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54793. /**
  54794. *
  54795. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54796. * @param taskName defines the name of the new task
  54797. * @param url defines the url of the file to load
  54798. * @param size defines the size you want for the cubemap (can be null)
  54799. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54800. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54801. * @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)
  54802. * @param reserved Internal use only
  54803. * @returns a new HDRCubeTextureAssetTask object
  54804. */
  54805. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54806. /**
  54807. *
  54808. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54809. * @param taskName defines the name of the new task
  54810. * @param url defines the url of the file to load
  54811. * @param size defines the size you want for the cubemap (can be null)
  54812. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54813. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54814. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54815. * @returns a new EquiRectangularCubeTextureAssetTask object
  54816. */
  54817. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54818. /**
  54819. * Remove a task from the assets manager.
  54820. * @param task the task to remove
  54821. */
  54822. removeTask(task: AbstractAssetTask): void;
  54823. private _decreaseWaitingTasksCount;
  54824. private _runTask;
  54825. /**
  54826. * Reset the AssetsManager and remove all tasks
  54827. * @return the current instance of the AssetsManager
  54828. */
  54829. reset(): AssetsManager;
  54830. /**
  54831. * Start the loading process
  54832. * @return the current instance of the AssetsManager
  54833. */
  54834. load(): AssetsManager;
  54835. /**
  54836. * Start the loading process as an async operation
  54837. * @return a promise returning the list of failed tasks
  54838. */
  54839. loadAsync(): Promise<void>;
  54840. }
  54841. }
  54842. declare module BABYLON {
  54843. /**
  54844. * Wrapper class for promise with external resolve and reject.
  54845. */
  54846. export class Deferred<T> {
  54847. /**
  54848. * The promise associated with this deferred object.
  54849. */
  54850. readonly promise: Promise<T>;
  54851. private _resolve;
  54852. private _reject;
  54853. /**
  54854. * The resolve method of the promise associated with this deferred object.
  54855. */
  54856. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54857. /**
  54858. * The reject method of the promise associated with this deferred object.
  54859. */
  54860. readonly reject: (reason?: any) => void;
  54861. /**
  54862. * Constructor for this deferred object.
  54863. */
  54864. constructor();
  54865. }
  54866. }
  54867. declare module BABYLON {
  54868. /**
  54869. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54870. */
  54871. export class MeshExploder {
  54872. private _centerMesh;
  54873. private _meshes;
  54874. private _meshesOrigins;
  54875. private _toCenterVectors;
  54876. private _scaledDirection;
  54877. private _newPosition;
  54878. private _centerPosition;
  54879. /**
  54880. * Explodes meshes from a center mesh.
  54881. * @param meshes The meshes to explode.
  54882. * @param centerMesh The mesh to be center of explosion.
  54883. */
  54884. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54885. private _setCenterMesh;
  54886. /**
  54887. * Get class name
  54888. * @returns "MeshExploder"
  54889. */
  54890. getClassName(): string;
  54891. /**
  54892. * "Exploded meshes"
  54893. * @returns Array of meshes with the centerMesh at index 0.
  54894. */
  54895. getMeshes(): Array<Mesh>;
  54896. /**
  54897. * Explodes meshes giving a specific direction
  54898. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54899. */
  54900. explode(direction?: number): void;
  54901. }
  54902. }
  54903. declare module BABYLON {
  54904. /**
  54905. * Class used to help managing file picking and drag'n'drop
  54906. */
  54907. export class FilesInput {
  54908. /**
  54909. * List of files ready to be loaded
  54910. */
  54911. static readonly FilesToLoad: {
  54912. [key: string]: File;
  54913. };
  54914. /**
  54915. * Callback called when a file is processed
  54916. */
  54917. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54918. private _engine;
  54919. private _currentScene;
  54920. private _sceneLoadedCallback;
  54921. private _progressCallback;
  54922. private _additionalRenderLoopLogicCallback;
  54923. private _textureLoadingCallback;
  54924. private _startingProcessingFilesCallback;
  54925. private _onReloadCallback;
  54926. private _errorCallback;
  54927. private _elementToMonitor;
  54928. private _sceneFileToLoad;
  54929. private _filesToLoad;
  54930. /**
  54931. * Creates a new FilesInput
  54932. * @param engine defines the rendering engine
  54933. * @param scene defines the hosting scene
  54934. * @param sceneLoadedCallback callback called when scene is loaded
  54935. * @param progressCallback callback called to track progress
  54936. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54937. * @param textureLoadingCallback callback called when a texture is loading
  54938. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54939. * @param onReloadCallback callback called when a reload is requested
  54940. * @param errorCallback callback call if an error occurs
  54941. */
  54942. 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);
  54943. private _dragEnterHandler;
  54944. private _dragOverHandler;
  54945. private _dropHandler;
  54946. /**
  54947. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54948. * @param elementToMonitor defines the DOM element to track
  54949. */
  54950. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54951. /**
  54952. * Release all associated resources
  54953. */
  54954. dispose(): void;
  54955. private renderFunction;
  54956. private drag;
  54957. private drop;
  54958. private _traverseFolder;
  54959. private _processFiles;
  54960. /**
  54961. * Load files from a drop event
  54962. * @param event defines the drop event to use as source
  54963. */
  54964. loadFiles(event: any): void;
  54965. private _processReload;
  54966. /**
  54967. * Reload the current scene from the loaded files
  54968. */
  54969. reload(): void;
  54970. }
  54971. }
  54972. declare module BABYLON {
  54973. /**
  54974. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54976. */
  54977. export class SceneOptimization {
  54978. /**
  54979. * Defines the priority of this optimization (0 by default which means first in the list)
  54980. */
  54981. priority: number;
  54982. /**
  54983. * Gets a string describing the action executed by the current optimization
  54984. * @returns description string
  54985. */
  54986. getDescription(): string;
  54987. /**
  54988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54989. * @param scene defines the current scene where to apply this optimization
  54990. * @param optimizer defines the current optimizer
  54991. * @returns true if everything that can be done was applied
  54992. */
  54993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54994. /**
  54995. * Creates the SceneOptimization object
  54996. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54997. * @param desc defines the description associated with the optimization
  54998. */
  54999. constructor(
  55000. /**
  55001. * Defines the priority of this optimization (0 by default which means first in the list)
  55002. */
  55003. priority?: number);
  55004. }
  55005. /**
  55006. * Defines an optimization used to reduce the size of render target textures
  55007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55008. */
  55009. export class TextureOptimization extends SceneOptimization {
  55010. /**
  55011. * Defines the priority of this optimization (0 by default which means first in the list)
  55012. */
  55013. priority: number;
  55014. /**
  55015. * 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
  55016. */
  55017. maximumSize: number;
  55018. /**
  55019. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55020. */
  55021. step: number;
  55022. /**
  55023. * Gets a string describing the action executed by the current optimization
  55024. * @returns description string
  55025. */
  55026. getDescription(): string;
  55027. /**
  55028. * Creates the TextureOptimization object
  55029. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55030. * @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
  55031. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55032. */
  55033. constructor(
  55034. /**
  55035. * Defines the priority of this optimization (0 by default which means first in the list)
  55036. */
  55037. priority?: number,
  55038. /**
  55039. * 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
  55040. */
  55041. maximumSize?: number,
  55042. /**
  55043. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55044. */
  55045. step?: number);
  55046. /**
  55047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55048. * @param scene defines the current scene where to apply this optimization
  55049. * @param optimizer defines the current optimizer
  55050. * @returns true if everything that can be done was applied
  55051. */
  55052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55053. }
  55054. /**
  55055. * Defines an optimization used to increase or decrease the rendering resolution
  55056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55057. */
  55058. export class HardwareScalingOptimization extends SceneOptimization {
  55059. /**
  55060. * Defines the priority of this optimization (0 by default which means first in the list)
  55061. */
  55062. priority: number;
  55063. /**
  55064. * Defines the maximum scale to use (2 by default)
  55065. */
  55066. maximumScale: number;
  55067. /**
  55068. * Defines the step to use between two passes (0.5 by default)
  55069. */
  55070. step: number;
  55071. private _currentScale;
  55072. private _directionOffset;
  55073. /**
  55074. * Gets a string describing the action executed by the current optimization
  55075. * @return description string
  55076. */
  55077. getDescription(): string;
  55078. /**
  55079. * Creates the HardwareScalingOptimization object
  55080. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55081. * @param maximumScale defines the maximum scale to use (2 by default)
  55082. * @param step defines the step to use between two passes (0.5 by default)
  55083. */
  55084. constructor(
  55085. /**
  55086. * Defines the priority of this optimization (0 by default which means first in the list)
  55087. */
  55088. priority?: number,
  55089. /**
  55090. * Defines the maximum scale to use (2 by default)
  55091. */
  55092. maximumScale?: number,
  55093. /**
  55094. * Defines the step to use between two passes (0.5 by default)
  55095. */
  55096. step?: number);
  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. /**
  55106. * Defines an optimization used to remove shadows
  55107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55108. */
  55109. export class ShadowsOptimization extends SceneOptimization {
  55110. /**
  55111. * Gets a string describing the action executed by the current optimization
  55112. * @return description string
  55113. */
  55114. getDescription(): string;
  55115. /**
  55116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55117. * @param scene defines the current scene where to apply this optimization
  55118. * @param optimizer defines the current optimizer
  55119. * @returns true if everything that can be done was applied
  55120. */
  55121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55122. }
  55123. /**
  55124. * Defines an optimization used to turn post-processes off
  55125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55126. */
  55127. export class PostProcessesOptimization extends SceneOptimization {
  55128. /**
  55129. * Gets a string describing the action executed by the current optimization
  55130. * @return description string
  55131. */
  55132. getDescription(): string;
  55133. /**
  55134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55135. * @param scene defines the current scene where to apply this optimization
  55136. * @param optimizer defines the current optimizer
  55137. * @returns true if everything that can be done was applied
  55138. */
  55139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55140. }
  55141. /**
  55142. * Defines an optimization used to turn lens flares off
  55143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55144. */
  55145. export class LensFlaresOptimization extends SceneOptimization {
  55146. /**
  55147. * Gets a string describing the action executed by the current optimization
  55148. * @return description string
  55149. */
  55150. getDescription(): string;
  55151. /**
  55152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55153. * @param scene defines the current scene where to apply this optimization
  55154. * @param optimizer defines the current optimizer
  55155. * @returns true if everything that can be done was applied
  55156. */
  55157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55158. }
  55159. /**
  55160. * Defines an optimization based on user defined callback.
  55161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55162. */
  55163. export class CustomOptimization extends SceneOptimization {
  55164. /**
  55165. * Callback called to apply the custom optimization.
  55166. */
  55167. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55168. /**
  55169. * Callback called to get custom description
  55170. */
  55171. onGetDescription: () => string;
  55172. /**
  55173. * Gets a string describing the action executed by the current optimization
  55174. * @returns description string
  55175. */
  55176. getDescription(): string;
  55177. /**
  55178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55179. * @param scene defines the current scene where to apply this optimization
  55180. * @param optimizer defines the current optimizer
  55181. * @returns true if everything that can be done was applied
  55182. */
  55183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55184. }
  55185. /**
  55186. * Defines an optimization used to turn particles off
  55187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55188. */
  55189. export class ParticlesOptimization extends SceneOptimization {
  55190. /**
  55191. * Gets a string describing the action executed by the current optimization
  55192. * @return description string
  55193. */
  55194. getDescription(): string;
  55195. /**
  55196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55197. * @param scene defines the current scene where to apply this optimization
  55198. * @param optimizer defines the current optimizer
  55199. * @returns true if everything that can be done was applied
  55200. */
  55201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55202. }
  55203. /**
  55204. * Defines an optimization used to turn render targets off
  55205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55206. */
  55207. export class RenderTargetsOptimization extends SceneOptimization {
  55208. /**
  55209. * Gets a string describing the action executed by the current optimization
  55210. * @return description string
  55211. */
  55212. getDescription(): string;
  55213. /**
  55214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55215. * @param scene defines the current scene where to apply this optimization
  55216. * @param optimizer defines the current optimizer
  55217. * @returns true if everything that can be done was applied
  55218. */
  55219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55220. }
  55221. /**
  55222. * Defines an optimization used to merge meshes with compatible materials
  55223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55224. */
  55225. export class MergeMeshesOptimization extends SceneOptimization {
  55226. private static _UpdateSelectionTree;
  55227. /**
  55228. * Gets or sets a boolean which defines if optimization octree has to be updated
  55229. */
  55230. /**
  55231. * Gets or sets a boolean which defines if optimization octree has to be updated
  55232. */
  55233. static UpdateSelectionTree: boolean;
  55234. /**
  55235. * Gets a string describing the action executed by the current optimization
  55236. * @return description string
  55237. */
  55238. getDescription(): string;
  55239. private _canBeMerged;
  55240. /**
  55241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55242. * @param scene defines the current scene where to apply this optimization
  55243. * @param optimizer defines the current optimizer
  55244. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55245. * @returns true if everything that can be done was applied
  55246. */
  55247. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55248. }
  55249. /**
  55250. * Defines a list of options used by SceneOptimizer
  55251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55252. */
  55253. export class SceneOptimizerOptions {
  55254. /**
  55255. * Defines the target frame rate to reach (60 by default)
  55256. */
  55257. targetFrameRate: number;
  55258. /**
  55259. * Defines the interval between two checkes (2000ms by default)
  55260. */
  55261. trackerDuration: number;
  55262. /**
  55263. * Gets the list of optimizations to apply
  55264. */
  55265. optimizations: SceneOptimization[];
  55266. /**
  55267. * Creates a new list of options used by SceneOptimizer
  55268. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55269. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55270. */
  55271. constructor(
  55272. /**
  55273. * Defines the target frame rate to reach (60 by default)
  55274. */
  55275. targetFrameRate?: number,
  55276. /**
  55277. * Defines the interval between two checkes (2000ms by default)
  55278. */
  55279. trackerDuration?: number);
  55280. /**
  55281. * Add a new optimization
  55282. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55283. * @returns the current SceneOptimizerOptions
  55284. */
  55285. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55286. /**
  55287. * Add a new custom optimization
  55288. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55289. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55290. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55291. * @returns the current SceneOptimizerOptions
  55292. */
  55293. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55294. /**
  55295. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55296. * @param targetFrameRate defines the target frame rate (60 by default)
  55297. * @returns a SceneOptimizerOptions object
  55298. */
  55299. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55300. /**
  55301. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55302. * @param targetFrameRate defines the target frame rate (60 by default)
  55303. * @returns a SceneOptimizerOptions object
  55304. */
  55305. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55306. /**
  55307. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55308. * @param targetFrameRate defines the target frame rate (60 by default)
  55309. * @returns a SceneOptimizerOptions object
  55310. */
  55311. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55312. }
  55313. /**
  55314. * Class used to run optimizations in order to reach a target frame rate
  55315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55316. */
  55317. export class SceneOptimizer implements IDisposable {
  55318. private _isRunning;
  55319. private _options;
  55320. private _scene;
  55321. private _currentPriorityLevel;
  55322. private _targetFrameRate;
  55323. private _trackerDuration;
  55324. private _currentFrameRate;
  55325. private _sceneDisposeObserver;
  55326. private _improvementMode;
  55327. /**
  55328. * Defines an observable called when the optimizer reaches the target frame rate
  55329. */
  55330. onSuccessObservable: Observable<SceneOptimizer>;
  55331. /**
  55332. * Defines an observable called when the optimizer enables an optimization
  55333. */
  55334. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55335. /**
  55336. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55337. */
  55338. onFailureObservable: Observable<SceneOptimizer>;
  55339. /**
  55340. * Gets a boolean indicating if the optimizer is in improvement mode
  55341. */
  55342. readonly isInImprovementMode: boolean;
  55343. /**
  55344. * Gets the current priority level (0 at start)
  55345. */
  55346. readonly currentPriorityLevel: number;
  55347. /**
  55348. * Gets the current frame rate checked by the SceneOptimizer
  55349. */
  55350. readonly currentFrameRate: number;
  55351. /**
  55352. * Gets or sets the current target frame rate (60 by default)
  55353. */
  55354. /**
  55355. * Gets or sets the current target frame rate (60 by default)
  55356. */
  55357. targetFrameRate: number;
  55358. /**
  55359. * Gets or sets the current interval between two checks (every 2000ms by default)
  55360. */
  55361. /**
  55362. * Gets or sets the current interval between two checks (every 2000ms by default)
  55363. */
  55364. trackerDuration: number;
  55365. /**
  55366. * Gets the list of active optimizations
  55367. */
  55368. readonly optimizations: SceneOptimization[];
  55369. /**
  55370. * Creates a new SceneOptimizer
  55371. * @param scene defines the scene to work on
  55372. * @param options defines the options to use with the SceneOptimizer
  55373. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55374. * @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)
  55375. */
  55376. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55377. /**
  55378. * Stops the current optimizer
  55379. */
  55380. stop(): void;
  55381. /**
  55382. * Reset the optimizer to initial step (current priority level = 0)
  55383. */
  55384. reset(): void;
  55385. /**
  55386. * Start the optimizer. By default it will try to reach a specific framerate
  55387. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55388. */
  55389. start(): void;
  55390. private _checkCurrentState;
  55391. /**
  55392. * Release all resources
  55393. */
  55394. dispose(): void;
  55395. /**
  55396. * Helper function to create a SceneOptimizer with one single line of code
  55397. * @param scene defines the scene to work on
  55398. * @param options defines the options to use with the SceneOptimizer
  55399. * @param onSuccess defines a callback to call on success
  55400. * @param onFailure defines a callback to call on failure
  55401. * @returns the new SceneOptimizer object
  55402. */
  55403. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55404. }
  55405. }
  55406. declare module BABYLON {
  55407. /**
  55408. * Class used to serialize a scene into a string
  55409. */
  55410. export class SceneSerializer {
  55411. /**
  55412. * Clear cache used by a previous serialization
  55413. */
  55414. static ClearCache(): void;
  55415. /**
  55416. * Serialize a scene into a JSON compatible object
  55417. * @param scene defines the scene to serialize
  55418. * @returns a JSON compatible object
  55419. */
  55420. static Serialize(scene: Scene): any;
  55421. /**
  55422. * Serialize a mesh into a JSON compatible object
  55423. * @param toSerialize defines the mesh to serialize
  55424. * @param withParents defines if parents must be serialized as well
  55425. * @param withChildren defines if children must be serialized as well
  55426. * @returns a JSON compatible object
  55427. */
  55428. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55429. }
  55430. }
  55431. declare module BABYLON {
  55432. /**
  55433. * Class used to host texture specific utilities
  55434. */
  55435. export class TextureTools {
  55436. /**
  55437. * Uses the GPU to create a copy texture rescaled at a given size
  55438. * @param texture Texture to copy from
  55439. * @param width defines the desired width
  55440. * @param height defines the desired height
  55441. * @param useBilinearMode defines if bilinear mode has to be used
  55442. * @return the generated texture
  55443. */
  55444. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55445. }
  55446. }
  55447. declare module BABYLON {
  55448. /**
  55449. * This represents the different options avilable for the video capture.
  55450. */
  55451. export interface VideoRecorderOptions {
  55452. /** Defines the mime type of the video */
  55453. mimeType: string;
  55454. /** Defines the video the video should be recorded at */
  55455. fps: number;
  55456. /** Defines the chunk size for the recording data */
  55457. recordChunckSize: number;
  55458. /** The audio tracks to attach to the record */
  55459. audioTracks?: MediaStreamTrack[];
  55460. }
  55461. /**
  55462. * This can helps recording videos from BabylonJS.
  55463. * This is based on the available WebRTC functionalities of the browser.
  55464. *
  55465. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55466. */
  55467. export class VideoRecorder {
  55468. private static readonly _defaultOptions;
  55469. /**
  55470. * Returns wehther or not the VideoRecorder is available in your browser.
  55471. * @param engine Defines the Babylon Engine to check the support for
  55472. * @returns true if supported otherwise false
  55473. */
  55474. static IsSupported(engine: Engine): boolean;
  55475. private readonly _options;
  55476. private _canvas;
  55477. private _mediaRecorder;
  55478. private _recordedChunks;
  55479. private _fileName;
  55480. private _resolve;
  55481. private _reject;
  55482. /**
  55483. * True wether a recording is already in progress.
  55484. */
  55485. readonly isRecording: boolean;
  55486. /**
  55487. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55488. * a video file.
  55489. * @param engine Defines the BabylonJS Engine you wish to record
  55490. * @param options Defines options that can be used to customized the capture
  55491. */
  55492. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55493. /**
  55494. * Stops the current recording before the default capture timeout passed in the startRecording
  55495. * functions.
  55496. */
  55497. stopRecording(): void;
  55498. /**
  55499. * Starts recording the canvas for a max duration specified in parameters.
  55500. * @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.
  55501. * @param maxDuration Defines the maximum recording time in seconds.
  55502. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55503. * @return a promise callback at the end of the recording with the video data in Blob.
  55504. */
  55505. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55506. /**
  55507. * Releases internal resources used during the recording.
  55508. */
  55509. dispose(): void;
  55510. private _handleDataAvailable;
  55511. private _handleError;
  55512. private _handleStop;
  55513. }
  55514. }
  55515. declare module BABYLON {
  55516. /**
  55517. * Class containing a set of static utilities functions for screenshots
  55518. */
  55519. export class ScreenshotTools {
  55520. /**
  55521. * Captures a screenshot of the current rendering
  55522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55523. * @param engine defines the rendering engine
  55524. * @param camera defines the source camera
  55525. * @param size This parameter can be set to a single number or to an object with the
  55526. * following (optional) properties: precision, width, height. If a single number is passed,
  55527. * it will be used for both width and height. If an object is passed, the screenshot size
  55528. * will be derived from the parameters. The precision property is a multiplier allowing
  55529. * rendering at a higher or lower resolution
  55530. * @param successCallback defines the callback receives a single parameter which contains the
  55531. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55532. * src parameter of an <img> to display it
  55533. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55534. * Check your browser for supported MIME types
  55535. */
  55536. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55537. /**
  55538. * Generates an image screenshot from the specified camera.
  55539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55540. * @param engine The engine to use for rendering
  55541. * @param camera The camera to use for rendering
  55542. * @param size This parameter can be set to a single number or to an object with the
  55543. * following (optional) properties: precision, width, height. If a single number is passed,
  55544. * it will be used for both width and height. If an object is passed, the screenshot size
  55545. * will be derived from the parameters. The precision property is a multiplier allowing
  55546. * rendering at a higher or lower resolution
  55547. * @param successCallback The callback receives a single parameter which contains the
  55548. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55549. * src parameter of an <img> to display it
  55550. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55551. * Check your browser for supported MIME types
  55552. * @param samples Texture samples (default: 1)
  55553. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55554. * @param fileName A name for for the downloaded file.
  55555. */
  55556. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /**
  55561. * A cursor which tracks a point on a path
  55562. */
  55563. export class PathCursor {
  55564. private path;
  55565. /**
  55566. * Stores path cursor callbacks for when an onchange event is triggered
  55567. */
  55568. private _onchange;
  55569. /**
  55570. * The value of the path cursor
  55571. */
  55572. value: number;
  55573. /**
  55574. * The animation array of the path cursor
  55575. */
  55576. animations: Animation[];
  55577. /**
  55578. * Initializes the path cursor
  55579. * @param path The path to track
  55580. */
  55581. constructor(path: Path2);
  55582. /**
  55583. * Gets the cursor point on the path
  55584. * @returns A point on the path cursor at the cursor location
  55585. */
  55586. getPoint(): Vector3;
  55587. /**
  55588. * Moves the cursor ahead by the step amount
  55589. * @param step The amount to move the cursor forward
  55590. * @returns This path cursor
  55591. */
  55592. moveAhead(step?: number): PathCursor;
  55593. /**
  55594. * Moves the cursor behind by the step amount
  55595. * @param step The amount to move the cursor back
  55596. * @returns This path cursor
  55597. */
  55598. moveBack(step?: number): PathCursor;
  55599. /**
  55600. * Moves the cursor by the step amount
  55601. * If the step amount is greater than one, an exception is thrown
  55602. * @param step The amount to move the cursor
  55603. * @returns This path cursor
  55604. */
  55605. move(step: number): PathCursor;
  55606. /**
  55607. * Ensures that the value is limited between zero and one
  55608. * @returns This path cursor
  55609. */
  55610. private ensureLimits;
  55611. /**
  55612. * Runs onchange callbacks on change (used by the animation engine)
  55613. * @returns This path cursor
  55614. */
  55615. private raiseOnChange;
  55616. /**
  55617. * Executes a function on change
  55618. * @param f A path cursor onchange callback
  55619. * @returns This path cursor
  55620. */
  55621. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55622. }
  55623. }
  55624. declare module BABYLON {
  55625. /** @hidden */
  55626. export var blurPixelShader: {
  55627. name: string;
  55628. shader: string;
  55629. };
  55630. }
  55631. declare module BABYLON {
  55632. /** @hidden */
  55633. export var bones300Declaration: {
  55634. name: string;
  55635. shader: string;
  55636. };
  55637. }
  55638. declare module BABYLON {
  55639. /** @hidden */
  55640. export var instances300Declaration: {
  55641. name: string;
  55642. shader: string;
  55643. };
  55644. }
  55645. declare module BABYLON {
  55646. /** @hidden */
  55647. export var pointCloudVertexDeclaration: {
  55648. name: string;
  55649. shader: string;
  55650. };
  55651. }
  55652. // Mixins
  55653. interface Window {
  55654. mozIndexedDB: IDBFactory;
  55655. webkitIndexedDB: IDBFactory;
  55656. msIndexedDB: IDBFactory;
  55657. webkitURL: typeof URL;
  55658. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55659. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55660. WebGLRenderingContext: WebGLRenderingContext;
  55661. MSGesture: MSGesture;
  55662. CANNON: any;
  55663. AudioContext: AudioContext;
  55664. webkitAudioContext: AudioContext;
  55665. PointerEvent: any;
  55666. Math: Math;
  55667. Uint8Array: Uint8ArrayConstructor;
  55668. Float32Array: Float32ArrayConstructor;
  55669. mozURL: typeof URL;
  55670. msURL: typeof URL;
  55671. VRFrameData: any; // WebVR, from specs 1.1
  55672. DracoDecoderModule: any;
  55673. setImmediate(handler: (...args: any[]) => void): number;
  55674. }
  55675. interface HTMLCanvasElement {
  55676. requestPointerLock(): void;
  55677. msRequestPointerLock?(): void;
  55678. mozRequestPointerLock?(): void;
  55679. webkitRequestPointerLock?(): void;
  55680. /** Track wether a record is in progress */
  55681. isRecording: boolean;
  55682. /** Capture Stream method defined by some browsers */
  55683. captureStream(fps?: number): MediaStream;
  55684. }
  55685. interface CanvasRenderingContext2D {
  55686. msImageSmoothingEnabled: boolean;
  55687. }
  55688. interface MouseEvent {
  55689. mozMovementX: number;
  55690. mozMovementY: number;
  55691. webkitMovementX: number;
  55692. webkitMovementY: number;
  55693. msMovementX: number;
  55694. msMovementY: number;
  55695. }
  55696. interface Navigator {
  55697. mozGetVRDevices: (any: any) => any;
  55698. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55699. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55700. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55701. webkitGetGamepads(): Gamepad[];
  55702. msGetGamepads(): Gamepad[];
  55703. webkitGamepads(): Gamepad[];
  55704. }
  55705. interface HTMLVideoElement {
  55706. mozSrcObject: any;
  55707. }
  55708. interface Math {
  55709. fround(x: number): number;
  55710. imul(a: number, b: number): number;
  55711. }
  55712. interface WebGLRenderingContext {
  55713. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55714. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55715. vertexAttribDivisor(index: number, divisor: number): void;
  55716. createVertexArray(): any;
  55717. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55718. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55719. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55720. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55721. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55722. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55723. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55724. // Queries
  55725. createQuery(): WebGLQuery;
  55726. deleteQuery(query: WebGLQuery): void;
  55727. beginQuery(target: number, query: WebGLQuery): void;
  55728. endQuery(target: number): void;
  55729. getQueryParameter(query: WebGLQuery, pname: number): any;
  55730. getQuery(target: number, pname: number): any;
  55731. MAX_SAMPLES: number;
  55732. RGBA8: number;
  55733. READ_FRAMEBUFFER: number;
  55734. DRAW_FRAMEBUFFER: number;
  55735. UNIFORM_BUFFER: number;
  55736. HALF_FLOAT_OES: number;
  55737. RGBA16F: number;
  55738. RGBA32F: number;
  55739. R32F: number;
  55740. RG32F: number;
  55741. RGB32F: number;
  55742. R16F: number;
  55743. RG16F: number;
  55744. RGB16F: number;
  55745. RED: number;
  55746. RG: number;
  55747. R8: number;
  55748. RG8: number;
  55749. UNSIGNED_INT_24_8: number;
  55750. DEPTH24_STENCIL8: number;
  55751. /* Multiple Render Targets */
  55752. drawBuffers(buffers: number[]): void;
  55753. readBuffer(src: number): void;
  55754. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55755. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55756. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55757. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55758. // Occlusion Query
  55759. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55760. ANY_SAMPLES_PASSED: number;
  55761. QUERY_RESULT_AVAILABLE: number;
  55762. QUERY_RESULT: number;
  55763. }
  55764. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55765. }
  55766. interface EXT_disjoint_timer_query {
  55767. QUERY_COUNTER_BITS_EXT: number;
  55768. TIME_ELAPSED_EXT: number;
  55769. TIMESTAMP_EXT: number;
  55770. GPU_DISJOINT_EXT: number;
  55771. QUERY_RESULT_EXT: number;
  55772. QUERY_RESULT_AVAILABLE_EXT: number;
  55773. queryCounterEXT(query: WebGLQuery, target: number): void;
  55774. createQueryEXT(): WebGLQuery;
  55775. beginQueryEXT(target: number, query: WebGLQuery): void;
  55776. endQueryEXT(target: number): void;
  55777. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55778. deleteQueryEXT(query: WebGLQuery): void;
  55779. }
  55780. interface WebGLUniformLocation { currentState: any;
  55781. }
  55782. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55783. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55784. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55785. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55786. interface WebGLRenderingContext {
  55787. readonly RASTERIZER_DISCARD: number;
  55788. readonly DEPTH_COMPONENT24: number;
  55789. readonly TEXTURE_3D: number;
  55790. readonly TEXTURE_2D_ARRAY: number;
  55791. readonly TEXTURE_COMPARE_FUNC: number;
  55792. readonly TEXTURE_COMPARE_MODE: number;
  55793. readonly COMPARE_REF_TO_TEXTURE: number;
  55794. readonly TEXTURE_WRAP_R: number;
  55795. readonly HALF_FLOAT: number;
  55796. readonly RGB8: number;
  55797. readonly RED_INTEGER: number;
  55798. readonly RG_INTEGER: number;
  55799. readonly RGB_INTEGER: number;
  55800. readonly RGBA_INTEGER: number;
  55801. readonly R8_SNORM: number;
  55802. readonly RG8_SNORM: number;
  55803. readonly RGB8_SNORM: number;
  55804. readonly RGBA8_SNORM: number;
  55805. readonly R8I: number;
  55806. readonly RG8I: number;
  55807. readonly RGB8I: number;
  55808. readonly RGBA8I: number;
  55809. readonly R8UI: number;
  55810. readonly RG8UI: number;
  55811. readonly RGB8UI: number;
  55812. readonly RGBA8UI: number;
  55813. readonly R16I: number;
  55814. readonly RG16I: number;
  55815. readonly RGB16I: number;
  55816. readonly RGBA16I: number;
  55817. readonly R16UI: number;
  55818. readonly RG16UI: number;
  55819. readonly RGB16UI: number;
  55820. readonly RGBA16UI: number;
  55821. readonly R32I: number;
  55822. readonly RG32I: number;
  55823. readonly RGB32I: number;
  55824. readonly RGBA32I: number;
  55825. readonly R32UI: number;
  55826. readonly RG32UI: number;
  55827. readonly RGB32UI: number;
  55828. readonly RGBA32UI: number;
  55829. readonly RGB10_A2UI: number;
  55830. readonly R11F_G11F_B10F: number;
  55831. readonly RGB9_E5: number;
  55832. readonly RGB10_A2: number;
  55833. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55834. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55835. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55836. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55837. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55838. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55839. 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;
  55840. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55841. readonly TRANSFORM_FEEDBACK: number;
  55842. readonly INTERLEAVED_ATTRIBS: number;
  55843. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55844. createTransformFeedback(): WebGLTransformFeedback;
  55845. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55846. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55847. beginTransformFeedback(primitiveMode: number): void;
  55848. endTransformFeedback(): void;
  55849. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55850. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55851. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55852. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55853. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55854. }
  55855. interface ImageBitmap {
  55856. readonly width: number;
  55857. readonly height: number;
  55858. close(): void;
  55859. }
  55860. interface WebGLQuery extends WebGLObject {
  55861. }
  55862. declare var WebGLQuery: {
  55863. prototype: WebGLQuery;
  55864. new(): WebGLQuery;
  55865. };
  55866. interface WebGLSampler extends WebGLObject {
  55867. }
  55868. declare var WebGLSampler: {
  55869. prototype: WebGLSampler;
  55870. new(): WebGLSampler;
  55871. };
  55872. interface WebGLSync extends WebGLObject {
  55873. }
  55874. declare var WebGLSync: {
  55875. prototype: WebGLSync;
  55876. new(): WebGLSync;
  55877. };
  55878. interface WebGLTransformFeedback extends WebGLObject {
  55879. }
  55880. declare var WebGLTransformFeedback: {
  55881. prototype: WebGLTransformFeedback;
  55882. new(): WebGLTransformFeedback;
  55883. };
  55884. interface WebGLVertexArrayObject extends WebGLObject {
  55885. }
  55886. declare var WebGLVertexArrayObject: {
  55887. prototype: WebGLVertexArrayObject;
  55888. new(): WebGLVertexArrayObject;
  55889. };
  55890. // Type definitions for WebVR API
  55891. // Project: https://w3c.github.io/webvr/
  55892. // Definitions by: six a <https://github.com/lostfictions>
  55893. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55894. interface VRDisplay extends EventTarget {
  55895. /**
  55896. * Dictionary of capabilities describing the VRDisplay.
  55897. */
  55898. readonly capabilities: VRDisplayCapabilities;
  55899. /**
  55900. * z-depth defining the far plane of the eye view frustum
  55901. * enables mapping of values in the render target depth
  55902. * attachment to scene coordinates. Initially set to 10000.0.
  55903. */
  55904. depthFar: number;
  55905. /**
  55906. * z-depth defining the near plane of the eye view frustum
  55907. * enables mapping of values in the render target depth
  55908. * attachment to scene coordinates. Initially set to 0.01.
  55909. */
  55910. depthNear: number;
  55911. /**
  55912. * An identifier for this distinct VRDisplay. Used as an
  55913. * association point in the Gamepad API.
  55914. */
  55915. readonly displayId: number;
  55916. /**
  55917. * A display name, a user-readable name identifying it.
  55918. */
  55919. readonly displayName: string;
  55920. readonly isConnected: boolean;
  55921. readonly isPresenting: boolean;
  55922. /**
  55923. * If this VRDisplay supports room-scale experiences, the optional
  55924. * stage attribute contains details on the room-scale parameters.
  55925. */
  55926. readonly stageParameters: VRStageParameters | null;
  55927. /**
  55928. * Passing the value returned by `requestAnimationFrame` to
  55929. * `cancelAnimationFrame` will unregister the callback.
  55930. * @param handle Define the hanle of the request to cancel
  55931. */
  55932. cancelAnimationFrame(handle: number): void;
  55933. /**
  55934. * Stops presenting to the VRDisplay.
  55935. * @returns a promise to know when it stopped
  55936. */
  55937. exitPresent(): Promise<void>;
  55938. /**
  55939. * Return the current VREyeParameters for the given eye.
  55940. * @param whichEye Define the eye we want the parameter for
  55941. * @returns the eye parameters
  55942. */
  55943. getEyeParameters(whichEye: string): VREyeParameters;
  55944. /**
  55945. * Populates the passed VRFrameData with the information required to render
  55946. * the current frame.
  55947. * @param frameData Define the data structure to populate
  55948. * @returns true if ok otherwise false
  55949. */
  55950. getFrameData(frameData: VRFrameData): boolean;
  55951. /**
  55952. * Get the layers currently being presented.
  55953. * @returns the list of VR layers
  55954. */
  55955. getLayers(): VRLayer[];
  55956. /**
  55957. * Return a VRPose containing the future predicted pose of the VRDisplay
  55958. * when the current frame will be presented. The value returned will not
  55959. * change until JavaScript has returned control to the browser.
  55960. *
  55961. * The VRPose will contain the position, orientation, velocity,
  55962. * and acceleration of each of these properties.
  55963. * @returns the pose object
  55964. */
  55965. getPose(): VRPose;
  55966. /**
  55967. * Return the current instantaneous pose of the VRDisplay, with no
  55968. * prediction applied.
  55969. * @returns the current instantaneous pose
  55970. */
  55971. getImmediatePose(): VRPose;
  55972. /**
  55973. * The callback passed to `requestAnimationFrame` will be called
  55974. * any time a new frame should be rendered. When the VRDisplay is
  55975. * presenting the callback will be called at the native refresh
  55976. * rate of the HMD. When not presenting this function acts
  55977. * identically to how window.requestAnimationFrame acts. Content should
  55978. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55979. * asynchronously from other displays and at differing refresh rates.
  55980. * @param callback Define the eaction to run next frame
  55981. * @returns the request handle it
  55982. */
  55983. requestAnimationFrame(callback: FrameRequestCallback): number;
  55984. /**
  55985. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55986. * Repeat calls while already presenting will update the VRLayers being displayed.
  55987. * @param layers Define the list of layer to present
  55988. * @returns a promise to know when the request has been fulfilled
  55989. */
  55990. requestPresent(layers: VRLayer[]): Promise<void>;
  55991. /**
  55992. * Reset the pose for this display, treating its current position and
  55993. * orientation as the "origin/zero" values. VRPose.position,
  55994. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55995. * updated when calling resetPose(). This should be called in only
  55996. * sitting-space experiences.
  55997. */
  55998. resetPose(): void;
  55999. /**
  56000. * The VRLayer provided to the VRDisplay will be captured and presented
  56001. * in the HMD. Calling this function has the same effect on the source
  56002. * canvas as any other operation that uses its source image, and canvases
  56003. * created without preserveDrawingBuffer set to true will be cleared.
  56004. * @param pose Define the pose to submit
  56005. */
  56006. submitFrame(pose?: VRPose): void;
  56007. }
  56008. declare var VRDisplay: {
  56009. prototype: VRDisplay;
  56010. new(): VRDisplay;
  56011. };
  56012. interface VRLayer {
  56013. leftBounds?: number[] | Float32Array | null;
  56014. rightBounds?: number[] | Float32Array | null;
  56015. source?: HTMLCanvasElement | null;
  56016. }
  56017. interface VRDisplayCapabilities {
  56018. readonly canPresent: boolean;
  56019. readonly hasExternalDisplay: boolean;
  56020. readonly hasOrientation: boolean;
  56021. readonly hasPosition: boolean;
  56022. readonly maxLayers: number;
  56023. }
  56024. interface VREyeParameters {
  56025. /** @deprecated */
  56026. readonly fieldOfView: VRFieldOfView;
  56027. readonly offset: Float32Array;
  56028. readonly renderHeight: number;
  56029. readonly renderWidth: number;
  56030. }
  56031. interface VRFieldOfView {
  56032. readonly downDegrees: number;
  56033. readonly leftDegrees: number;
  56034. readonly rightDegrees: number;
  56035. readonly upDegrees: number;
  56036. }
  56037. interface VRFrameData {
  56038. readonly leftProjectionMatrix: Float32Array;
  56039. readonly leftViewMatrix: Float32Array;
  56040. readonly pose: VRPose;
  56041. readonly rightProjectionMatrix: Float32Array;
  56042. readonly rightViewMatrix: Float32Array;
  56043. readonly timestamp: number;
  56044. }
  56045. interface VRPose {
  56046. readonly angularAcceleration: Float32Array | null;
  56047. readonly angularVelocity: Float32Array | null;
  56048. readonly linearAcceleration: Float32Array | null;
  56049. readonly linearVelocity: Float32Array | null;
  56050. readonly orientation: Float32Array | null;
  56051. readonly position: Float32Array | null;
  56052. readonly timestamp: number;
  56053. }
  56054. interface VRStageParameters {
  56055. sittingToStandingTransform?: Float32Array;
  56056. sizeX?: number;
  56057. sizeY?: number;
  56058. }
  56059. interface Navigator {
  56060. getVRDisplays(): Promise<VRDisplay[]>;
  56061. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56062. }
  56063. interface Window {
  56064. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56065. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56066. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56067. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56068. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56069. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56070. }
  56071. interface Gamepad {
  56072. readonly displayId: number;
  56073. }
  56074. interface XRDevice {
  56075. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56076. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56077. }
  56078. interface XRSession {
  56079. getInputSources(): Array<any>;
  56080. baseLayer: XRWebGLLayer;
  56081. requestFrameOfReference(type: string): Promise<void>;
  56082. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56083. end(): Promise<void>;
  56084. requestAnimationFrame: Function;
  56085. addEventListener: Function;
  56086. }
  56087. interface XRSessionCreationOptions {
  56088. outputContext?: WebGLRenderingContext | null;
  56089. immersive?: boolean;
  56090. environmentIntegration?: boolean;
  56091. }
  56092. interface XRLayer {
  56093. getViewport: Function;
  56094. framebufferWidth: number;
  56095. framebufferHeight: number;
  56096. }
  56097. interface XRView {
  56098. projectionMatrix: Float32Array;
  56099. }
  56100. interface XRFrame {
  56101. getDevicePose: Function;
  56102. getInputPose: Function;
  56103. views: Array<XRView>;
  56104. baseLayer: XRLayer;
  56105. }
  56106. interface XRFrameOfReference {
  56107. }
  56108. interface XRWebGLLayer extends XRLayer {
  56109. framebuffer: WebGLFramebuffer;
  56110. }
  56111. declare var XRWebGLLayer: {
  56112. prototype: XRWebGLLayer;
  56113. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56114. };
  56115. declare module BABYLON.GUI {
  56116. /**
  56117. * Class used to specific a value and its associated unit
  56118. */
  56119. export class ValueAndUnit {
  56120. /** defines the unit to store */
  56121. unit: number;
  56122. /** defines a boolean indicating if the value can be negative */
  56123. negativeValueAllowed: boolean;
  56124. private _value;
  56125. private _originalUnit;
  56126. /**
  56127. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56128. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56129. */
  56130. ignoreAdaptiveScaling: boolean;
  56131. /**
  56132. * Creates a new ValueAndUnit
  56133. * @param value defines the value to store
  56134. * @param unit defines the unit to store
  56135. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56136. */
  56137. constructor(value: number,
  56138. /** defines the unit to store */
  56139. unit?: number,
  56140. /** defines a boolean indicating if the value can be negative */
  56141. negativeValueAllowed?: boolean);
  56142. /** Gets a boolean indicating if the value is a percentage */
  56143. readonly isPercentage: boolean;
  56144. /** Gets a boolean indicating if the value is store as pixel */
  56145. readonly isPixel: boolean;
  56146. /** Gets direct internal value */
  56147. readonly internalValue: number;
  56148. /**
  56149. * Gets value as pixel
  56150. * @param host defines the root host
  56151. * @param refValue defines the reference value for percentages
  56152. * @returns the value as pixel
  56153. */
  56154. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56155. /**
  56156. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56157. * @param value defines the value to store
  56158. * @param unit defines the unit to store
  56159. * @returns the current ValueAndUnit
  56160. */
  56161. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56162. /**
  56163. * Gets the value accordingly to its unit
  56164. * @param host defines the root host
  56165. * @returns the value
  56166. */
  56167. getValue(host: AdvancedDynamicTexture): number;
  56168. /**
  56169. * Gets a string representation of the value
  56170. * @param host defines the root host
  56171. * @param decimals defines an optional number of decimals to display
  56172. * @returns a string
  56173. */
  56174. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56175. /**
  56176. * Store a value parsed from a string
  56177. * @param source defines the source string
  56178. * @returns true if the value was successfully parsed
  56179. */
  56180. fromString(source: string | number): boolean;
  56181. private static _Regex;
  56182. private static _UNITMODE_PERCENTAGE;
  56183. private static _UNITMODE_PIXEL;
  56184. /** UNITMODE_PERCENTAGE */
  56185. static readonly UNITMODE_PERCENTAGE: number;
  56186. /** UNITMODE_PIXEL */
  56187. static readonly UNITMODE_PIXEL: number;
  56188. }
  56189. }
  56190. declare module BABYLON.GUI {
  56191. /**
  56192. * Define a style used by control to automatically setup properties based on a template.
  56193. * Only support font related properties so far
  56194. */
  56195. export class Style implements BABYLON.IDisposable {
  56196. private _fontFamily;
  56197. private _fontStyle;
  56198. private _fontWeight;
  56199. /** @hidden */ host: AdvancedDynamicTexture;
  56200. /** @hidden */ fontSize: ValueAndUnit;
  56201. /**
  56202. * BABYLON.Observable raised when the style values are changed
  56203. */
  56204. onChangedObservable: BABYLON.Observable<Style>;
  56205. /**
  56206. * Creates a new style object
  56207. * @param host defines the AdvancedDynamicTexture which hosts this style
  56208. */
  56209. constructor(host: AdvancedDynamicTexture);
  56210. /**
  56211. * Gets or sets the font size
  56212. */
  56213. fontSize: string | number;
  56214. /**
  56215. * Gets or sets the font family
  56216. */
  56217. fontFamily: string;
  56218. /**
  56219. * Gets or sets the font style
  56220. */
  56221. fontStyle: string;
  56222. /** Gets or sets font weight */
  56223. fontWeight: string;
  56224. /** Dispose all associated resources */
  56225. dispose(): void;
  56226. }
  56227. }
  56228. declare module BABYLON.GUI {
  56229. /**
  56230. * Class used to transport BABYLON.Vector2 information for pointer events
  56231. */
  56232. export class Vector2WithInfo extends BABYLON.Vector2 {
  56233. /** defines the current mouse button index */
  56234. buttonIndex: number;
  56235. /**
  56236. * Creates a new Vector2WithInfo
  56237. * @param source defines the vector2 data to transport
  56238. * @param buttonIndex defines the current mouse button index
  56239. */
  56240. constructor(source: BABYLON.Vector2,
  56241. /** defines the current mouse button index */
  56242. buttonIndex?: number);
  56243. }
  56244. /** Class used to provide 2D matrix features */
  56245. export class Matrix2D {
  56246. /** Gets the internal array of 6 floats used to store matrix data */
  56247. m: Float32Array;
  56248. /**
  56249. * Creates a new matrix
  56250. * @param m00 defines value for (0, 0)
  56251. * @param m01 defines value for (0, 1)
  56252. * @param m10 defines value for (1, 0)
  56253. * @param m11 defines value for (1, 1)
  56254. * @param m20 defines value for (2, 0)
  56255. * @param m21 defines value for (2, 1)
  56256. */
  56257. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56258. /**
  56259. * Fills the matrix from direct values
  56260. * @param m00 defines value for (0, 0)
  56261. * @param m01 defines value for (0, 1)
  56262. * @param m10 defines value for (1, 0)
  56263. * @param m11 defines value for (1, 1)
  56264. * @param m20 defines value for (2, 0)
  56265. * @param m21 defines value for (2, 1)
  56266. * @returns the current modified matrix
  56267. */
  56268. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56269. /**
  56270. * Gets matrix determinant
  56271. * @returns the determinant
  56272. */
  56273. determinant(): number;
  56274. /**
  56275. * Inverses the matrix and stores it in a target matrix
  56276. * @param result defines the target matrix
  56277. * @returns the current matrix
  56278. */
  56279. invertToRef(result: Matrix2D): Matrix2D;
  56280. /**
  56281. * Multiplies the current matrix with another one
  56282. * @param other defines the second operand
  56283. * @param result defines the target matrix
  56284. * @returns the current matrix
  56285. */
  56286. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56287. /**
  56288. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56289. * @param x defines the x coordinate to transform
  56290. * @param y defines the x coordinate to transform
  56291. * @param result defines the target vector2
  56292. * @returns the current matrix
  56293. */
  56294. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56295. /**
  56296. * Creates an identity matrix
  56297. * @returns a new matrix
  56298. */
  56299. static Identity(): Matrix2D;
  56300. /**
  56301. * Creates a translation matrix and stores it in a target matrix
  56302. * @param x defines the x coordinate of the translation
  56303. * @param y defines the y coordinate of the translation
  56304. * @param result defines the target matrix
  56305. */
  56306. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56307. /**
  56308. * Creates a scaling matrix and stores it in a target matrix
  56309. * @param x defines the x coordinate of the scaling
  56310. * @param y defines the y coordinate of the scaling
  56311. * @param result defines the target matrix
  56312. */
  56313. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56314. /**
  56315. * Creates a rotation matrix and stores it in a target matrix
  56316. * @param angle defines the rotation angle
  56317. * @param result defines the target matrix
  56318. */
  56319. static RotationToRef(angle: number, result: Matrix2D): void;
  56320. private static _TempPreTranslationMatrix;
  56321. private static _TempPostTranslationMatrix;
  56322. private static _TempRotationMatrix;
  56323. private static _TempScalingMatrix;
  56324. private static _TempCompose0;
  56325. private static _TempCompose1;
  56326. private static _TempCompose2;
  56327. /**
  56328. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56329. * @param tx defines the x coordinate of the translation
  56330. * @param ty defines the y coordinate of the translation
  56331. * @param angle defines the rotation angle
  56332. * @param scaleX defines the x coordinate of the scaling
  56333. * @param scaleY defines the y coordinate of the scaling
  56334. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56335. * @param result defines the target matrix
  56336. */
  56337. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56338. }
  56339. }
  56340. declare module BABYLON.GUI {
  56341. /**
  56342. * Class used to store 2D control sizes
  56343. */
  56344. export class Measure {
  56345. /** defines left coordinate */
  56346. left: number;
  56347. /** defines top coordinate */
  56348. top: number;
  56349. /** defines width dimension */
  56350. width: number;
  56351. /** defines height dimension */
  56352. height: number;
  56353. /**
  56354. * Creates a new measure
  56355. * @param left defines left coordinate
  56356. * @param top defines top coordinate
  56357. * @param width defines width dimension
  56358. * @param height defines height dimension
  56359. */
  56360. constructor(
  56361. /** defines left coordinate */
  56362. left: number,
  56363. /** defines top coordinate */
  56364. top: number,
  56365. /** defines width dimension */
  56366. width: number,
  56367. /** defines height dimension */
  56368. height: number);
  56369. /**
  56370. * Copy from another measure
  56371. * @param other defines the other measure to copy from
  56372. */
  56373. copyFrom(other: Measure): void;
  56374. /**
  56375. * Copy from a group of 4 floats
  56376. * @param left defines left coordinate
  56377. * @param top defines top coordinate
  56378. * @param width defines width dimension
  56379. * @param height defines height dimension
  56380. */
  56381. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56382. /**
  56383. * Computes the axis aligned bounding box measure for two given measures
  56384. * @param a Input measure
  56385. * @param b Input measure
  56386. * @param result the resulting bounding measure
  56387. */
  56388. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56389. /**
  56390. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56391. * @param transform the matrix to transform the measure before computing the AABB
  56392. * @param result the resulting AABB
  56393. */
  56394. transformToRef(transform: Matrix2D, result: Measure): void;
  56395. /**
  56396. * Check equality between this measure and another one
  56397. * @param other defines the other measures
  56398. * @returns true if both measures are equals
  56399. */
  56400. isEqualsTo(other: Measure): boolean;
  56401. /**
  56402. * Creates an empty measure
  56403. * @returns a new measure
  56404. */
  56405. static Empty(): Measure;
  56406. }
  56407. }
  56408. declare module BABYLON.GUI {
  56409. /**
  56410. * Interface used to define a control that can receive focus
  56411. */
  56412. export interface IFocusableControl {
  56413. /**
  56414. * Function called when the control receives the focus
  56415. */
  56416. onFocus(): void;
  56417. /**
  56418. * Function called when the control loses the focus
  56419. */
  56420. onBlur(): void;
  56421. /**
  56422. * Function called to let the control handle keyboard events
  56423. * @param evt defines the current keyboard event
  56424. */
  56425. processKeyboard(evt: KeyboardEvent): void;
  56426. /**
  56427. * Function called to get the list of controls that should not steal the focus from this control
  56428. * @returns an array of controls
  56429. */
  56430. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56431. }
  56432. /**
  56433. * Class used to create texture to support 2D GUI elements
  56434. * @see http://doc.babylonjs.com/how_to/gui
  56435. */
  56436. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56437. private _isDirty;
  56438. private _renderObserver;
  56439. private _resizeObserver;
  56440. private _preKeyboardObserver;
  56441. private _pointerMoveObserver;
  56442. private _pointerObserver;
  56443. private _canvasPointerOutObserver;
  56444. private _background;
  56445. /** @hidden */ rootContainer: Container;
  56446. /** @hidden */ lastPickedControl: Control;
  56447. /** @hidden */ lastControlOver: {
  56448. [pointerId: number]: Control;
  56449. };
  56450. /** @hidden */ lastControlDown: {
  56451. [pointerId: number]: Control;
  56452. };
  56453. /** @hidden */ capturingControl: {
  56454. [pointerId: number]: Control;
  56455. };
  56456. /** @hidden */ shouldBlockPointer: boolean;
  56457. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56458. /** @hidden */ linkedControls: Control[];
  56459. private _isFullscreen;
  56460. private _fullscreenViewport;
  56461. private _idealWidth;
  56462. private _idealHeight;
  56463. private _useSmallestIdeal;
  56464. private _renderAtIdealSize;
  56465. private _focusedControl;
  56466. private _blockNextFocusCheck;
  56467. private _renderScale;
  56468. private _rootCanvas;
  56469. private _cursorChanged;
  56470. /**
  56471. * Define type to string to ensure compatibility across browsers
  56472. * Safari doesn't support DataTransfer constructor
  56473. */
  56474. private _clipboardData;
  56475. /**
  56476. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56477. */
  56478. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56479. /**
  56480. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56481. */
  56482. onControlPickedObservable: BABYLON.Observable<Control>;
  56483. /**
  56484. * BABYLON.Observable event triggered before layout is evaluated
  56485. */
  56486. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56487. /**
  56488. * BABYLON.Observable event triggered after the layout was evaluated
  56489. */
  56490. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56491. /**
  56492. * BABYLON.Observable event triggered before the texture is rendered
  56493. */
  56494. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56495. /**
  56496. * BABYLON.Observable event triggered after the texture was rendered
  56497. */
  56498. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56499. /**
  56500. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56501. */
  56502. premulAlpha: boolean;
  56503. /**
  56504. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56505. * Useful when you want more antialiasing
  56506. */
  56507. renderScale: number;
  56508. /** Gets or sets the background color */
  56509. background: string;
  56510. /**
  56511. * Gets or sets the ideal width used to design controls.
  56512. * The GUI will then rescale everything accordingly
  56513. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56514. */
  56515. idealWidth: number;
  56516. /**
  56517. * Gets or sets the ideal height used to design controls.
  56518. * The GUI will then rescale everything accordingly
  56519. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56520. */
  56521. idealHeight: number;
  56522. /**
  56523. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56524. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56525. */
  56526. useSmallestIdeal: boolean;
  56527. /**
  56528. * Gets or sets a boolean indicating if adaptive scaling must be used
  56529. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56530. */
  56531. renderAtIdealSize: boolean;
  56532. /**
  56533. * Gets the underlying layer used to render the texture when in fullscreen mode
  56534. */
  56535. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56536. /**
  56537. * Gets the root container control
  56538. */
  56539. readonly rootContainer: Container;
  56540. /**
  56541. * Returns an array containing the root container.
  56542. * This is mostly used to let the Inspector introspects the ADT
  56543. * @returns an array containing the rootContainer
  56544. */
  56545. getChildren(): Array<Container>;
  56546. /**
  56547. * Will return all controls that are inside this texture
  56548. * @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
  56549. * @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
  56550. * @return all child controls
  56551. */
  56552. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56553. /**
  56554. * Gets or sets the current focused control
  56555. */
  56556. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56557. /**
  56558. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56559. */
  56560. isForeground: boolean;
  56561. /**
  56562. * Gets or set information about clipboardData
  56563. */
  56564. clipboardData: string;
  56565. /**
  56566. * Creates a new AdvancedDynamicTexture
  56567. * @param name defines the name of the texture
  56568. * @param width defines the width of the texture
  56569. * @param height defines the height of the texture
  56570. * @param scene defines the hosting scene
  56571. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56572. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56573. */
  56574. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56575. /**
  56576. * Get the current class name of the texture useful for serialization or dynamic coding.
  56577. * @returns "AdvancedDynamicTexture"
  56578. */
  56579. getClassName(): string;
  56580. /**
  56581. * Function used to execute a function on all controls
  56582. * @param func defines the function to execute
  56583. * @param container defines the container where controls belong. If null the root container will be used
  56584. */
  56585. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56586. private _useInvalidateRectOptimization;
  56587. /**
  56588. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56589. */
  56590. useInvalidateRectOptimization: boolean;
  56591. private _invalidatedRectangle;
  56592. /**
  56593. * Invalidates a rectangle area on the gui texture
  56594. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56595. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56596. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56597. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56598. */
  56599. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56600. /**
  56601. * Marks the texture as dirty forcing a complete update
  56602. */
  56603. markAsDirty(): void;
  56604. /**
  56605. * Helper function used to create a new style
  56606. * @returns a new style
  56607. * @see http://doc.babylonjs.com/how_to/gui#styles
  56608. */
  56609. createStyle(): Style;
  56610. /**
  56611. * Adds a new control to the root container
  56612. * @param control defines the control to add
  56613. * @returns the current texture
  56614. */
  56615. addControl(control: Control): AdvancedDynamicTexture;
  56616. /**
  56617. * Removes a control from the root container
  56618. * @param control defines the control to remove
  56619. * @returns the current texture
  56620. */
  56621. removeControl(control: Control): AdvancedDynamicTexture;
  56622. /**
  56623. * Release all resources
  56624. */
  56625. dispose(): void;
  56626. private _onResize;
  56627. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56628. /**
  56629. * Get screen coordinates for a vector3
  56630. * @param position defines the position to project
  56631. * @param worldMatrix defines the world matrix to use
  56632. * @returns the projected position
  56633. */
  56634. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56635. private _checkUpdate;
  56636. private _clearMeasure;
  56637. private _render;
  56638. /** @hidden */ changeCursor(cursor: string): void;
  56639. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56640. private _doPicking;
  56641. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56642. [pointerId: number]: Control;
  56643. }, control: Control): void;
  56644. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56645. /** Attach to all scene events required to support pointer events */
  56646. attach(): void;
  56647. /** @hidden */
  56648. private onClipboardCopy;
  56649. /** @hidden */
  56650. private onClipboardCut;
  56651. /** @hidden */
  56652. private onClipboardPaste;
  56653. /**
  56654. * Register the clipboard Events onto the canvas
  56655. */
  56656. registerClipboardEvents(): void;
  56657. /**
  56658. * Unregister the clipboard Events from the canvas
  56659. */
  56660. unRegisterClipboardEvents(): void;
  56661. /**
  56662. * Connect the texture to a hosting mesh to enable interactions
  56663. * @param mesh defines the mesh to attach to
  56664. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56665. */
  56666. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56667. /**
  56668. * Move the focus to a specific control
  56669. * @param control defines the control which will receive the focus
  56670. */
  56671. moveFocusToControl(control: IFocusableControl): void;
  56672. private _manageFocus;
  56673. private _attachToOnPointerOut;
  56674. /**
  56675. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56676. * @param mesh defines the mesh which will receive the texture
  56677. * @param width defines the texture width (1024 by default)
  56678. * @param height defines the texture height (1024 by default)
  56679. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56680. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56681. * @returns a new AdvancedDynamicTexture
  56682. */
  56683. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56684. /**
  56685. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56686. * In this mode the texture will rely on a layer for its rendering.
  56687. * This allows it to be treated like any other layer.
  56688. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56689. * LayerMask is set through advancedTexture.layer.layerMask
  56690. * @param name defines name for the texture
  56691. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56692. * @param scene defines the hsoting scene
  56693. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56694. * @returns a new AdvancedDynamicTexture
  56695. */
  56696. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56697. }
  56698. }
  56699. declare module BABYLON.GUI {
  56700. /**
  56701. * Root class used for all 2D controls
  56702. * @see http://doc.babylonjs.com/how_to/gui#controls
  56703. */
  56704. export class Control {
  56705. /** defines the name of the control */
  56706. name?: string | undefined;
  56707. /**
  56708. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56709. */
  56710. static AllowAlphaInheritance: boolean;
  56711. private _alpha;
  56712. private _alphaSet;
  56713. private _zIndex;
  56714. /** @hidden */ host: AdvancedDynamicTexture;
  56715. /** Gets or sets the control parent */
  56716. parent: BABYLON.Nullable<Container>;
  56717. /** @hidden */ currentMeasure: Measure;
  56718. private _fontFamily;
  56719. private _fontStyle;
  56720. private _fontWeight;
  56721. private _fontSize;
  56722. private _font;
  56723. /** @hidden */ width: ValueAndUnit;
  56724. /** @hidden */ height: ValueAndUnit;
  56725. /** @hidden */
  56726. protected _fontOffset: {
  56727. ascent: number;
  56728. height: number;
  56729. descent: number;
  56730. };
  56731. private _color;
  56732. private _style;
  56733. private _styleObserver;
  56734. /** @hidden */
  56735. protected _horizontalAlignment: number;
  56736. /** @hidden */
  56737. protected _verticalAlignment: number;
  56738. /** @hidden */
  56739. protected _isDirty: boolean;
  56740. /** @hidden */
  56741. protected _wasDirty: boolean;
  56742. /** @hidden */ tempParentMeasure: Measure;
  56743. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56744. /** @hidden */
  56745. protected _cachedParentMeasure: Measure;
  56746. private _paddingLeft;
  56747. private _paddingRight;
  56748. private _paddingTop;
  56749. private _paddingBottom;
  56750. /** @hidden */ left: ValueAndUnit;
  56751. /** @hidden */ top: ValueAndUnit;
  56752. private _scaleX;
  56753. private _scaleY;
  56754. private _rotation;
  56755. private _transformCenterX;
  56756. private _transformCenterY;
  56757. /** @hidden */ transformMatrix: Matrix2D;
  56758. /** @hidden */
  56759. protected _invertTransformMatrix: Matrix2D;
  56760. /** @hidden */
  56761. protected _transformedPosition: BABYLON.Vector2;
  56762. private _isMatrixDirty;
  56763. private _cachedOffsetX;
  56764. private _cachedOffsetY;
  56765. private _isVisible;
  56766. private _isHighlighted;
  56767. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56768. private _fontSet;
  56769. private _dummyVector2;
  56770. private _downCount;
  56771. private _enterCount;
  56772. private _doNotRender;
  56773. private _downPointerIds;
  56774. protected _isEnabled: boolean;
  56775. protected _disabledColor: string;
  56776. /** @hidden */
  56777. protected _rebuildLayout: boolean;
  56778. /** @hidden */ isClipped: boolean;
  56779. /** @hidden */ tag: any;
  56780. /**
  56781. * 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
  56782. */
  56783. uniqueId: number;
  56784. /**
  56785. * Gets or sets an object used to store user defined information for the node
  56786. */
  56787. metadata: any;
  56788. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56789. isHitTestVisible: boolean;
  56790. /** Gets or sets a boolean indicating if the control can block pointer events */
  56791. isPointerBlocker: boolean;
  56792. /** Gets or sets a boolean indicating if the control can be focusable */
  56793. isFocusInvisible: boolean;
  56794. /**
  56795. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56796. * 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
  56797. */
  56798. clipChildren: boolean;
  56799. /**
  56800. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56801. */
  56802. useBitmapCache: boolean;
  56803. private _cacheData;
  56804. private _shadowOffsetX;
  56805. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56806. shadowOffsetX: number;
  56807. private _shadowOffsetY;
  56808. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56809. shadowOffsetY: number;
  56810. private _shadowBlur;
  56811. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56812. shadowBlur: number;
  56813. private _shadowColor;
  56814. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56815. shadowColor: string;
  56816. /** Gets or sets the cursor to use when the control is hovered */
  56817. hoverCursor: string;
  56818. /** @hidden */
  56819. protected _linkOffsetX: ValueAndUnit;
  56820. /** @hidden */
  56821. protected _linkOffsetY: ValueAndUnit;
  56822. /** Gets the control type name */
  56823. readonly typeName: string;
  56824. /**
  56825. * Get the current class name of the control.
  56826. * @returns current class name
  56827. */
  56828. getClassName(): string;
  56829. /**
  56830. * An event triggered when the pointer move over the control.
  56831. */
  56832. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56833. /**
  56834. * An event triggered when the pointer move out of the control.
  56835. */
  56836. onPointerOutObservable: BABYLON.Observable<Control>;
  56837. /**
  56838. * An event triggered when the pointer taps the control
  56839. */
  56840. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56841. /**
  56842. * An event triggered when pointer up
  56843. */
  56844. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56845. /**
  56846. * An event triggered when a control is clicked on
  56847. */
  56848. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56849. /**
  56850. * An event triggered when pointer enters the control
  56851. */
  56852. onPointerEnterObservable: BABYLON.Observable<Control>;
  56853. /**
  56854. * An event triggered when the control is marked as dirty
  56855. */
  56856. onDirtyObservable: BABYLON.Observable<Control>;
  56857. /**
  56858. * An event triggered before drawing the control
  56859. */
  56860. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56861. /**
  56862. * An event triggered after the control was drawn
  56863. */
  56864. onAfterDrawObservable: BABYLON.Observable<Control>;
  56865. /**
  56866. * Get the hosting AdvancedDynamicTexture
  56867. */
  56868. readonly host: AdvancedDynamicTexture;
  56869. /** Gets or set information about font offsets (used to render and align text) */
  56870. fontOffset: {
  56871. ascent: number;
  56872. height: number;
  56873. descent: number;
  56874. };
  56875. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56876. alpha: number;
  56877. /**
  56878. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56879. */
  56880. isHighlighted: boolean;
  56881. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56882. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56883. */
  56884. scaleX: number;
  56885. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56886. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56887. */
  56888. scaleY: number;
  56889. /** Gets or sets the rotation angle (0 by default)
  56890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56891. */
  56892. rotation: number;
  56893. /** Gets or sets the transformation center on Y axis (0 by default)
  56894. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56895. */
  56896. transformCenterY: number;
  56897. /** Gets or sets the transformation center on X axis (0 by default)
  56898. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56899. */
  56900. transformCenterX: number;
  56901. /**
  56902. * Gets or sets the horizontal alignment
  56903. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56904. */
  56905. horizontalAlignment: number;
  56906. /**
  56907. * Gets or sets the vertical alignment
  56908. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56909. */
  56910. verticalAlignment: number;
  56911. /**
  56912. * Gets or sets control width
  56913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56914. */
  56915. width: string | number;
  56916. /**
  56917. * Gets control width in pixel
  56918. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56919. */
  56920. readonly widthInPixels: number;
  56921. /**
  56922. * Gets or sets control height
  56923. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56924. */
  56925. height: string | number;
  56926. /**
  56927. * Gets control height in pixel
  56928. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56929. */
  56930. readonly heightInPixels: number;
  56931. /** Gets or set font family */
  56932. fontFamily: string;
  56933. /** Gets or sets font style */
  56934. fontStyle: string;
  56935. /** Gets or sets font weight */
  56936. fontWeight: string;
  56937. /**
  56938. * Gets or sets style
  56939. * @see http://doc.babylonjs.com/how_to/gui#styles
  56940. */
  56941. style: BABYLON.Nullable<Style>;
  56942. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56943. /** Gets font size in pixels */
  56944. readonly fontSizeInPixels: number;
  56945. /** Gets or sets font size */
  56946. fontSize: string | number;
  56947. /** Gets or sets foreground color */
  56948. color: string;
  56949. /** Gets or sets z index which is used to reorder controls on the z axis */
  56950. zIndex: number;
  56951. /** Gets or sets a boolean indicating if the control can be rendered */
  56952. notRenderable: boolean;
  56953. /** Gets or sets a boolean indicating if the control is visible */
  56954. isVisible: boolean;
  56955. /** Gets a boolean indicating that the control needs to update its rendering */
  56956. readonly isDirty: boolean;
  56957. /**
  56958. * Gets the current linked mesh (or null if none)
  56959. */
  56960. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56961. /**
  56962. * Gets or sets a value indicating the padding to use on the left of the control
  56963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56964. */
  56965. paddingLeft: string | number;
  56966. /**
  56967. * Gets a value indicating the padding in pixels to use on the left of the control
  56968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56969. */
  56970. readonly paddingLeftInPixels: number;
  56971. /**
  56972. * Gets or sets a value indicating the padding to use on the right of the control
  56973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56974. */
  56975. paddingRight: string | number;
  56976. /**
  56977. * Gets a value indicating the padding in pixels to use on the right of the control
  56978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56979. */
  56980. readonly paddingRightInPixels: number;
  56981. /**
  56982. * Gets or sets a value indicating the padding to use on the top of the control
  56983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56984. */
  56985. paddingTop: string | number;
  56986. /**
  56987. * Gets a value indicating the padding in pixels to use on the top of the control
  56988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56989. */
  56990. readonly paddingTopInPixels: number;
  56991. /**
  56992. * Gets or sets a value indicating the padding to use on the bottom of the control
  56993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56994. */
  56995. paddingBottom: string | number;
  56996. /**
  56997. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56999. */
  57000. readonly paddingBottomInPixels: number;
  57001. /**
  57002. * Gets or sets a value indicating the left coordinate of the control
  57003. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57004. */
  57005. left: string | number;
  57006. /**
  57007. * Gets a value indicating the left coordinate in pixels of the control
  57008. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57009. */
  57010. readonly leftInPixels: number;
  57011. /**
  57012. * Gets or sets a value indicating the top coordinate of the control
  57013. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57014. */
  57015. top: string | number;
  57016. /**
  57017. * Gets a value indicating the top coordinate in pixels of the control
  57018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57019. */
  57020. readonly topInPixels: number;
  57021. /**
  57022. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57023. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57024. */
  57025. linkOffsetX: string | number;
  57026. /**
  57027. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57028. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57029. */
  57030. readonly linkOffsetXInPixels: number;
  57031. /**
  57032. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57033. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57034. */
  57035. linkOffsetY: string | number;
  57036. /**
  57037. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57038. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57039. */
  57040. readonly linkOffsetYInPixels: number;
  57041. /** Gets the center coordinate on X axis */
  57042. readonly centerX: number;
  57043. /** Gets the center coordinate on Y axis */
  57044. readonly centerY: number;
  57045. /** Gets or sets if control is Enabled*/
  57046. isEnabled: boolean;
  57047. /** Gets or sets background color of control if it's disabled*/
  57048. disabledColor: string;
  57049. /**
  57050. * Creates a new control
  57051. * @param name defines the name of the control
  57052. */
  57053. constructor(
  57054. /** defines the name of the control */
  57055. name?: string | undefined);
  57056. /** @hidden */
  57057. protected _getTypeName(): string;
  57058. /**
  57059. * Gets the first ascendant in the hierarchy of the given type
  57060. * @param className defines the required type
  57061. * @returns the ascendant or null if not found
  57062. */
  57063. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57064. /** @hidden */ resetFontCache(): void;
  57065. /**
  57066. * Determines if a container is an ascendant of the current control
  57067. * @param container defines the container to look for
  57068. * @returns true if the container is one of the ascendant of the control
  57069. */
  57070. isAscendant(container: Control): boolean;
  57071. /**
  57072. * Gets coordinates in local control space
  57073. * @param globalCoordinates defines the coordinates to transform
  57074. * @returns the new coordinates in local space
  57075. */
  57076. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57077. /**
  57078. * Gets coordinates in local control space
  57079. * @param globalCoordinates defines the coordinates to transform
  57080. * @param result defines the target vector2 where to store the result
  57081. * @returns the current control
  57082. */
  57083. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57084. /**
  57085. * Gets coordinates in parent local control space
  57086. * @param globalCoordinates defines the coordinates to transform
  57087. * @returns the new coordinates in parent local space
  57088. */
  57089. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57090. /**
  57091. * Move the current control to a vector3 position projected onto the screen.
  57092. * @param position defines the target position
  57093. * @param scene defines the hosting scene
  57094. */
  57095. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57096. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57097. /**
  57098. * Will return all controls that have this control as ascendant
  57099. * @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
  57100. * @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
  57101. * @return all child controls
  57102. */
  57103. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57104. /**
  57105. * Link current control with a target mesh
  57106. * @param mesh defines the mesh to link with
  57107. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57108. */
  57109. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57110. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57111. /** @hidden */ offsetLeft(offset: number): void;
  57112. /** @hidden */ offsetTop(offset: number): void;
  57113. /** @hidden */ markMatrixAsDirty(): void;
  57114. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57115. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57116. /** @hidden */
  57117. protected invalidateRect(): void;
  57118. /** @hidden */ markAsDirty(force?: boolean): void;
  57119. /** @hidden */ markAllAsDirty(): void;
  57120. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57121. /** @hidden */
  57122. protected _transform(context?: CanvasRenderingContext2D): void;
  57123. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57124. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57125. /** @hidden */
  57126. protected _applyStates(context: CanvasRenderingContext2D): void;
  57127. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57128. /** @hidden */
  57129. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57130. protected _evaluateClippingState(parentMeasure: Measure): void;
  57131. /** @hidden */ measure(): void;
  57132. /** @hidden */
  57133. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57134. /** @hidden */
  57135. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57136. /** @hidden */
  57137. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57138. /** @hidden */
  57139. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57140. private static _ClipMeasure;
  57141. private _tmpMeasureA;
  57142. private _clip;
  57143. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57144. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57145. /**
  57146. * Tests if a given coordinates belong to the current control
  57147. * @param x defines x coordinate to test
  57148. * @param y defines y coordinate to test
  57149. * @returns true if the coordinates are inside the control
  57150. */
  57151. contains(x: number, y: number): boolean;
  57152. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57153. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  57154. /** @hidden */ onPointerEnter(target: Control): boolean;
  57155. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57156. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57157. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57158. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57159. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57160. private _prepareFont;
  57161. /** Releases associated resources */
  57162. dispose(): void;
  57163. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57164. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57165. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57166. private static _VERTICAL_ALIGNMENT_TOP;
  57167. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57168. private static _VERTICAL_ALIGNMENT_CENTER;
  57169. /** HORIZONTAL_ALIGNMENT_LEFT */
  57170. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57171. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57172. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57173. /** HORIZONTAL_ALIGNMENT_CENTER */
  57174. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57175. /** VERTICAL_ALIGNMENT_TOP */
  57176. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57177. /** VERTICAL_ALIGNMENT_BOTTOM */
  57178. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57179. /** VERTICAL_ALIGNMENT_CENTER */
  57180. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57181. private static _FontHeightSizes;
  57182. /** @hidden */ private static _GetFontOffset(font: string): {
  57183. ascent: number;
  57184. height: number;
  57185. descent: number;
  57186. };
  57187. /**
  57188. * Creates a stack panel that can be used to render headers
  57189. * @param control defines the control to associate with the header
  57190. * @param text defines the text of the header
  57191. * @param size defines the size of the header
  57192. * @param options defines options used to configure the header
  57193. * @returns a new StackPanel
  57194. * @ignore
  57195. * @hidden
  57196. */
  57197. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57198. isHorizontal: boolean;
  57199. controlFirst: boolean;
  57200. }) => any;
  57201. /** @hidden */
  57202. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57203. }
  57204. }
  57205. declare module BABYLON.GUI {
  57206. /**
  57207. * Root class for 2D containers
  57208. * @see http://doc.babylonjs.com/how_to/gui#containers
  57209. */
  57210. export class Container extends Control {
  57211. name?: string | undefined;
  57212. /** @hidden */
  57213. protected _children: Control[];
  57214. /** @hidden */
  57215. protected _measureForChildren: Measure;
  57216. /** @hidden */
  57217. protected _background: string;
  57218. /** @hidden */
  57219. protected _adaptWidthToChildren: boolean;
  57220. /** @hidden */
  57221. protected _adaptHeightToChildren: boolean;
  57222. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57223. adaptHeightToChildren: boolean;
  57224. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57225. adaptWidthToChildren: boolean;
  57226. /** Gets or sets background color */
  57227. background: string;
  57228. /** Gets the list of children */
  57229. readonly children: Control[];
  57230. /**
  57231. * Creates a new Container
  57232. * @param name defines the name of the container
  57233. */
  57234. constructor(name?: string | undefined);
  57235. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57236. /**
  57237. * Gets a child using its name
  57238. * @param name defines the child name to look for
  57239. * @returns the child control if found
  57240. */
  57241. getChildByName(name: string): BABYLON.Nullable<Control>;
  57242. /**
  57243. * Gets a child using its type and its name
  57244. * @param name defines the child name to look for
  57245. * @param type defines the child type to look for
  57246. * @returns the child control if found
  57247. */
  57248. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57249. /**
  57250. * Search for a specific control in children
  57251. * @param control defines the control to look for
  57252. * @returns true if the control is in child list
  57253. */
  57254. containsControl(control: Control): boolean;
  57255. /**
  57256. * Adds a new control to the current container
  57257. * @param control defines the control to add
  57258. * @returns the current container
  57259. */
  57260. addControl(control: BABYLON.Nullable<Control>): Container;
  57261. /**
  57262. * Removes all controls from the current container
  57263. * @returns the current container
  57264. */
  57265. clearControls(): Container;
  57266. /**
  57267. * Removes a control from the current container
  57268. * @param control defines the control to remove
  57269. * @returns the current container
  57270. */
  57271. removeControl(control: Control): Container;
  57272. /** @hidden */ reOrderControl(control: Control): void;
  57273. /** @hidden */ offsetLeft(offset: number): void;
  57274. /** @hidden */ offsetTop(offset: number): void;
  57275. /** @hidden */ markAllAsDirty(): void;
  57276. /** @hidden */
  57277. protected _localDraw(context: CanvasRenderingContext2D): void;
  57278. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57279. /** @hidden */
  57280. protected _beforeLayout(): void;
  57281. /** @hidden */
  57282. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57283. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57284. protected _postMeasure(): void;
  57285. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57286. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57287. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57288. /** @hidden */
  57289. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57290. /** Releases associated resources */
  57291. dispose(): void;
  57292. }
  57293. }
  57294. declare module BABYLON.GUI {
  57295. /** Class used to create rectangle container */
  57296. export class Rectangle extends Container {
  57297. name?: string | undefined;
  57298. private _thickness;
  57299. private _cornerRadius;
  57300. /** Gets or sets border thickness */
  57301. thickness: number;
  57302. /** Gets or sets the corner radius angle */
  57303. cornerRadius: number;
  57304. /**
  57305. * Creates a new Rectangle
  57306. * @param name defines the control name
  57307. */
  57308. constructor(name?: string | undefined);
  57309. protected _getTypeName(): string;
  57310. protected _localDraw(context: CanvasRenderingContext2D): void;
  57311. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57312. private _drawRoundedRect;
  57313. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57314. }
  57315. }
  57316. declare module BABYLON.GUI {
  57317. /**
  57318. * Enum that determines the text-wrapping mode to use.
  57319. */
  57320. export enum TextWrapping {
  57321. /**
  57322. * Clip the text when it's larger than Control.width; this is the default mode.
  57323. */
  57324. Clip = 0,
  57325. /**
  57326. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57327. */
  57328. WordWrap = 1,
  57329. /**
  57330. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57331. */
  57332. Ellipsis = 2
  57333. }
  57334. /**
  57335. * Class used to create text block control
  57336. */
  57337. export class TextBlock extends Control {
  57338. /**
  57339. * Defines the name of the control
  57340. */
  57341. name?: string | undefined;
  57342. private _text;
  57343. private _textWrapping;
  57344. private _textHorizontalAlignment;
  57345. private _textVerticalAlignment;
  57346. private _lines;
  57347. private _resizeToFit;
  57348. private _lineSpacing;
  57349. private _outlineWidth;
  57350. private _outlineColor;
  57351. /**
  57352. * An event triggered after the text is changed
  57353. */
  57354. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57355. /**
  57356. * An event triggered after the text was broken up into lines
  57357. */
  57358. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57359. /**
  57360. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57361. */
  57362. readonly lines: any[];
  57363. /**
  57364. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57365. */
  57366. /**
  57367. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57368. */
  57369. resizeToFit: boolean;
  57370. /**
  57371. * Gets or sets a boolean indicating if text must be wrapped
  57372. */
  57373. /**
  57374. * Gets or sets a boolean indicating if text must be wrapped
  57375. */
  57376. textWrapping: TextWrapping | boolean;
  57377. /**
  57378. * Gets or sets text to display
  57379. */
  57380. /**
  57381. * Gets or sets text to display
  57382. */
  57383. text: string;
  57384. /**
  57385. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57386. */
  57387. /**
  57388. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57389. */
  57390. textHorizontalAlignment: number;
  57391. /**
  57392. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57393. */
  57394. /**
  57395. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57396. */
  57397. textVerticalAlignment: number;
  57398. /**
  57399. * Gets or sets line spacing value
  57400. */
  57401. /**
  57402. * Gets or sets line spacing value
  57403. */
  57404. lineSpacing: string | number;
  57405. /**
  57406. * Gets or sets outlineWidth of the text to display
  57407. */
  57408. /**
  57409. * Gets or sets outlineWidth of the text to display
  57410. */
  57411. outlineWidth: number;
  57412. /**
  57413. * Gets or sets outlineColor of the text to display
  57414. */
  57415. /**
  57416. * Gets or sets outlineColor of the text to display
  57417. */
  57418. outlineColor: string;
  57419. /**
  57420. * Creates a new TextBlock object
  57421. * @param name defines the name of the control
  57422. * @param text defines the text to display (emptry string by default)
  57423. */
  57424. constructor(
  57425. /**
  57426. * Defines the name of the control
  57427. */
  57428. name?: string | undefined, text?: string);
  57429. protected _getTypeName(): string;
  57430. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57431. private _drawText;
  57432. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57433. protected _applyStates(context: CanvasRenderingContext2D): void;
  57434. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57435. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57436. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57437. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57438. protected _renderLines(context: CanvasRenderingContext2D): void;
  57439. /**
  57440. * Given a width constraint applied on the text block, find the expected height
  57441. * @returns expected height
  57442. */
  57443. computeExpectedHeight(): number;
  57444. dispose(): void;
  57445. }
  57446. }
  57447. declare module BABYLON.GUI {
  57448. /**
  57449. * Class used to create 2D images
  57450. */
  57451. export class Image extends Control {
  57452. name?: string | undefined;
  57453. private static _WorkingCanvas;
  57454. private _domImage;
  57455. private _imageWidth;
  57456. private _imageHeight;
  57457. private _loaded;
  57458. private _stretch;
  57459. private _source;
  57460. private _autoScale;
  57461. private _sourceLeft;
  57462. private _sourceTop;
  57463. private _sourceWidth;
  57464. private _sourceHeight;
  57465. private _cellWidth;
  57466. private _cellHeight;
  57467. private _cellId;
  57468. private _populateNinePatchSlicesFromImage;
  57469. private _sliceLeft;
  57470. private _sliceRight;
  57471. private _sliceTop;
  57472. private _sliceBottom;
  57473. private _detectPointerOnOpaqueOnly;
  57474. /**
  57475. * BABYLON.Observable notified when the content is loaded
  57476. */
  57477. onImageLoadedObservable: BABYLON.Observable<Image>;
  57478. /**
  57479. * Gets a boolean indicating that the content is loaded
  57480. */
  57481. readonly isLoaded: boolean;
  57482. /**
  57483. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57484. */
  57485. populateNinePatchSlicesFromImage: boolean;
  57486. /**
  57487. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57488. * Beware using this as this will comsume more memory as the image has to be stored twice
  57489. */
  57490. detectPointerOnOpaqueOnly: boolean;
  57491. /**
  57492. * Gets or sets the left value for slicing (9-patch)
  57493. */
  57494. sliceLeft: number;
  57495. /**
  57496. * Gets or sets the right value for slicing (9-patch)
  57497. */
  57498. sliceRight: number;
  57499. /**
  57500. * Gets or sets the top value for slicing (9-patch)
  57501. */
  57502. sliceTop: number;
  57503. /**
  57504. * Gets or sets the bottom value for slicing (9-patch)
  57505. */
  57506. sliceBottom: number;
  57507. /**
  57508. * Gets or sets the left coordinate in the source image
  57509. */
  57510. sourceLeft: number;
  57511. /**
  57512. * Gets or sets the top coordinate in the source image
  57513. */
  57514. sourceTop: number;
  57515. /**
  57516. * Gets or sets the width to capture in the source image
  57517. */
  57518. sourceWidth: number;
  57519. /**
  57520. * Gets or sets the height to capture in the source image
  57521. */
  57522. sourceHeight: number;
  57523. /**
  57524. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57525. * @see http://doc.babylonjs.com/how_to/gui#image
  57526. */
  57527. autoScale: boolean;
  57528. /** Gets or sets the streching mode used by the image */
  57529. stretch: number;
  57530. /**
  57531. * Gets or sets the internal DOM image used to render the control
  57532. */
  57533. domImage: HTMLImageElement;
  57534. private _onImageLoaded;
  57535. private _extractNinePatchSliceDataFromImage;
  57536. /**
  57537. * Gets or sets image source url
  57538. */
  57539. source: BABYLON.Nullable<string>;
  57540. /**
  57541. * Gets or sets the cell width to use when animation sheet is enabled
  57542. * @see http://doc.babylonjs.com/how_to/gui#image
  57543. */
  57544. cellWidth: number;
  57545. /**
  57546. * Gets or sets the cell height to use when animation sheet is enabled
  57547. * @see http://doc.babylonjs.com/how_to/gui#image
  57548. */
  57549. cellHeight: number;
  57550. /**
  57551. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57552. * @see http://doc.babylonjs.com/how_to/gui#image
  57553. */
  57554. cellId: number;
  57555. /**
  57556. * Creates a new Image
  57557. * @param name defines the control name
  57558. * @param url defines the image url
  57559. */
  57560. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57561. /**
  57562. * Tests if a given coordinates belong to the current control
  57563. * @param x defines x coordinate to test
  57564. * @param y defines y coordinate to test
  57565. * @returns true if the coordinates are inside the control
  57566. */
  57567. contains(x: number, y: number): boolean;
  57568. protected _getTypeName(): string;
  57569. /** Force the control to synchronize with its content */
  57570. synchronizeSizeWithContent(): void;
  57571. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57572. private _prepareWorkingCanvasForOpaqueDetection;
  57573. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57574. private _renderCornerPatch;
  57575. private _renderNinePatch;
  57576. dispose(): void;
  57577. /** STRETCH_NONE */
  57578. static readonly STRETCH_NONE: number;
  57579. /** STRETCH_FILL */
  57580. static readonly STRETCH_FILL: number;
  57581. /** STRETCH_UNIFORM */
  57582. static readonly STRETCH_UNIFORM: number;
  57583. /** STRETCH_EXTEND */
  57584. static readonly STRETCH_EXTEND: number;
  57585. /** NINE_PATCH */
  57586. static readonly STRETCH_NINE_PATCH: number;
  57587. }
  57588. }
  57589. declare module BABYLON.GUI {
  57590. /**
  57591. * Class used to create 2D buttons
  57592. */
  57593. export class Button extends Rectangle {
  57594. name?: string | undefined;
  57595. /**
  57596. * Function called to generate a pointer enter animation
  57597. */
  57598. pointerEnterAnimation: () => void;
  57599. /**
  57600. * Function called to generate a pointer out animation
  57601. */
  57602. pointerOutAnimation: () => void;
  57603. /**
  57604. * Function called to generate a pointer down animation
  57605. */
  57606. pointerDownAnimation: () => void;
  57607. /**
  57608. * Function called to generate a pointer up animation
  57609. */
  57610. pointerUpAnimation: () => void;
  57611. private _image;
  57612. /**
  57613. * Returns the image part of the button (if any)
  57614. */
  57615. readonly image: BABYLON.Nullable<Image>;
  57616. private _textBlock;
  57617. /**
  57618. * Returns the image part of the button (if any)
  57619. */
  57620. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57621. /**
  57622. * Creates a new Button
  57623. * @param name defines the name of the button
  57624. */
  57625. constructor(name?: string | undefined);
  57626. protected _getTypeName(): string;
  57627. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57628. /** @hidden */ onPointerEnter(target: Control): boolean;
  57629. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57630. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57631. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57632. /**
  57633. * Creates a new button made with an image and a text
  57634. * @param name defines the name of the button
  57635. * @param text defines the text of the button
  57636. * @param imageUrl defines the url of the image
  57637. * @returns a new Button
  57638. */
  57639. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57640. /**
  57641. * Creates a new button made with an image
  57642. * @param name defines the name of the button
  57643. * @param imageUrl defines the url of the image
  57644. * @returns a new Button
  57645. */
  57646. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57647. /**
  57648. * Creates a new button made with a text
  57649. * @param name defines the name of the button
  57650. * @param text defines the text of the button
  57651. * @returns a new Button
  57652. */
  57653. static CreateSimpleButton(name: string, text: string): Button;
  57654. /**
  57655. * Creates a new button made with an image and a centered text
  57656. * @param name defines the name of the button
  57657. * @param text defines the text of the button
  57658. * @param imageUrl defines the url of the image
  57659. * @returns a new Button
  57660. */
  57661. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57662. }
  57663. }
  57664. declare module BABYLON.GUI {
  57665. /**
  57666. * Class used to create a 2D stack panel container
  57667. */
  57668. export class StackPanel extends Container {
  57669. name?: string | undefined;
  57670. private _isVertical;
  57671. private _manualWidth;
  57672. private _manualHeight;
  57673. private _doNotTrackManualChanges;
  57674. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57675. isVertical: boolean;
  57676. /**
  57677. * Gets or sets panel width.
  57678. * This value should not be set when in horizontal mode as it will be computed automatically
  57679. */
  57680. width: string | number;
  57681. /**
  57682. * Gets or sets panel height.
  57683. * This value should not be set when in vertical mode as it will be computed automatically
  57684. */
  57685. height: string | number;
  57686. /**
  57687. * Creates a new StackPanel
  57688. * @param name defines control name
  57689. */
  57690. constructor(name?: string | undefined);
  57691. protected _getTypeName(): string;
  57692. /** @hidden */
  57693. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57694. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57695. protected _postMeasure(): void;
  57696. }
  57697. }
  57698. declare module BABYLON.GUI {
  57699. /**
  57700. * Class used to represent a 2D checkbox
  57701. */
  57702. export class Checkbox extends Control {
  57703. name?: string | undefined;
  57704. private _isChecked;
  57705. private _background;
  57706. private _checkSizeRatio;
  57707. private _thickness;
  57708. /** Gets or sets border thickness */
  57709. thickness: number;
  57710. /**
  57711. * BABYLON.Observable raised when isChecked property changes
  57712. */
  57713. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57714. /** Gets or sets a value indicating the ratio between overall size and check size */
  57715. checkSizeRatio: number;
  57716. /** Gets or sets background color */
  57717. background: string;
  57718. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57719. isChecked: boolean;
  57720. /**
  57721. * Creates a new CheckBox
  57722. * @param name defines the control name
  57723. */
  57724. constructor(name?: string | undefined);
  57725. protected _getTypeName(): string;
  57726. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57727. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57728. /**
  57729. * Utility function to easily create a checkbox with a header
  57730. * @param title defines the label to use for the header
  57731. * @param onValueChanged defines the callback to call when value changes
  57732. * @returns a StackPanel containing the checkbox and a textBlock
  57733. */
  57734. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57735. }
  57736. }
  57737. declare module BABYLON.GUI {
  57738. /**
  57739. * Class used to store key control properties
  57740. */
  57741. export class KeyPropertySet {
  57742. /** Width */
  57743. width?: string;
  57744. /** Height */
  57745. height?: string;
  57746. /** Left padding */
  57747. paddingLeft?: string;
  57748. /** Right padding */
  57749. paddingRight?: string;
  57750. /** Top padding */
  57751. paddingTop?: string;
  57752. /** Bottom padding */
  57753. paddingBottom?: string;
  57754. /** Foreground color */
  57755. color?: string;
  57756. /** Background color */
  57757. background?: string;
  57758. }
  57759. /**
  57760. * Class used to create virtual keyboard
  57761. */
  57762. export class VirtualKeyboard extends StackPanel {
  57763. /** BABYLON.Observable raised when a key is pressed */
  57764. onKeyPressObservable: BABYLON.Observable<string>;
  57765. /** Gets or sets default key button width */
  57766. defaultButtonWidth: string;
  57767. /** Gets or sets default key button height */
  57768. defaultButtonHeight: string;
  57769. /** Gets or sets default key button left padding */
  57770. defaultButtonPaddingLeft: string;
  57771. /** Gets or sets default key button right padding */
  57772. defaultButtonPaddingRight: string;
  57773. /** Gets or sets default key button top padding */
  57774. defaultButtonPaddingTop: string;
  57775. /** Gets or sets default key button bottom padding */
  57776. defaultButtonPaddingBottom: string;
  57777. /** Gets or sets default key button foreground color */
  57778. defaultButtonColor: string;
  57779. /** Gets or sets default key button background color */
  57780. defaultButtonBackground: string;
  57781. /** Gets or sets shift button foreground color */
  57782. shiftButtonColor: string;
  57783. /** Gets or sets shift button thickness*/
  57784. selectedShiftThickness: number;
  57785. /** Gets shift key state */
  57786. shiftState: number;
  57787. protected _getTypeName(): string;
  57788. private _createKey;
  57789. /**
  57790. * Adds a new row of keys
  57791. * @param keys defines the list of keys to add
  57792. * @param propertySets defines the associated property sets
  57793. */
  57794. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57795. /**
  57796. * Set the shift key to a specific state
  57797. * @param shiftState defines the new shift state
  57798. */
  57799. applyShiftState(shiftState: number): void;
  57800. private _currentlyConnectedInputText;
  57801. private _connectedInputTexts;
  57802. private _onKeyPressObserver;
  57803. /** Gets the input text control currently attached to the keyboard */
  57804. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57805. /**
  57806. * Connects the keyboard with an input text control
  57807. *
  57808. * @param input defines the target control
  57809. */
  57810. connect(input: InputText): void;
  57811. /**
  57812. * Disconnects the keyboard from connected InputText controls
  57813. *
  57814. * @param input optionally defines a target control, otherwise all are disconnected
  57815. */
  57816. disconnect(input?: InputText): void;
  57817. private _removeConnectedInputObservables;
  57818. /**
  57819. * Release all resources
  57820. */
  57821. dispose(): void;
  57822. /**
  57823. * Creates a new keyboard using a default layout
  57824. *
  57825. * @param name defines control name
  57826. * @returns a new VirtualKeyboard
  57827. */
  57828. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57829. }
  57830. }
  57831. declare module BABYLON.GUI {
  57832. /**
  57833. * Class used to create input text control
  57834. */
  57835. export class InputText extends Control implements IFocusableControl {
  57836. name?: string | undefined;
  57837. private _text;
  57838. private _placeholderText;
  57839. private _background;
  57840. private _focusedBackground;
  57841. private _focusedColor;
  57842. private _placeholderColor;
  57843. private _thickness;
  57844. private _margin;
  57845. private _autoStretchWidth;
  57846. private _maxWidth;
  57847. private _isFocused;
  57848. private _blinkTimeout;
  57849. private _blinkIsEven;
  57850. private _cursorOffset;
  57851. private _scrollLeft;
  57852. private _textWidth;
  57853. private _clickedCoordinate;
  57854. private _deadKey;
  57855. private _addKey;
  57856. private _currentKey;
  57857. private _isTextHighlightOn;
  57858. private _textHighlightColor;
  57859. private _highligherOpacity;
  57860. private _highlightedText;
  57861. private _startHighlightIndex;
  57862. private _endHighlightIndex;
  57863. private _cursorIndex;
  57864. private _onFocusSelectAll;
  57865. private _isPointerDown;
  57866. private _onClipboardObserver;
  57867. private _onPointerDblTapObserver;
  57868. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57869. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57870. promptMessage: string;
  57871. /** BABYLON.Observable raised when the text changes */
  57872. onTextChangedObservable: BABYLON.Observable<InputText>;
  57873. /** BABYLON.Observable raised just before an entered character is to be added */
  57874. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57875. /** BABYLON.Observable raised when the control gets the focus */
  57876. onFocusObservable: BABYLON.Observable<InputText>;
  57877. /** BABYLON.Observable raised when the control loses the focus */
  57878. onBlurObservable: BABYLON.Observable<InputText>;
  57879. /**Observable raised when the text is highlighted */
  57880. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57881. /**Observable raised when copy event is triggered */
  57882. onTextCopyObservable: BABYLON.Observable<InputText>;
  57883. /** BABYLON.Observable raised when cut event is triggered */
  57884. onTextCutObservable: BABYLON.Observable<InputText>;
  57885. /** BABYLON.Observable raised when paste event is triggered */
  57886. onTextPasteObservable: BABYLON.Observable<InputText>;
  57887. /** BABYLON.Observable raised when a key event was processed */
  57888. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57889. /** Gets or sets the maximum width allowed by the control */
  57890. maxWidth: string | number;
  57891. /** Gets the maximum width allowed by the control in pixels */
  57892. readonly maxWidthInPixels: number;
  57893. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57894. highligherOpacity: number;
  57895. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57896. onFocusSelectAll: boolean;
  57897. /** Gets or sets the text hightlight color */
  57898. textHighlightColor: string;
  57899. /** Gets or sets control margin */
  57900. margin: string;
  57901. /** Gets control margin in pixels */
  57902. readonly marginInPixels: number;
  57903. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57904. autoStretchWidth: boolean;
  57905. /** Gets or sets border thickness */
  57906. thickness: number;
  57907. /** Gets or sets the background color when focused */
  57908. focusedBackground: string;
  57909. /** Gets or sets the background color when focused */
  57910. focusedColor: string;
  57911. /** Gets or sets the background color */
  57912. background: string;
  57913. /** Gets or sets the placeholder color */
  57914. placeholderColor: string;
  57915. /** Gets or sets the text displayed when the control is empty */
  57916. placeholderText: string;
  57917. /** Gets or sets the dead key flag */
  57918. deadKey: boolean;
  57919. /** Gets or sets the highlight text */
  57920. highlightedText: string;
  57921. /** Gets or sets if the current key should be added */
  57922. addKey: boolean;
  57923. /** Gets or sets the value of the current key being entered */
  57924. currentKey: string;
  57925. /** Gets or sets the text displayed in the control */
  57926. text: string;
  57927. /** Gets or sets control width */
  57928. width: string | number;
  57929. /**
  57930. * Creates a new InputText
  57931. * @param name defines the control name
  57932. * @param text defines the text of the control
  57933. */
  57934. constructor(name?: string | undefined, text?: string);
  57935. /** @hidden */
  57936. onBlur(): void;
  57937. /** @hidden */
  57938. onFocus(): void;
  57939. protected _getTypeName(): string;
  57940. /**
  57941. * Function called to get the list of controls that should not steal the focus from this control
  57942. * @returns an array of controls
  57943. */
  57944. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57945. /** @hidden */
  57946. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57947. /** @hidden */
  57948. private _updateValueFromCursorIndex;
  57949. /** @hidden */
  57950. private _processDblClick;
  57951. /** @hidden */
  57952. private _selectAllText;
  57953. /**
  57954. * Handles the keyboard event
  57955. * @param evt Defines the KeyboardEvent
  57956. */
  57957. processKeyboard(evt: KeyboardEvent): void;
  57958. /** @hidden */
  57959. private _onCopyText;
  57960. /** @hidden */
  57961. private _onCutText;
  57962. /** @hidden */
  57963. 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;
  57964. protected _beforeRenderText(text: string): string;
  57965. dispose(): void;
  57966. }
  57967. }
  57968. declare module BABYLON.GUI {
  57969. /**
  57970. * Class used to create a 2D grid container
  57971. */
  57972. export class Grid extends Container {
  57973. name?: string | undefined;
  57974. private _rowDefinitions;
  57975. private _columnDefinitions;
  57976. private _cells;
  57977. private _childControls;
  57978. /**
  57979. * Gets the number of columns
  57980. */
  57981. readonly columnCount: number;
  57982. /**
  57983. * Gets the number of rows
  57984. */
  57985. readonly rowCount: number;
  57986. /** Gets the list of children */
  57987. readonly children: Control[];
  57988. /**
  57989. * Gets the definition of a specific row
  57990. * @param index defines the index of the row
  57991. * @returns the row definition
  57992. */
  57993. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57994. /**
  57995. * Gets the definition of a specific column
  57996. * @param index defines the index of the column
  57997. * @returns the column definition
  57998. */
  57999. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58000. /**
  58001. * Adds a new row to the grid
  58002. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58003. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58004. * @returns the current grid
  58005. */
  58006. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58007. /**
  58008. * Adds a new column to the grid
  58009. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58010. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58011. * @returns the current grid
  58012. */
  58013. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58014. /**
  58015. * Update a row definition
  58016. * @param index defines the index of the row to update
  58017. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58018. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58019. * @returns the current grid
  58020. */
  58021. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58022. /**
  58023. * Update a column definition
  58024. * @param index defines the index of the column to update
  58025. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58026. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58027. * @returns the current grid
  58028. */
  58029. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58030. /**
  58031. * Gets the list of children stored in a specific cell
  58032. * @param row defines the row to check
  58033. * @param column defines the column to check
  58034. * @returns the list of controls
  58035. */
  58036. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58037. /**
  58038. * Gets a string representing the child cell info (row x column)
  58039. * @param child defines the control to get info from
  58040. * @returns a string containing the child cell info (row x column)
  58041. */
  58042. getChildCellInfo(child: Control): string;
  58043. private _removeCell;
  58044. private _offsetCell;
  58045. /**
  58046. * Remove a column definition at specified index
  58047. * @param index defines the index of the column to remove
  58048. * @returns the current grid
  58049. */
  58050. removeColumnDefinition(index: number): Grid;
  58051. /**
  58052. * Remove a row definition at specified index
  58053. * @param index defines the index of the row to remove
  58054. * @returns the current grid
  58055. */
  58056. removeRowDefinition(index: number): Grid;
  58057. /**
  58058. * Adds a new control to the current grid
  58059. * @param control defines the control to add
  58060. * @param row defines the row where to add the control (0 by default)
  58061. * @param column defines the column where to add the control (0 by default)
  58062. * @returns the current grid
  58063. */
  58064. addControl(control: Control, row?: number, column?: number): Grid;
  58065. /**
  58066. * Removes a control from the current container
  58067. * @param control defines the control to remove
  58068. * @returns the current container
  58069. */
  58070. removeControl(control: Control): Container;
  58071. /**
  58072. * Creates a new Grid
  58073. * @param name defines control name
  58074. */
  58075. constructor(name?: string | undefined);
  58076. protected _getTypeName(): string;
  58077. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58078. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58079. /** Releases associated resources */
  58080. dispose(): void;
  58081. }
  58082. }
  58083. declare module BABYLON.GUI {
  58084. /** Class used to create color pickers */
  58085. export class ColorPicker extends Control {
  58086. name?: string | undefined;
  58087. private static _Epsilon;
  58088. private _colorWheelCanvas;
  58089. private _value;
  58090. private _tmpColor;
  58091. private _pointerStartedOnSquare;
  58092. private _pointerStartedOnWheel;
  58093. private _squareLeft;
  58094. private _squareTop;
  58095. private _squareSize;
  58096. private _h;
  58097. private _s;
  58098. private _v;
  58099. /**
  58100. * BABYLON.Observable raised when the value changes
  58101. */
  58102. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58103. /** Gets or sets the color of the color picker */
  58104. value: BABYLON.Color3;
  58105. /**
  58106. * Gets or sets control width
  58107. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58108. */
  58109. width: string | number;
  58110. /**
  58111. * Gets or sets control height
  58112. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58113. */
  58114. /** Gets or sets control height */
  58115. height: string | number;
  58116. /** Gets or sets control size */
  58117. size: string | number;
  58118. /**
  58119. * Creates a new ColorPicker
  58120. * @param name defines the control name
  58121. */
  58122. constructor(name?: string | undefined);
  58123. protected _getTypeName(): string;
  58124. /** @hidden */
  58125. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58126. private _updateSquareProps;
  58127. private _drawGradientSquare;
  58128. private _drawCircle;
  58129. private _createColorWheelCanvas;
  58130. private _RGBtoHSV;
  58131. private _HSVtoRGB;
  58132. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58133. private _pointerIsDown;
  58134. private _updateValueFromPointer;
  58135. private _isPointOnSquare;
  58136. 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;
  58137. /**
  58138. * This function expands the color picker by creating a color picker dialog with manual
  58139. * color value input and the ability to save colors into an array to be used later in
  58140. * subsequent launches of the dialogue.
  58141. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58142. * @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.
  58143. * @returns picked color as a hex string and the saved colors array as hex strings.
  58144. */
  58145. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58146. pickerWidth?: string;
  58147. pickerHeight?: string;
  58148. headerHeight?: string;
  58149. lastColor?: string;
  58150. swatchLimit?: number;
  58151. numSwatchesPerLine?: number;
  58152. savedColors?: Array<string>;
  58153. }): Promise<{
  58154. savedColors?: string[];
  58155. pickedColor: string;
  58156. }>;
  58157. }
  58158. }
  58159. declare module BABYLON.GUI {
  58160. /** Class used to create 2D ellipse containers */
  58161. export class Ellipse extends Container {
  58162. name?: string | undefined;
  58163. private _thickness;
  58164. /** Gets or sets border thickness */
  58165. thickness: number;
  58166. /**
  58167. * Creates a new Ellipse
  58168. * @param name defines the control name
  58169. */
  58170. constructor(name?: string | undefined);
  58171. protected _getTypeName(): string;
  58172. protected _localDraw(context: CanvasRenderingContext2D): void;
  58173. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58174. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58175. }
  58176. }
  58177. declare module BABYLON.GUI {
  58178. /**
  58179. * Class used to create a password control
  58180. */
  58181. export class InputPassword extends InputText {
  58182. protected _beforeRenderText(text: string): string;
  58183. }
  58184. }
  58185. declare module BABYLON.GUI {
  58186. /** Class used to render 2D lines */
  58187. export class Line extends Control {
  58188. name?: string | undefined;
  58189. private _lineWidth;
  58190. private _x1;
  58191. private _y1;
  58192. private _x2;
  58193. private _y2;
  58194. private _dash;
  58195. private _connectedControl;
  58196. private _connectedControlDirtyObserver;
  58197. /** Gets or sets the dash pattern */
  58198. dash: Array<number>;
  58199. /** Gets or sets the control connected with the line end */
  58200. connectedControl: Control;
  58201. /** Gets or sets start coordinates on X axis */
  58202. x1: string | number;
  58203. /** Gets or sets start coordinates on Y axis */
  58204. y1: string | number;
  58205. /** Gets or sets end coordinates on X axis */
  58206. x2: string | number;
  58207. /** Gets or sets end coordinates on Y axis */
  58208. y2: string | number;
  58209. /** Gets or sets line width */
  58210. lineWidth: number;
  58211. /** Gets or sets horizontal alignment */
  58212. horizontalAlignment: number;
  58213. /** Gets or sets vertical alignment */
  58214. verticalAlignment: number;
  58215. private readonly _effectiveX2;
  58216. private readonly _effectiveY2;
  58217. /**
  58218. * Creates a new Line
  58219. * @param name defines the control name
  58220. */
  58221. constructor(name?: string | undefined);
  58222. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58223. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58224. /**
  58225. * Move one end of the line given 3D cartesian coordinates.
  58226. * @param position Targeted world position
  58227. * @param scene BABYLON.Scene
  58228. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58229. */
  58230. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58231. /**
  58232. * Move one end of the line to a position in screen absolute space.
  58233. * @param projectedPosition Position in screen absolute space (X, Y)
  58234. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58235. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58236. }
  58237. }
  58238. declare module BABYLON.GUI {
  58239. /**
  58240. * Class used to store a point for a MultiLine object.
  58241. * The point can be pure 2D coordinates, a mesh or a control
  58242. */
  58243. export class MultiLinePoint {
  58244. private _multiLine;
  58245. private _x;
  58246. private _y;
  58247. private _control;
  58248. private _mesh;
  58249. private _controlObserver;
  58250. private _meshObserver;
  58251. /** @hidden */ point: BABYLON.Vector2;
  58252. /**
  58253. * Creates a new MultiLinePoint
  58254. * @param multiLine defines the source MultiLine object
  58255. */
  58256. constructor(multiLine: MultiLine);
  58257. /** Gets or sets x coordinate */
  58258. x: string | number;
  58259. /** Gets or sets y coordinate */
  58260. y: string | number;
  58261. /** Gets or sets the control associated with this point */
  58262. control: BABYLON.Nullable<Control>;
  58263. /** Gets or sets the mesh associated with this point */
  58264. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58265. /** Resets links */
  58266. resetLinks(): void;
  58267. /**
  58268. * Gets a translation vector
  58269. * @returns the translation vector
  58270. */
  58271. translate(): BABYLON.Vector2;
  58272. private _translatePoint;
  58273. /** Release associated resources */
  58274. dispose(): void;
  58275. }
  58276. }
  58277. declare module BABYLON.GUI {
  58278. /**
  58279. * Class used to create multi line control
  58280. */
  58281. export class MultiLine extends Control {
  58282. name?: string | undefined;
  58283. private _lineWidth;
  58284. private _dash;
  58285. private _points;
  58286. private _minX;
  58287. private _minY;
  58288. private _maxX;
  58289. private _maxY;
  58290. /**
  58291. * Creates a new MultiLine
  58292. * @param name defines the control name
  58293. */
  58294. constructor(name?: string | undefined);
  58295. /** Gets or sets dash pattern */
  58296. dash: Array<number>;
  58297. /**
  58298. * Gets point stored at specified index
  58299. * @param index defines the index to look for
  58300. * @returns the requested point if found
  58301. */
  58302. getAt(index: number): MultiLinePoint;
  58303. /** Function called when a point is updated */
  58304. onPointUpdate: () => void;
  58305. /**
  58306. * Adds new points to the point collection
  58307. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58308. * @returns the list of created MultiLinePoint
  58309. */
  58310. add(...items: (AbstractMesh | Control | {
  58311. x: string | number;
  58312. y: string | number;
  58313. })[]): MultiLinePoint[];
  58314. /**
  58315. * Adds a new point to the point collection
  58316. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58317. * @returns the created MultiLinePoint
  58318. */
  58319. push(item?: (AbstractMesh | Control | {
  58320. x: string | number;
  58321. y: string | number;
  58322. })): MultiLinePoint;
  58323. /**
  58324. * Remove a specific value or point from the active point collection
  58325. * @param value defines the value or point to remove
  58326. */
  58327. remove(value: number | MultiLinePoint): void;
  58328. /**
  58329. * Resets this object to initial state (no point)
  58330. */
  58331. reset(): void;
  58332. /**
  58333. * Resets all links
  58334. */
  58335. resetLinks(): void;
  58336. /** Gets or sets line width */
  58337. lineWidth: number;
  58338. horizontalAlignment: number;
  58339. verticalAlignment: number;
  58340. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58341. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58342. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58343. dispose(): void;
  58344. }
  58345. }
  58346. declare module BABYLON.GUI {
  58347. /**
  58348. * Class used to create radio button controls
  58349. */
  58350. export class RadioButton extends Control {
  58351. name?: string | undefined;
  58352. private _isChecked;
  58353. private _background;
  58354. private _checkSizeRatio;
  58355. private _thickness;
  58356. /** Gets or sets border thickness */
  58357. thickness: number;
  58358. /** Gets or sets group name */
  58359. group: string;
  58360. /** BABYLON.Observable raised when isChecked is changed */
  58361. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58362. /** Gets or sets a value indicating the ratio between overall size and check size */
  58363. checkSizeRatio: number;
  58364. /** Gets or sets background color */
  58365. background: string;
  58366. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58367. isChecked: boolean;
  58368. /**
  58369. * Creates a new RadioButton
  58370. * @param name defines the control name
  58371. */
  58372. constructor(name?: string | undefined);
  58373. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58374. /**
  58375. * Utility function to easily create a radio button with a header
  58376. * @param title defines the label to use for the header
  58377. * @param group defines the group to use for the radio button
  58378. * @param isChecked defines the initial state of the radio button
  58379. * @param onValueChanged defines the callback to call when value changes
  58380. * @returns a StackPanel containing the radio button and a textBlock
  58381. */
  58382. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58383. }
  58384. }
  58385. declare module BABYLON.GUI {
  58386. /**
  58387. * Class used to create slider controls
  58388. */
  58389. export class BaseSlider extends Control {
  58390. name?: string | undefined;
  58391. protected _thumbWidth: ValueAndUnit;
  58392. private _minimum;
  58393. private _maximum;
  58394. private _value;
  58395. private _isVertical;
  58396. protected _barOffset: ValueAndUnit;
  58397. private _isThumbClamped;
  58398. protected _displayThumb: boolean;
  58399. private _step;
  58400. protected _effectiveBarOffset: number;
  58401. protected _renderLeft: number;
  58402. protected _renderTop: number;
  58403. protected _renderWidth: number;
  58404. protected _renderHeight: number;
  58405. protected _backgroundBoxLength: number;
  58406. protected _backgroundBoxThickness: number;
  58407. protected _effectiveThumbThickness: number;
  58408. /** BABYLON.Observable raised when the sldier value changes */
  58409. onValueChangedObservable: BABYLON.Observable<number>;
  58410. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58411. displayThumb: boolean;
  58412. /** Gets or sets a step to apply to values (0 by default) */
  58413. step: number;
  58414. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58415. barOffset: string | number;
  58416. /** Gets main bar offset in pixels*/
  58417. readonly barOffsetInPixels: number;
  58418. /** Gets or sets thumb width */
  58419. thumbWidth: string | number;
  58420. /** Gets thumb width in pixels */
  58421. readonly thumbWidthInPixels: number;
  58422. /** Gets or sets minimum value */
  58423. minimum: number;
  58424. /** Gets or sets maximum value */
  58425. maximum: number;
  58426. /** Gets or sets current value */
  58427. value: number;
  58428. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58429. isVertical: boolean;
  58430. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58431. isThumbClamped: boolean;
  58432. /**
  58433. * Creates a new BaseSlider
  58434. * @param name defines the control name
  58435. */
  58436. constructor(name?: string | undefined);
  58437. protected _getTypeName(): string;
  58438. protected _getThumbPosition(): number;
  58439. protected _getThumbThickness(type: string): number;
  58440. protected _prepareRenderingData(type: string): void;
  58441. private _pointerIsDown;
  58442. /** @hidden */
  58443. 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;
  58444. }
  58445. }
  58446. declare module BABYLON.GUI {
  58447. /**
  58448. * Class used to create slider controls
  58449. */
  58450. export class Slider extends BaseSlider {
  58451. name?: string | undefined;
  58452. private _background;
  58453. private _borderColor;
  58454. private _isThumbCircle;
  58455. protected _displayValueBar: boolean;
  58456. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58457. displayValueBar: boolean;
  58458. /** Gets or sets border color */
  58459. borderColor: string;
  58460. /** Gets or sets background color */
  58461. background: string;
  58462. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58463. isThumbCircle: boolean;
  58464. /**
  58465. * Creates a new Slider
  58466. * @param name defines the control name
  58467. */
  58468. constructor(name?: string | undefined);
  58469. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58470. }
  58471. }
  58472. declare module BABYLON.GUI {
  58473. /** Class used to create a RadioGroup
  58474. * which contains groups of radio buttons
  58475. */
  58476. export class SelectorGroup {
  58477. /** name of SelectorGroup */
  58478. name: string;
  58479. private _groupPanel;
  58480. private _selectors;
  58481. private _groupHeader;
  58482. /**
  58483. * Creates a new SelectorGroup
  58484. * @param name of group, used as a group heading
  58485. */
  58486. constructor(
  58487. /** name of SelectorGroup */
  58488. name: string);
  58489. /** Gets the groupPanel of the SelectorGroup */
  58490. readonly groupPanel: StackPanel;
  58491. /** Gets the selectors array */
  58492. readonly selectors: StackPanel[];
  58493. /** Gets and sets the group header */
  58494. header: string;
  58495. /** @hidden */
  58496. private _addGroupHeader;
  58497. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58498. /** Removes the selector at the given position
  58499. * @param selectorNb the position of the selector within the group
  58500. */
  58501. removeSelector(selectorNb: number): void;
  58502. }
  58503. /** Class used to create a CheckboxGroup
  58504. * which contains groups of checkbox buttons
  58505. */
  58506. export class CheckboxGroup extends SelectorGroup {
  58507. /** Adds a checkbox as a control
  58508. * @param text is the label for the selector
  58509. * @param func is the function called when the Selector is checked
  58510. * @param checked is true when Selector is checked
  58511. */
  58512. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58513. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58514. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58515. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58516. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58517. }
  58518. /** Class used to create a RadioGroup
  58519. * which contains groups of radio buttons
  58520. */
  58521. export class RadioGroup extends SelectorGroup {
  58522. private _selectNb;
  58523. /** Adds a radio button as a control
  58524. * @param label is the label for the selector
  58525. * @param func is the function called when the Selector is checked
  58526. * @param checked is true when Selector is checked
  58527. */
  58528. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58529. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58530. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58531. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58532. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58533. }
  58534. /** Class used to create a SliderGroup
  58535. * which contains groups of slider buttons
  58536. */
  58537. export class SliderGroup extends SelectorGroup {
  58538. /**
  58539. * Adds a slider to the SelectorGroup
  58540. * @param label is the label for the SliderBar
  58541. * @param func is the function called when the Slider moves
  58542. * @param unit is a string describing the units used, eg degrees or metres
  58543. * @param min is the minimum value for the Slider
  58544. * @param max is the maximum value for the Slider
  58545. * @param value is the start value for the Slider between min and max
  58546. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58547. */
  58548. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58549. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58550. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58551. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58552. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58553. }
  58554. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58555. * @see http://doc.babylonjs.com/how_to/selector
  58556. */
  58557. export class SelectionPanel extends Rectangle {
  58558. /** name of SelectionPanel */
  58559. name: string;
  58560. /** an array of SelectionGroups */
  58561. groups: SelectorGroup[];
  58562. private _panel;
  58563. private _buttonColor;
  58564. private _buttonBackground;
  58565. private _headerColor;
  58566. private _barColor;
  58567. private _barHeight;
  58568. private _spacerHeight;
  58569. private _labelColor;
  58570. private _groups;
  58571. private _bars;
  58572. /**
  58573. * Creates a new SelectionPanel
  58574. * @param name of SelectionPanel
  58575. * @param groups is an array of SelectionGroups
  58576. */
  58577. constructor(
  58578. /** name of SelectionPanel */
  58579. name: string,
  58580. /** an array of SelectionGroups */
  58581. groups?: SelectorGroup[]);
  58582. protected _getTypeName(): string;
  58583. /** Gets or sets the headerColor */
  58584. headerColor: string;
  58585. private _setHeaderColor;
  58586. /** Gets or sets the button color */
  58587. buttonColor: string;
  58588. private _setbuttonColor;
  58589. /** Gets or sets the label color */
  58590. labelColor: string;
  58591. private _setLabelColor;
  58592. /** Gets or sets the button background */
  58593. buttonBackground: string;
  58594. private _setButtonBackground;
  58595. /** Gets or sets the color of separator bar */
  58596. barColor: string;
  58597. private _setBarColor;
  58598. /** Gets or sets the height of separator bar */
  58599. barHeight: string;
  58600. private _setBarHeight;
  58601. /** Gets or sets the height of spacers*/
  58602. spacerHeight: string;
  58603. private _setSpacerHeight;
  58604. /** Adds a bar between groups */
  58605. private _addSpacer;
  58606. /** Add a group to the selection panel
  58607. * @param group is the selector group to add
  58608. */
  58609. addGroup(group: SelectorGroup): void;
  58610. /** Remove the group from the given position
  58611. * @param groupNb is the position of the group in the list
  58612. */
  58613. removeGroup(groupNb: number): void;
  58614. /** Change a group header label
  58615. * @param label is the new group header label
  58616. * @param groupNb is the number of the group to relabel
  58617. * */
  58618. setHeaderName(label: string, groupNb: number): void;
  58619. /** Change selector label to the one given
  58620. * @param label is the new selector label
  58621. * @param groupNb is the number of the groupcontaining the selector
  58622. * @param selectorNb is the number of the selector within a group to relabel
  58623. * */
  58624. relabel(label: string, groupNb: number, selectorNb: number): void;
  58625. /** For a given group position remove the selector at the given position
  58626. * @param groupNb is the number of the group to remove the selector from
  58627. * @param selectorNb is the number of the selector within the group
  58628. */
  58629. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58630. /** For a given group position of correct type add a checkbox button
  58631. * @param groupNb is the number of the group to remove the selector from
  58632. * @param label is the label for the selector
  58633. * @param func is the function called when the Selector is checked
  58634. * @param checked is true when Selector is checked
  58635. */
  58636. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58637. /** For a given group position of correct type add a radio button
  58638. * @param groupNb is the number of the group to remove the selector from
  58639. * @param label is the label for the selector
  58640. * @param func is the function called when the Selector is checked
  58641. * @param checked is true when Selector is checked
  58642. */
  58643. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58644. /**
  58645. * For a given slider group add a slider
  58646. * @param groupNb is the number of the group to add the slider to
  58647. * @param label is the label for the Slider
  58648. * @param func is the function called when the Slider moves
  58649. * @param unit is a string describing the units used, eg degrees or metres
  58650. * @param min is the minimum value for the Slider
  58651. * @param max is the maximum value for the Slider
  58652. * @param value is the start value for the Slider between min and max
  58653. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58654. */
  58655. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58656. }
  58657. }
  58658. declare module BABYLON.GUI {
  58659. /**
  58660. * Class used to hold a the container for ScrollViewer
  58661. * @hidden
  58662. */
  58663. export class _ScrollViewerWindow extends Container {
  58664. parentClientWidth: number;
  58665. parentClientHeight: number;
  58666. /**
  58667. * Creates a new ScrollViewerWindow
  58668. * @param name of ScrollViewerWindow
  58669. */
  58670. constructor(name?: string);
  58671. protected _getTypeName(): string;
  58672. /** @hidden */
  58673. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58674. protected _postMeasure(): void;
  58675. }
  58676. }
  58677. declare module BABYLON.GUI {
  58678. /**
  58679. * Class used to create slider controls
  58680. */
  58681. export class ScrollBar extends BaseSlider {
  58682. name?: string | undefined;
  58683. private _background;
  58684. private _borderColor;
  58685. private _thumbMeasure;
  58686. /** Gets or sets border color */
  58687. borderColor: string;
  58688. /** Gets or sets background color */
  58689. background: string;
  58690. /**
  58691. * Creates a new Slider
  58692. * @param name defines the control name
  58693. */
  58694. constructor(name?: string | undefined);
  58695. protected _getTypeName(): string;
  58696. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58697. private _first;
  58698. private _originX;
  58699. private _originY;
  58700. /** @hidden */
  58701. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58702. }
  58703. }
  58704. declare module BABYLON.GUI {
  58705. /**
  58706. * Class used to hold a viewer window and sliders in a grid
  58707. */
  58708. export class ScrollViewer extends Rectangle {
  58709. private _grid;
  58710. private _horizontalBarSpace;
  58711. private _verticalBarSpace;
  58712. private _dragSpace;
  58713. private _horizontalBar;
  58714. private _verticalBar;
  58715. private _barColor;
  58716. private _barBackground;
  58717. private _barSize;
  58718. private _endLeft;
  58719. private _endTop;
  58720. private _window;
  58721. private _pointerIsOver;
  58722. private _wheelPrecision;
  58723. private _onPointerObserver;
  58724. private _clientWidth;
  58725. private _clientHeight;
  58726. /**
  58727. * Gets the horizontal scrollbar
  58728. */
  58729. readonly horizontalBar: ScrollBar;
  58730. /**
  58731. * Gets the vertical scrollbar
  58732. */
  58733. readonly verticalBar: ScrollBar;
  58734. /**
  58735. * Adds a new control to the current container
  58736. * @param control defines the control to add
  58737. * @returns the current container
  58738. */
  58739. addControl(control: BABYLON.Nullable<Control>): Container;
  58740. /**
  58741. * Removes a control from the current container
  58742. * @param control defines the control to remove
  58743. * @returns the current container
  58744. */
  58745. removeControl(control: Control): Container;
  58746. /** Gets the list of children */
  58747. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58748. /**
  58749. * Creates a new ScrollViewer
  58750. * @param name of ScrollViewer
  58751. */
  58752. constructor(name?: string);
  58753. /** Reset the scroll viewer window to initial size */
  58754. resetWindow(): void;
  58755. protected _getTypeName(): string;
  58756. private _buildClientSizes;
  58757. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58758. protected _postMeasure(): void;
  58759. /**
  58760. * Gets or sets the mouse wheel precision
  58761. * from 0 to 1 with a default value of 0.05
  58762. * */
  58763. wheelPrecision: number;
  58764. /** Gets or sets the bar color */
  58765. barColor: string;
  58766. /** Gets or sets the size of the bar */
  58767. barSize: number;
  58768. /** Gets or sets the bar background */
  58769. barBackground: string;
  58770. /** @hidden */
  58771. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58772. /** @hidden */
  58773. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58774. /** Releases associated resources */
  58775. dispose(): void;
  58776. }
  58777. }
  58778. declare module BABYLON.GUI {
  58779. /** Class used to render a grid */
  58780. export class DisplayGrid extends Control {
  58781. name?: string | undefined;
  58782. private _cellWidth;
  58783. private _cellHeight;
  58784. private _minorLineTickness;
  58785. private _minorLineColor;
  58786. private _majorLineTickness;
  58787. private _majorLineColor;
  58788. private _majorLineFrequency;
  58789. private _background;
  58790. private _displayMajorLines;
  58791. private _displayMinorLines;
  58792. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58793. displayMinorLines: boolean;
  58794. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58795. displayMajorLines: boolean;
  58796. /** Gets or sets background color (Black by default) */
  58797. background: string;
  58798. /** Gets or sets the width of each cell (20 by default) */
  58799. cellWidth: number;
  58800. /** Gets or sets the height of each cell (20 by default) */
  58801. cellHeight: number;
  58802. /** Gets or sets the tickness of minor lines (1 by default) */
  58803. minorLineTickness: number;
  58804. /** Gets or sets the color of minor lines (DarkGray by default) */
  58805. minorLineColor: string;
  58806. /** Gets or sets the tickness of major lines (2 by default) */
  58807. majorLineTickness: number;
  58808. /** Gets or sets the color of major lines (White by default) */
  58809. majorLineColor: string;
  58810. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58811. majorLineFrequency: number;
  58812. /**
  58813. * Creates a new GridDisplayRectangle
  58814. * @param name defines the control name
  58815. */
  58816. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58817. protected _getTypeName(): string;
  58818. }
  58819. }
  58820. declare module BABYLON.GUI {
  58821. /**
  58822. * Class used to create slider controls based on images
  58823. */
  58824. export class ImageBasedSlider extends BaseSlider {
  58825. name?: string | undefined;
  58826. private _backgroundImage;
  58827. private _thumbImage;
  58828. private _valueBarImage;
  58829. private _tempMeasure;
  58830. displayThumb: boolean;
  58831. /**
  58832. * Gets or sets the image used to render the background
  58833. */
  58834. backgroundImage: Image;
  58835. /**
  58836. * Gets or sets the image used to render the value bar
  58837. */
  58838. valueBarImage: Image;
  58839. /**
  58840. * Gets or sets the image used to render the thumb
  58841. */
  58842. thumbImage: Image;
  58843. /**
  58844. * Creates a new ImageBasedSlider
  58845. * @param name defines the control name
  58846. */
  58847. constructor(name?: string | undefined);
  58848. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58849. }
  58850. }
  58851. declare module BABYLON.GUI {
  58852. /**
  58853. * Forcing an export so that this code will execute
  58854. * @hidden
  58855. */
  58856. const name = "Statics";
  58857. }
  58858. declare module BABYLON.GUI {
  58859. /**
  58860. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58861. */
  58862. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58863. /**
  58864. * Define the instrumented AdvancedDynamicTexture.
  58865. */
  58866. texture: AdvancedDynamicTexture;
  58867. private _captureRenderTime;
  58868. private _renderTime;
  58869. private _captureLayoutTime;
  58870. private _layoutTime;
  58871. private _onBeginRenderObserver;
  58872. private _onEndRenderObserver;
  58873. private _onBeginLayoutObserver;
  58874. private _onEndLayoutObserver;
  58875. /**
  58876. * Gets the perf counter used to capture render time
  58877. */
  58878. readonly renderTimeCounter: BABYLON.PerfCounter;
  58879. /**
  58880. * Gets the perf counter used to capture layout time
  58881. */
  58882. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58883. /**
  58884. * Enable or disable the render time capture
  58885. */
  58886. captureRenderTime: boolean;
  58887. /**
  58888. * Enable or disable the layout time capture
  58889. */
  58890. captureLayoutTime: boolean;
  58891. /**
  58892. * Instantiates a new advanced dynamic texture instrumentation.
  58893. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58894. * @param texture Defines the AdvancedDynamicTexture to instrument
  58895. */
  58896. constructor(
  58897. /**
  58898. * Define the instrumented AdvancedDynamicTexture.
  58899. */
  58900. texture: AdvancedDynamicTexture);
  58901. /**
  58902. * Dispose and release associated resources.
  58903. */
  58904. dispose(): void;
  58905. }
  58906. }
  58907. declare module BABYLON.GUI {
  58908. /**
  58909. * Class used to create containers for controls
  58910. */
  58911. export class Container3D extends Control3D {
  58912. private _blockLayout;
  58913. /**
  58914. * Gets the list of child controls
  58915. */
  58916. protected _children: Control3D[];
  58917. /**
  58918. * Gets the list of child controls
  58919. */
  58920. readonly children: Array<Control3D>;
  58921. /**
  58922. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58923. * This is helpful to optimize layout operation when adding multiple children in a row
  58924. */
  58925. blockLayout: boolean;
  58926. /**
  58927. * Creates a new container
  58928. * @param name defines the container name
  58929. */
  58930. constructor(name?: string);
  58931. /**
  58932. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58933. * @returns the current container
  58934. */
  58935. updateLayout(): Container3D;
  58936. /**
  58937. * Gets a boolean indicating if the given control is in the children of this control
  58938. * @param control defines the control to check
  58939. * @returns true if the control is in the child list
  58940. */
  58941. containsControl(control: Control3D): boolean;
  58942. /**
  58943. * Adds a control to the children of this control
  58944. * @param control defines the control to add
  58945. * @returns the current container
  58946. */
  58947. addControl(control: Control3D): Container3D;
  58948. /**
  58949. * This function will be called everytime a new control is added
  58950. */
  58951. protected _arrangeChildren(): void;
  58952. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58953. /**
  58954. * Removes a control from the children of this control
  58955. * @param control defines the control to remove
  58956. * @returns the current container
  58957. */
  58958. removeControl(control: Control3D): Container3D;
  58959. protected _getTypeName(): string;
  58960. /**
  58961. * Releases all associated resources
  58962. */
  58963. dispose(): void;
  58964. /** Control rotation will remain unchanged */
  58965. static readonly UNSET_ORIENTATION: number;
  58966. /** Control will rotate to make it look at sphere central axis */
  58967. static readonly FACEORIGIN_ORIENTATION: number;
  58968. /** Control will rotate to make it look back at sphere central axis */
  58969. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58970. /** Control will rotate to look at z axis (0, 0, 1) */
  58971. static readonly FACEFORWARD_ORIENTATION: number;
  58972. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58973. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58974. }
  58975. }
  58976. declare module BABYLON.GUI {
  58977. /**
  58978. * Class used to manage 3D user interface
  58979. * @see http://doc.babylonjs.com/how_to/gui3d
  58980. */
  58981. export class GUI3DManager implements BABYLON.IDisposable {
  58982. private _scene;
  58983. private _sceneDisposeObserver;
  58984. private _utilityLayer;
  58985. private _rootContainer;
  58986. private _pointerObserver;
  58987. private _pointerOutObserver;
  58988. /** @hidden */ lastPickedControl: Control3D;
  58989. /** @hidden */ lastControlOver: {
  58990. [pointerId: number]: Control3D;
  58991. };
  58992. /** @hidden */ lastControlDown: {
  58993. [pointerId: number]: Control3D;
  58994. };
  58995. /**
  58996. * BABYLON.Observable raised when the point picked by the pointer events changed
  58997. */
  58998. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58999. /** @hidden */ sharedMaterials: {
  59000. [key: string]: BABYLON.Material;
  59001. };
  59002. /** Gets the hosting scene */
  59003. readonly scene: BABYLON.Scene;
  59004. /** Gets associated utility layer */
  59005. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59006. /**
  59007. * Creates a new GUI3DManager
  59008. * @param scene
  59009. */
  59010. constructor(scene?: BABYLON.Scene);
  59011. private _handlePointerOut;
  59012. private _doPicking;
  59013. /**
  59014. * Gets the root container
  59015. */
  59016. readonly rootContainer: Container3D;
  59017. /**
  59018. * Gets a boolean indicating if the given control is in the root child list
  59019. * @param control defines the control to check
  59020. * @returns true if the control is in the root child list
  59021. */
  59022. containsControl(control: Control3D): boolean;
  59023. /**
  59024. * Adds a control to the root child list
  59025. * @param control defines the control to add
  59026. * @returns the current manager
  59027. */
  59028. addControl(control: Control3D): GUI3DManager;
  59029. /**
  59030. * Removes a control from the root child list
  59031. * @param control defines the control to remove
  59032. * @returns the current container
  59033. */
  59034. removeControl(control: Control3D): GUI3DManager;
  59035. /**
  59036. * Releases all associated resources
  59037. */
  59038. dispose(): void;
  59039. }
  59040. }
  59041. declare module BABYLON.GUI {
  59042. /**
  59043. * Class used to transport BABYLON.Vector3 information for pointer events
  59044. */
  59045. export class Vector3WithInfo extends BABYLON.Vector3 {
  59046. /** defines the current mouse button index */
  59047. buttonIndex: number;
  59048. /**
  59049. * Creates a new Vector3WithInfo
  59050. * @param source defines the vector3 data to transport
  59051. * @param buttonIndex defines the current mouse button index
  59052. */
  59053. constructor(source: BABYLON.Vector3,
  59054. /** defines the current mouse button index */
  59055. buttonIndex?: number);
  59056. }
  59057. }
  59058. declare module BABYLON.GUI {
  59059. /**
  59060. * Class used as base class for controls
  59061. */
  59062. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59063. /** Defines the control name */
  59064. name?: string | undefined;
  59065. /** @hidden */ host: GUI3DManager;
  59066. private _node;
  59067. private _downCount;
  59068. private _enterCount;
  59069. private _downPointerIds;
  59070. private _isVisible;
  59071. /** Gets or sets the control position in world space */
  59072. position: BABYLON.Vector3;
  59073. /** Gets or sets the control scaling in world space */
  59074. scaling: BABYLON.Vector3;
  59075. /** Callback used to start pointer enter animation */
  59076. pointerEnterAnimation: () => void;
  59077. /** Callback used to start pointer out animation */
  59078. pointerOutAnimation: () => void;
  59079. /** Callback used to start pointer down animation */
  59080. pointerDownAnimation: () => void;
  59081. /** Callback used to start pointer up animation */
  59082. pointerUpAnimation: () => void;
  59083. /**
  59084. * An event triggered when the pointer move over the control
  59085. */
  59086. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59087. /**
  59088. * An event triggered when the pointer move out of the control
  59089. */
  59090. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59091. /**
  59092. * An event triggered when the pointer taps the control
  59093. */
  59094. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59095. /**
  59096. * An event triggered when pointer is up
  59097. */
  59098. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59099. /**
  59100. * An event triggered when a control is clicked on (with a mouse)
  59101. */
  59102. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59103. /**
  59104. * An event triggered when pointer enters the control
  59105. */
  59106. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59107. /**
  59108. * Gets or sets the parent container
  59109. */
  59110. parent: BABYLON.Nullable<Container3D>;
  59111. private _behaviors;
  59112. /**
  59113. * Gets the list of attached behaviors
  59114. * @see http://doc.babylonjs.com/features/behaviour
  59115. */
  59116. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59117. /**
  59118. * Attach a behavior to the control
  59119. * @see http://doc.babylonjs.com/features/behaviour
  59120. * @param behavior defines the behavior to attach
  59121. * @returns the current control
  59122. */
  59123. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59124. /**
  59125. * Remove an attached behavior
  59126. * @see http://doc.babylonjs.com/features/behaviour
  59127. * @param behavior defines the behavior to attach
  59128. * @returns the current control
  59129. */
  59130. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59131. /**
  59132. * Gets an attached behavior by name
  59133. * @param name defines the name of the behavior to look for
  59134. * @see http://doc.babylonjs.com/features/behaviour
  59135. * @returns null if behavior was not found else the requested behavior
  59136. */
  59137. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59138. /** Gets or sets a boolean indicating if the control is visible */
  59139. isVisible: boolean;
  59140. /**
  59141. * Creates a new control
  59142. * @param name defines the control name
  59143. */
  59144. constructor(
  59145. /** Defines the control name */
  59146. name?: string | undefined);
  59147. /**
  59148. * Gets a string representing the class name
  59149. */
  59150. readonly typeName: string;
  59151. /**
  59152. * Get the current class name of the control.
  59153. * @returns current class name
  59154. */
  59155. getClassName(): string;
  59156. protected _getTypeName(): string;
  59157. /**
  59158. * Gets the transform node used by this control
  59159. */
  59160. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59161. /**
  59162. * Gets the mesh used to render this control
  59163. */
  59164. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59165. /**
  59166. * Link the control as child of the given node
  59167. * @param node defines the node to link to. Use null to unlink the control
  59168. * @returns the current control
  59169. */
  59170. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59171. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59172. /**
  59173. * Node creation.
  59174. * Can be overriden by children
  59175. * @param scene defines the scene where the node must be attached
  59176. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59177. */
  59178. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59179. /**
  59180. * Affect a material to the given mesh
  59181. * @param mesh defines the mesh which will represent the control
  59182. */
  59183. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59184. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59185. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59186. /** @hidden */ onPointerOut(target: Control3D): void;
  59187. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59188. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59189. /** @hidden */
  59190. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59191. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59192. /** @hidden */ disposeNode(): void;
  59193. /**
  59194. * Releases all associated resources
  59195. */
  59196. dispose(): void;
  59197. }
  59198. }
  59199. declare module BABYLON.GUI {
  59200. /**
  59201. * Class used as a root to all buttons
  59202. */
  59203. export class AbstractButton3D extends Control3D {
  59204. /**
  59205. * Creates a new button
  59206. * @param name defines the control name
  59207. */
  59208. constructor(name?: string);
  59209. protected _getTypeName(): string;
  59210. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59211. }
  59212. }
  59213. declare module BABYLON.GUI {
  59214. /**
  59215. * Class used to create a button in 3D
  59216. */
  59217. export class Button3D extends AbstractButton3D {
  59218. /** @hidden */
  59219. protected _currentMaterial: BABYLON.Material;
  59220. private _facadeTexture;
  59221. private _content;
  59222. private _contentResolution;
  59223. private _contentScaleRatio;
  59224. /**
  59225. * Gets or sets the texture resolution used to render content (512 by default)
  59226. */
  59227. contentResolution: BABYLON.int;
  59228. /**
  59229. * Gets or sets the texture scale ratio used to render content (2 by default)
  59230. */
  59231. contentScaleRatio: number;
  59232. protected _disposeFacadeTexture(): void;
  59233. protected _resetContent(): void;
  59234. /**
  59235. * Creates a new button
  59236. * @param name defines the control name
  59237. */
  59238. constructor(name?: string);
  59239. /**
  59240. * Gets or sets the GUI 2D content used to display the button's facade
  59241. */
  59242. content: Control;
  59243. /**
  59244. * Apply the facade texture (created from the content property).
  59245. * This function can be overloaded by child classes
  59246. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59247. */
  59248. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59249. protected _getTypeName(): string;
  59250. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59251. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59252. /**
  59253. * Releases all associated resources
  59254. */
  59255. dispose(): void;
  59256. }
  59257. }
  59258. declare module BABYLON.GUI {
  59259. /**
  59260. * Abstract class used to create a container panel deployed on the surface of a volume
  59261. */
  59262. export abstract class VolumeBasedPanel extends Container3D {
  59263. private _columns;
  59264. private _rows;
  59265. private _rowThenColum;
  59266. private _orientation;
  59267. protected _cellWidth: number;
  59268. protected _cellHeight: number;
  59269. /**
  59270. * Gets or sets the distance between elements
  59271. */
  59272. margin: number;
  59273. /**
  59274. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59275. * | Value | Type | Description |
  59276. * | ----- | ----------------------------------- | ----------- |
  59277. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59278. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59279. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59280. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59281. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59282. */
  59283. orientation: number;
  59284. /**
  59285. * Gets or sets the number of columns requested (10 by default).
  59286. * The panel will automatically compute the number of rows based on number of child controls.
  59287. */
  59288. columns: BABYLON.int;
  59289. /**
  59290. * Gets or sets a the number of rows requested.
  59291. * The panel will automatically compute the number of columns based on number of child controls.
  59292. */
  59293. rows: BABYLON.int;
  59294. /**
  59295. * Creates new VolumeBasedPanel
  59296. */
  59297. constructor();
  59298. protected _arrangeChildren(): void;
  59299. /** Child classes must implement this function to provide correct control positioning */
  59300. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59301. /** Child classes can implement this function to provide additional processing */
  59302. protected _finalProcessing(): void;
  59303. }
  59304. }
  59305. declare module BABYLON.GUI {
  59306. /**
  59307. * Class used to create a container panel deployed on the surface of a cylinder
  59308. */
  59309. export class CylinderPanel extends VolumeBasedPanel {
  59310. private _radius;
  59311. /**
  59312. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59313. */
  59314. radius: BABYLON.float;
  59315. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59316. private _cylindricalMapping;
  59317. }
  59318. }
  59319. declare module BABYLON.GUI {
  59320. /** @hidden */
  59321. export var fluentVertexShader: {
  59322. name: string;
  59323. shader: string;
  59324. };
  59325. }
  59326. declare module BABYLON.GUI {
  59327. /** @hidden */
  59328. export var fluentPixelShader: {
  59329. name: string;
  59330. shader: string;
  59331. };
  59332. }
  59333. declare module BABYLON.GUI {
  59334. /** @hidden */
  59335. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59336. INNERGLOW: boolean;
  59337. BORDER: boolean;
  59338. HOVERLIGHT: boolean;
  59339. TEXTURE: boolean;
  59340. constructor();
  59341. }
  59342. /**
  59343. * Class used to render controls with fluent desgin
  59344. */
  59345. export class FluentMaterial extends BABYLON.PushMaterial {
  59346. /**
  59347. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59348. */
  59349. innerGlowColorIntensity: number;
  59350. /**
  59351. * Gets or sets the inner glow color (white by default)
  59352. */
  59353. innerGlowColor: BABYLON.Color3;
  59354. /**
  59355. * Gets or sets alpha value (default is 1.0)
  59356. */
  59357. alpha: number;
  59358. /**
  59359. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59360. */
  59361. albedoColor: BABYLON.Color3;
  59362. /**
  59363. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59364. */
  59365. renderBorders: boolean;
  59366. /**
  59367. * Gets or sets border width (default is 0.5)
  59368. */
  59369. borderWidth: number;
  59370. /**
  59371. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59372. */
  59373. edgeSmoothingValue: number;
  59374. /**
  59375. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59376. */
  59377. borderMinValue: number;
  59378. /**
  59379. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59380. */
  59381. renderHoverLight: boolean;
  59382. /**
  59383. * Gets or sets the radius used to render the hover light (default is 1.0)
  59384. */
  59385. hoverRadius: number;
  59386. /**
  59387. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59388. */
  59389. hoverColor: BABYLON.Color4;
  59390. /**
  59391. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59392. */
  59393. hoverPosition: BABYLON.Vector3;
  59394. private _albedoTexture;
  59395. /** Gets or sets the texture to use for albedo color */
  59396. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59397. /**
  59398. * Creates a new Fluent material
  59399. * @param name defines the name of the material
  59400. * @param scene defines the hosting scene
  59401. */
  59402. constructor(name: string, scene: BABYLON.Scene);
  59403. needAlphaBlending(): boolean;
  59404. needAlphaTesting(): boolean;
  59405. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59406. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59407. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59408. getActiveTextures(): BABYLON.BaseTexture[];
  59409. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59410. dispose(forceDisposeEffect?: boolean): void;
  59411. clone(name: string): FluentMaterial;
  59412. serialize(): any;
  59413. getClassName(): string;
  59414. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59415. }
  59416. }
  59417. declare module BABYLON.GUI {
  59418. /**
  59419. * Class used to create a holographic button in 3D
  59420. */
  59421. export class HolographicButton extends Button3D {
  59422. private _backPlate;
  59423. private _textPlate;
  59424. private _frontPlate;
  59425. private _text;
  59426. private _imageUrl;
  59427. private _shareMaterials;
  59428. private _frontMaterial;
  59429. private _backMaterial;
  59430. private _plateMaterial;
  59431. private _pickedPointObserver;
  59432. private _tooltipFade;
  59433. private _tooltipTextBlock;
  59434. private _tooltipTexture;
  59435. private _tooltipMesh;
  59436. private _tooltipHoverObserver;
  59437. private _tooltipOutObserver;
  59438. private _disposeTooltip;
  59439. /**
  59440. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59441. */
  59442. tooltipText: BABYLON.Nullable<string>;
  59443. /**
  59444. * Gets or sets text for the button
  59445. */
  59446. text: string;
  59447. /**
  59448. * Gets or sets the image url for the button
  59449. */
  59450. imageUrl: string;
  59451. /**
  59452. * Gets the back material used by this button
  59453. */
  59454. readonly backMaterial: FluentMaterial;
  59455. /**
  59456. * Gets the front material used by this button
  59457. */
  59458. readonly frontMaterial: FluentMaterial;
  59459. /**
  59460. * Gets the plate material used by this button
  59461. */
  59462. readonly plateMaterial: BABYLON.StandardMaterial;
  59463. /**
  59464. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59465. */
  59466. readonly shareMaterials: boolean;
  59467. /**
  59468. * Creates a new button
  59469. * @param name defines the control name
  59470. */
  59471. constructor(name?: string, shareMaterials?: boolean);
  59472. protected _getTypeName(): string;
  59473. private _rebuildContent;
  59474. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59475. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59476. private _createBackMaterial;
  59477. private _createFrontMaterial;
  59478. private _createPlateMaterial;
  59479. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59480. /**
  59481. * Releases all associated resources
  59482. */
  59483. dispose(): void;
  59484. }
  59485. }
  59486. declare module BABYLON.GUI {
  59487. /**
  59488. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59489. */
  59490. export class MeshButton3D extends Button3D {
  59491. /** @hidden */
  59492. protected _currentMesh: BABYLON.Mesh;
  59493. /**
  59494. * Creates a new 3D button based on a mesh
  59495. * @param mesh mesh to become a 3D button
  59496. * @param name defines the control name
  59497. */
  59498. constructor(mesh: BABYLON.Mesh, name?: string);
  59499. protected _getTypeName(): string;
  59500. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59501. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59502. }
  59503. }
  59504. declare module BABYLON.GUI {
  59505. /**
  59506. * Class used to create a container panel deployed on the surface of a plane
  59507. */
  59508. export class PlanePanel extends VolumeBasedPanel {
  59509. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59510. }
  59511. }
  59512. declare module BABYLON.GUI {
  59513. /**
  59514. * Class used to create a container panel where items get randomized planar mapping
  59515. */
  59516. export class ScatterPanel extends VolumeBasedPanel {
  59517. private _iteration;
  59518. /**
  59519. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59520. */
  59521. iteration: BABYLON.float;
  59522. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59523. private _scatterMapping;
  59524. protected _finalProcessing(): void;
  59525. }
  59526. }
  59527. declare module BABYLON.GUI {
  59528. /**
  59529. * Class used to create a container panel deployed on the surface of a sphere
  59530. */
  59531. export class SpherePanel extends VolumeBasedPanel {
  59532. private _radius;
  59533. /**
  59534. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59535. */
  59536. radius: BABYLON.float;
  59537. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59538. private _sphericalMapping;
  59539. }
  59540. }
  59541. declare module BABYLON.GUI {
  59542. /**
  59543. * Class used to create a stack panel in 3D on XY plane
  59544. */
  59545. export class StackPanel3D extends Container3D {
  59546. private _isVertical;
  59547. /**
  59548. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59549. */
  59550. isVertical: boolean;
  59551. /**
  59552. * Gets or sets the distance between elements
  59553. */
  59554. margin: number;
  59555. /**
  59556. * Creates new StackPanel
  59557. * @param isVertical
  59558. */
  59559. constructor(isVertical?: boolean);
  59560. protected _arrangeChildren(): void;
  59561. }
  59562. }
  59563. declare module BABYLON {
  59564. /**
  59565. * Mode that determines the coordinate system to use.
  59566. */
  59567. export enum GLTFLoaderCoordinateSystemMode {
  59568. /**
  59569. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59570. */
  59571. AUTO = 0,
  59572. /**
  59573. * Sets the useRightHandedSystem flag on the scene.
  59574. */
  59575. FORCE_RIGHT_HANDED = 1
  59576. }
  59577. /**
  59578. * Mode that determines what animations will start.
  59579. */
  59580. export enum GLTFLoaderAnimationStartMode {
  59581. /**
  59582. * No animation will start.
  59583. */
  59584. NONE = 0,
  59585. /**
  59586. * The first animation will start.
  59587. */
  59588. FIRST = 1,
  59589. /**
  59590. * All animations will start.
  59591. */
  59592. ALL = 2
  59593. }
  59594. /**
  59595. * Interface that contains the data for the glTF asset.
  59596. */
  59597. export interface IGLTFLoaderData {
  59598. /**
  59599. * Object that represents the glTF JSON.
  59600. */
  59601. json: Object;
  59602. /**
  59603. * The BIN chunk of a binary glTF.
  59604. */
  59605. bin: Nullable<ArrayBufferView>;
  59606. }
  59607. /**
  59608. * Interface for extending the loader.
  59609. */
  59610. export interface IGLTFLoaderExtension {
  59611. /**
  59612. * The name of this extension.
  59613. */
  59614. readonly name: string;
  59615. /**
  59616. * Defines whether this extension is enabled.
  59617. */
  59618. enabled: boolean;
  59619. }
  59620. /**
  59621. * Loader state.
  59622. */
  59623. export enum GLTFLoaderState {
  59624. /**
  59625. * The asset is loading.
  59626. */
  59627. LOADING = 0,
  59628. /**
  59629. * The asset is ready for rendering.
  59630. */
  59631. READY = 1,
  59632. /**
  59633. * The asset is completely loaded.
  59634. */
  59635. COMPLETE = 2
  59636. }
  59637. /** @hidden */
  59638. export interface IGLTFLoader extends IDisposable {
  59639. readonly state: Nullable<GLTFLoaderState>;
  59640. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59641. meshes: AbstractMesh[];
  59642. particleSystems: IParticleSystem[];
  59643. skeletons: Skeleton[];
  59644. animationGroups: AnimationGroup[];
  59645. }>;
  59646. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59647. }
  59648. /**
  59649. * File loader for loading glTF files into a scene.
  59650. */
  59651. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59652. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59653. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59654. /**
  59655. * Raised when the asset has been parsed
  59656. */
  59657. onParsedObservable: Observable<IGLTFLoaderData>;
  59658. private _onParsedObserver;
  59659. /**
  59660. * Raised when the asset has been parsed
  59661. */
  59662. onParsed: (loaderData: IGLTFLoaderData) => void;
  59663. /**
  59664. * 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.
  59665. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59666. * Defaults to true.
  59667. * @hidden
  59668. */
  59669. static IncrementalLoading: boolean;
  59670. /**
  59671. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59672. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59673. * @hidden
  59674. */
  59675. static HomogeneousCoordinates: boolean;
  59676. /**
  59677. * The coordinate system mode. Defaults to AUTO.
  59678. */
  59679. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59680. /**
  59681. * The animation start mode. Defaults to FIRST.
  59682. */
  59683. animationStartMode: GLTFLoaderAnimationStartMode;
  59684. /**
  59685. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59686. */
  59687. compileMaterials: boolean;
  59688. /**
  59689. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59690. */
  59691. useClipPlane: boolean;
  59692. /**
  59693. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59694. */
  59695. compileShadowGenerators: boolean;
  59696. /**
  59697. * Defines if the Alpha blended materials are only applied as coverage.
  59698. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59699. * If true, no extra effects are applied to transparent pixels.
  59700. */
  59701. transparencyAsCoverage: boolean;
  59702. /**
  59703. * Function called before loading a url referenced by the asset.
  59704. */
  59705. preprocessUrlAsync: (url: string) => Promise<string>;
  59706. /**
  59707. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59708. */
  59709. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59710. private _onMeshLoadedObserver;
  59711. /**
  59712. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59713. */
  59714. onMeshLoaded: (mesh: AbstractMesh) => void;
  59715. /**
  59716. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59717. */
  59718. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59719. private _onTextureLoadedObserver;
  59720. /**
  59721. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59722. */
  59723. onTextureLoaded: (texture: BaseTexture) => void;
  59724. /**
  59725. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59726. */
  59727. readonly onMaterialLoadedObservable: Observable<Material>;
  59728. private _onMaterialLoadedObserver;
  59729. /**
  59730. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59731. */
  59732. onMaterialLoaded: (material: Material) => void;
  59733. /**
  59734. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59735. */
  59736. readonly onCameraLoadedObservable: Observable<Camera>;
  59737. private _onCameraLoadedObserver;
  59738. /**
  59739. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59740. */
  59741. onCameraLoaded: (camera: Camera) => void;
  59742. /**
  59743. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59744. * For assets with LODs, raised when all of the LODs are complete.
  59745. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59746. */
  59747. readonly onCompleteObservable: Observable<void>;
  59748. private _onCompleteObserver;
  59749. /**
  59750. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59751. * For assets with LODs, raised when all of the LODs are complete.
  59752. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59753. */
  59754. onComplete: () => void;
  59755. /**
  59756. * Observable raised when an error occurs.
  59757. */
  59758. readonly onErrorObservable: Observable<any>;
  59759. private _onErrorObserver;
  59760. /**
  59761. * Callback raised when an error occurs.
  59762. */
  59763. onError: (reason: any) => void;
  59764. /**
  59765. * Observable raised after the loader is disposed.
  59766. */
  59767. readonly onDisposeObservable: Observable<void>;
  59768. private _onDisposeObserver;
  59769. /**
  59770. * Callback raised after the loader is disposed.
  59771. */
  59772. onDispose: () => void;
  59773. /**
  59774. * Observable raised after a loader extension is created.
  59775. * Set additional options for a loader extension in this event.
  59776. */
  59777. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59778. private _onExtensionLoadedObserver;
  59779. /**
  59780. * Callback raised after a loader extension is created.
  59781. */
  59782. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59783. /**
  59784. * Defines if the loader logging is enabled.
  59785. */
  59786. loggingEnabled: boolean;
  59787. /**
  59788. * Defines if the loader should capture performance counters.
  59789. */
  59790. capturePerformanceCounters: boolean;
  59791. /**
  59792. * Defines if the loader should validate the asset.
  59793. */
  59794. validate: boolean;
  59795. /**
  59796. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59797. */
  59798. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59799. private _onValidatedObserver;
  59800. /**
  59801. * Callback raised after a loader extension is created.
  59802. */
  59803. onValidated: (results: IGLTFValidationResults) => void;
  59804. private _loader;
  59805. /**
  59806. * Name of the loader ("gltf")
  59807. */
  59808. name: string;
  59809. /**
  59810. * Supported file extensions of the loader (.gltf, .glb)
  59811. */
  59812. extensions: ISceneLoaderPluginExtensions;
  59813. /**
  59814. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59815. */
  59816. dispose(): void;
  59817. /** @hidden */ clear(): void;
  59818. /**
  59819. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59820. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59821. * @param scene the scene the meshes should be added to
  59822. * @param data the glTF data to load
  59823. * @param rootUrl root url to load from
  59824. * @param onProgress event that fires when loading progress has occured
  59825. * @param fileName Defines the name of the file to load
  59826. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59827. */
  59828. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59829. meshes: AbstractMesh[];
  59830. particleSystems: IParticleSystem[];
  59831. skeletons: Skeleton[];
  59832. animationGroups: AnimationGroup[];
  59833. }>;
  59834. /**
  59835. * Imports all objects from the loaded glTF data and adds them to the scene
  59836. * @param scene the scene the objects should be added to
  59837. * @param data the glTF data to load
  59838. * @param rootUrl root url to load from
  59839. * @param onProgress event that fires when loading progress has occured
  59840. * @param fileName Defines the name of the file to load
  59841. * @returns a promise which completes when objects have been loaded to the scene
  59842. */
  59843. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59844. /**
  59845. * Load into an asset container.
  59846. * @param scene The scene to load into
  59847. * @param data The data to import
  59848. * @param rootUrl The root url for scene and resources
  59849. * @param onProgress The callback when the load progresses
  59850. * @param fileName Defines the name of the file to load
  59851. * @returns The loaded asset container
  59852. */
  59853. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59854. /**
  59855. * If the data string can be loaded directly.
  59856. * @param data string contianing the file data
  59857. * @returns if the data can be loaded directly
  59858. */
  59859. canDirectLoad(data: string): boolean;
  59860. /**
  59861. * Rewrites a url by combining a root url and response url.
  59862. */
  59863. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59864. /**
  59865. * Instantiates a glTF file loader plugin.
  59866. * @returns the created plugin
  59867. */
  59868. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59869. /**
  59870. * The loader state or null if the loader is not active.
  59871. */
  59872. readonly loaderState: Nullable<GLTFLoaderState>;
  59873. /**
  59874. * Returns a promise that resolves when the asset is completely loaded.
  59875. * @returns a promise that resolves when the asset is completely loaded.
  59876. */
  59877. whenCompleteAsync(): Promise<void>;
  59878. private _parseAsync;
  59879. private _validateAsync;
  59880. private _getLoader;
  59881. private _unpackBinary;
  59882. private _unpackBinaryV1;
  59883. private _unpackBinaryV2;
  59884. private static _parseVersion;
  59885. private static _compareVersion;
  59886. private static _decodeBufferToText;
  59887. private static readonly _logSpaces;
  59888. private _logIndentLevel;
  59889. private _loggingEnabled;
  59890. /** @hidden */ log: (message: string) => void;
  59891. /** @hidden */ logOpen(message: string): void;
  59892. /** @hidden */ logClose(): void;
  59893. private _logEnabled;
  59894. private _logDisabled;
  59895. private _capturePerformanceCounters;
  59896. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59897. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59898. private _startPerformanceCounterEnabled;
  59899. private _startPerformanceCounterDisabled;
  59900. private _endPerformanceCounterEnabled;
  59901. private _endPerformanceCounterDisabled;
  59902. }
  59903. }
  59904. declare module BABYLON.GLTF1 {
  59905. /**
  59906. * Enums
  59907. * @hidden
  59908. */
  59909. export enum EComponentType {
  59910. BYTE = 5120,
  59911. UNSIGNED_BYTE = 5121,
  59912. SHORT = 5122,
  59913. UNSIGNED_SHORT = 5123,
  59914. FLOAT = 5126
  59915. }
  59916. /** @hidden */
  59917. export enum EShaderType {
  59918. FRAGMENT = 35632,
  59919. VERTEX = 35633
  59920. }
  59921. /** @hidden */
  59922. export enum EParameterType {
  59923. BYTE = 5120,
  59924. UNSIGNED_BYTE = 5121,
  59925. SHORT = 5122,
  59926. UNSIGNED_SHORT = 5123,
  59927. INT = 5124,
  59928. UNSIGNED_INT = 5125,
  59929. FLOAT = 5126,
  59930. FLOAT_VEC2 = 35664,
  59931. FLOAT_VEC3 = 35665,
  59932. FLOAT_VEC4 = 35666,
  59933. INT_VEC2 = 35667,
  59934. INT_VEC3 = 35668,
  59935. INT_VEC4 = 35669,
  59936. BOOL = 35670,
  59937. BOOL_VEC2 = 35671,
  59938. BOOL_VEC3 = 35672,
  59939. BOOL_VEC4 = 35673,
  59940. FLOAT_MAT2 = 35674,
  59941. FLOAT_MAT3 = 35675,
  59942. FLOAT_MAT4 = 35676,
  59943. SAMPLER_2D = 35678
  59944. }
  59945. /** @hidden */
  59946. export enum ETextureWrapMode {
  59947. CLAMP_TO_EDGE = 33071,
  59948. MIRRORED_REPEAT = 33648,
  59949. REPEAT = 10497
  59950. }
  59951. /** @hidden */
  59952. export enum ETextureFilterType {
  59953. NEAREST = 9728,
  59954. LINEAR = 9728,
  59955. NEAREST_MIPMAP_NEAREST = 9984,
  59956. LINEAR_MIPMAP_NEAREST = 9985,
  59957. NEAREST_MIPMAP_LINEAR = 9986,
  59958. LINEAR_MIPMAP_LINEAR = 9987
  59959. }
  59960. /** @hidden */
  59961. export enum ETextureFormat {
  59962. ALPHA = 6406,
  59963. RGB = 6407,
  59964. RGBA = 6408,
  59965. LUMINANCE = 6409,
  59966. LUMINANCE_ALPHA = 6410
  59967. }
  59968. /** @hidden */
  59969. export enum ECullingType {
  59970. FRONT = 1028,
  59971. BACK = 1029,
  59972. FRONT_AND_BACK = 1032
  59973. }
  59974. /** @hidden */
  59975. export enum EBlendingFunction {
  59976. ZERO = 0,
  59977. ONE = 1,
  59978. SRC_COLOR = 768,
  59979. ONE_MINUS_SRC_COLOR = 769,
  59980. DST_COLOR = 774,
  59981. ONE_MINUS_DST_COLOR = 775,
  59982. SRC_ALPHA = 770,
  59983. ONE_MINUS_SRC_ALPHA = 771,
  59984. DST_ALPHA = 772,
  59985. ONE_MINUS_DST_ALPHA = 773,
  59986. CONSTANT_COLOR = 32769,
  59987. ONE_MINUS_CONSTANT_COLOR = 32770,
  59988. CONSTANT_ALPHA = 32771,
  59989. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59990. SRC_ALPHA_SATURATE = 776
  59991. }
  59992. /** @hidden */
  59993. export interface IGLTFProperty {
  59994. extensions?: {
  59995. [key: string]: any;
  59996. };
  59997. extras?: Object;
  59998. }
  59999. /** @hidden */
  60000. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60001. name?: string;
  60002. }
  60003. /** @hidden */
  60004. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60005. bufferView: string;
  60006. byteOffset: number;
  60007. byteStride: number;
  60008. count: number;
  60009. type: string;
  60010. componentType: EComponentType;
  60011. max?: number[];
  60012. min?: number[];
  60013. name?: string;
  60014. }
  60015. /** @hidden */
  60016. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60017. buffer: string;
  60018. byteOffset: number;
  60019. byteLength: number;
  60020. byteStride: number;
  60021. target?: number;
  60022. }
  60023. /** @hidden */
  60024. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60025. uri: string;
  60026. byteLength?: number;
  60027. type?: string;
  60028. }
  60029. /** @hidden */
  60030. export interface IGLTFShader extends IGLTFChildRootProperty {
  60031. uri: string;
  60032. type: EShaderType;
  60033. }
  60034. /** @hidden */
  60035. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60036. attributes: string[];
  60037. fragmentShader: string;
  60038. vertexShader: string;
  60039. }
  60040. /** @hidden */
  60041. export interface IGLTFTechniqueParameter {
  60042. type: number;
  60043. count?: number;
  60044. semantic?: string;
  60045. node?: string;
  60046. value?: number | boolean | string | Array<any>;
  60047. source?: string;
  60048. babylonValue?: any;
  60049. }
  60050. /** @hidden */
  60051. export interface IGLTFTechniqueCommonProfile {
  60052. lightingModel: string;
  60053. texcoordBindings: Object;
  60054. parameters?: Array<any>;
  60055. }
  60056. /** @hidden */
  60057. export interface IGLTFTechniqueStatesFunctions {
  60058. blendColor?: number[];
  60059. blendEquationSeparate?: number[];
  60060. blendFuncSeparate?: number[];
  60061. colorMask: boolean[];
  60062. cullFace: number[];
  60063. }
  60064. /** @hidden */
  60065. export interface IGLTFTechniqueStates {
  60066. enable: number[];
  60067. functions: IGLTFTechniqueStatesFunctions;
  60068. }
  60069. /** @hidden */
  60070. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60071. parameters: {
  60072. [key: string]: IGLTFTechniqueParameter;
  60073. };
  60074. program: string;
  60075. attributes: {
  60076. [key: string]: string;
  60077. };
  60078. uniforms: {
  60079. [key: string]: string;
  60080. };
  60081. states: IGLTFTechniqueStates;
  60082. }
  60083. /** @hidden */
  60084. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60085. technique?: string;
  60086. values: string[];
  60087. }
  60088. /** @hidden */
  60089. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60090. attributes: {
  60091. [key: string]: string;
  60092. };
  60093. indices: string;
  60094. material: string;
  60095. mode?: number;
  60096. }
  60097. /** @hidden */
  60098. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60099. primitives: IGLTFMeshPrimitive[];
  60100. }
  60101. /** @hidden */
  60102. export interface IGLTFImage extends IGLTFChildRootProperty {
  60103. uri: string;
  60104. }
  60105. /** @hidden */
  60106. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60107. magFilter?: number;
  60108. minFilter?: number;
  60109. wrapS?: number;
  60110. wrapT?: number;
  60111. }
  60112. /** @hidden */
  60113. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60114. sampler: string;
  60115. source: string;
  60116. format?: ETextureFormat;
  60117. internalFormat?: ETextureFormat;
  60118. target?: number;
  60119. type?: number;
  60120. babylonTexture?: Texture;
  60121. }
  60122. /** @hidden */
  60123. export interface IGLTFAmbienLight {
  60124. color?: number[];
  60125. }
  60126. /** @hidden */
  60127. export interface IGLTFDirectionalLight {
  60128. color?: number[];
  60129. }
  60130. /** @hidden */
  60131. export interface IGLTFPointLight {
  60132. color?: number[];
  60133. constantAttenuation?: number;
  60134. linearAttenuation?: number;
  60135. quadraticAttenuation?: number;
  60136. }
  60137. /** @hidden */
  60138. export interface IGLTFSpotLight {
  60139. color?: number[];
  60140. constantAttenuation?: number;
  60141. fallOfAngle?: number;
  60142. fallOffExponent?: number;
  60143. linearAttenuation?: number;
  60144. quadraticAttenuation?: number;
  60145. }
  60146. /** @hidden */
  60147. export interface IGLTFLight extends IGLTFChildRootProperty {
  60148. type: string;
  60149. }
  60150. /** @hidden */
  60151. export interface IGLTFCameraOrthographic {
  60152. xmag: number;
  60153. ymag: number;
  60154. zfar: number;
  60155. znear: number;
  60156. }
  60157. /** @hidden */
  60158. export interface IGLTFCameraPerspective {
  60159. aspectRatio: number;
  60160. yfov: number;
  60161. zfar: number;
  60162. znear: number;
  60163. }
  60164. /** @hidden */
  60165. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60166. type: string;
  60167. }
  60168. /** @hidden */
  60169. export interface IGLTFAnimationChannelTarget {
  60170. id: string;
  60171. path: string;
  60172. }
  60173. /** @hidden */
  60174. export interface IGLTFAnimationChannel {
  60175. sampler: string;
  60176. target: IGLTFAnimationChannelTarget;
  60177. }
  60178. /** @hidden */
  60179. export interface IGLTFAnimationSampler {
  60180. input: string;
  60181. output: string;
  60182. interpolation?: string;
  60183. }
  60184. /** @hidden */
  60185. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60186. channels?: IGLTFAnimationChannel[];
  60187. parameters?: {
  60188. [key: string]: string;
  60189. };
  60190. samplers?: {
  60191. [key: string]: IGLTFAnimationSampler;
  60192. };
  60193. }
  60194. /** @hidden */
  60195. export interface IGLTFNodeInstanceSkin {
  60196. skeletons: string[];
  60197. skin: string;
  60198. meshes: string[];
  60199. }
  60200. /** @hidden */
  60201. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60202. bindShapeMatrix: number[];
  60203. inverseBindMatrices: string;
  60204. jointNames: string[];
  60205. babylonSkeleton?: Skeleton;
  60206. }
  60207. /** @hidden */
  60208. export interface IGLTFNode extends IGLTFChildRootProperty {
  60209. camera?: string;
  60210. children: string[];
  60211. skin?: string;
  60212. jointName?: string;
  60213. light?: string;
  60214. matrix: number[];
  60215. mesh?: string;
  60216. meshes?: string[];
  60217. rotation?: number[];
  60218. scale?: number[];
  60219. translation?: number[];
  60220. babylonNode?: Node;
  60221. }
  60222. /** @hidden */
  60223. export interface IGLTFScene extends IGLTFChildRootProperty {
  60224. nodes: string[];
  60225. }
  60226. /** @hidden */
  60227. export interface IGLTFRuntime {
  60228. extensions: {
  60229. [key: string]: any;
  60230. };
  60231. accessors: {
  60232. [key: string]: IGLTFAccessor;
  60233. };
  60234. buffers: {
  60235. [key: string]: IGLTFBuffer;
  60236. };
  60237. bufferViews: {
  60238. [key: string]: IGLTFBufferView;
  60239. };
  60240. meshes: {
  60241. [key: string]: IGLTFMesh;
  60242. };
  60243. lights: {
  60244. [key: string]: IGLTFLight;
  60245. };
  60246. cameras: {
  60247. [key: string]: IGLTFCamera;
  60248. };
  60249. nodes: {
  60250. [key: string]: IGLTFNode;
  60251. };
  60252. images: {
  60253. [key: string]: IGLTFImage;
  60254. };
  60255. textures: {
  60256. [key: string]: IGLTFTexture;
  60257. };
  60258. shaders: {
  60259. [key: string]: IGLTFShader;
  60260. };
  60261. programs: {
  60262. [key: string]: IGLTFProgram;
  60263. };
  60264. samplers: {
  60265. [key: string]: IGLTFSampler;
  60266. };
  60267. techniques: {
  60268. [key: string]: IGLTFTechnique;
  60269. };
  60270. materials: {
  60271. [key: string]: IGLTFMaterial;
  60272. };
  60273. animations: {
  60274. [key: string]: IGLTFAnimation;
  60275. };
  60276. skins: {
  60277. [key: string]: IGLTFSkins;
  60278. };
  60279. currentScene?: Object;
  60280. scenes: {
  60281. [key: string]: IGLTFScene;
  60282. };
  60283. extensionsUsed: string[];
  60284. extensionsRequired?: string[];
  60285. buffersCount: number;
  60286. shaderscount: number;
  60287. scene: Scene;
  60288. rootUrl: string;
  60289. loadedBufferCount: number;
  60290. loadedBufferViews: {
  60291. [name: string]: ArrayBufferView;
  60292. };
  60293. loadedShaderCount: number;
  60294. importOnlyMeshes: boolean;
  60295. importMeshesNames?: string[];
  60296. dummyNodes: Node[];
  60297. }
  60298. /** @hidden */
  60299. export interface INodeToRoot {
  60300. bone: Bone;
  60301. node: IGLTFNode;
  60302. id: string;
  60303. }
  60304. /** @hidden */
  60305. export interface IJointNode {
  60306. node: IGLTFNode;
  60307. id: string;
  60308. }
  60309. }
  60310. declare module BABYLON.GLTF1 {
  60311. /**
  60312. * Utils functions for GLTF
  60313. * @hidden
  60314. */
  60315. export class GLTFUtils {
  60316. /**
  60317. * Sets the given "parameter" matrix
  60318. * @param scene: the Scene object
  60319. * @param source: the source node where to pick the matrix
  60320. * @param parameter: the GLTF technique parameter
  60321. * @param uniformName: the name of the shader's uniform
  60322. * @param shaderMaterial: the shader material
  60323. */
  60324. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60325. /**
  60326. * Sets the given "parameter" matrix
  60327. * @param shaderMaterial: the shader material
  60328. * @param uniform: the name of the shader's uniform
  60329. * @param value: the value of the uniform
  60330. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60331. */
  60332. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60333. /**
  60334. * Returns the wrap mode of the texture
  60335. * @param mode: the mode value
  60336. */
  60337. static GetWrapMode(mode: number): number;
  60338. /**
  60339. * Returns the byte stride giving an accessor
  60340. * @param accessor: the GLTF accessor objet
  60341. */
  60342. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60343. /**
  60344. * Returns the texture filter mode giving a mode value
  60345. * @param mode: the filter mode value
  60346. */
  60347. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60348. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60349. /**
  60350. * Returns a buffer from its accessor
  60351. * @param gltfRuntime: the GLTF runtime
  60352. * @param accessor: the GLTF accessor
  60353. */
  60354. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60355. /**
  60356. * Decodes a buffer view into a string
  60357. * @param view: the buffer view
  60358. */
  60359. static DecodeBufferToText(view: ArrayBufferView): string;
  60360. /**
  60361. * Returns the default material of gltf. Related to
  60362. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60363. * @param scene: the Babylon.js scene
  60364. */
  60365. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60366. private static _DefaultMaterial;
  60367. }
  60368. }
  60369. declare module BABYLON.GLTF1 {
  60370. /**
  60371. * Implementation of the base glTF spec
  60372. * @hidden
  60373. */
  60374. export class GLTFLoaderBase {
  60375. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60376. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60377. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60378. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60379. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60380. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60381. }
  60382. /**
  60383. * glTF V1 Loader
  60384. * @hidden
  60385. */
  60386. export class GLTFLoader implements IGLTFLoader {
  60387. static Extensions: {
  60388. [name: string]: GLTFLoaderExtension;
  60389. };
  60390. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60391. state: Nullable<GLTFLoaderState>;
  60392. dispose(): void;
  60393. private _importMeshAsync;
  60394. /**
  60395. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60396. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60397. * @param scene the scene the meshes should be added to
  60398. * @param data gltf data containing information of the meshes in a loaded file
  60399. * @param rootUrl root url to load from
  60400. * @param onProgress event that fires when loading progress has occured
  60401. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60402. */
  60403. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60404. meshes: AbstractMesh[];
  60405. particleSystems: IParticleSystem[];
  60406. skeletons: Skeleton[];
  60407. animationGroups: AnimationGroup[];
  60408. }>;
  60409. private _loadAsync;
  60410. /**
  60411. * Imports all objects from a loaded gltf file and adds them to the scene
  60412. * @param scene the scene the objects should be added to
  60413. * @param data gltf data containing information of the meshes in a loaded file
  60414. * @param rootUrl root url to load from
  60415. * @param onProgress event that fires when loading progress has occured
  60416. * @returns a promise which completes when objects have been loaded to the scene
  60417. */
  60418. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60419. private _loadShadersAsync;
  60420. private _loadBuffersAsync;
  60421. private _createNodes;
  60422. }
  60423. /** @hidden */
  60424. export abstract class GLTFLoaderExtension {
  60425. private _name;
  60426. constructor(name: string);
  60427. readonly name: string;
  60428. /**
  60429. * Defines an override for loading the runtime
  60430. * Return true to stop further extensions from loading the runtime
  60431. */
  60432. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60433. /**
  60434. * Defines an onverride for creating gltf runtime
  60435. * Return true to stop further extensions from creating the runtime
  60436. */
  60437. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60438. /**
  60439. * Defines an override for loading buffers
  60440. * Return true to stop further extensions from loading this buffer
  60441. */
  60442. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60443. /**
  60444. * Defines an override for loading texture buffers
  60445. * Return true to stop further extensions from loading this texture data
  60446. */
  60447. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60448. /**
  60449. * Defines an override for creating textures
  60450. * Return true to stop further extensions from loading this texture
  60451. */
  60452. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60453. /**
  60454. * Defines an override for loading shader strings
  60455. * Return true to stop further extensions from loading this shader data
  60456. */
  60457. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60458. /**
  60459. * Defines an override for loading materials
  60460. * Return true to stop further extensions from loading this material
  60461. */
  60462. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60463. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60464. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60465. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60466. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60467. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60468. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60469. private static LoadTextureBufferAsync;
  60470. private static CreateTextureAsync;
  60471. private static ApplyExtensions;
  60472. }
  60473. }
  60474. declare module BABYLON.GLTF1 {
  60475. /** @hidden */
  60476. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60477. private _bin;
  60478. constructor();
  60479. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60480. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60481. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60482. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60483. }
  60484. }
  60485. declare module BABYLON.GLTF1 {
  60486. /** @hidden */
  60487. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60488. constructor();
  60489. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60490. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60491. private _loadTexture;
  60492. }
  60493. }
  60494. declare module BABYLON.GLTF2.Loader {
  60495. /**
  60496. * Loader interface with an index field.
  60497. */
  60498. export interface IArrayItem {
  60499. /**
  60500. * The index of this item in the array.
  60501. */
  60502. index: number;
  60503. }
  60504. /**
  60505. * Loader interface with additional members.
  60506. */
  60507. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60508. /** @hidden */ data?: Promise<ArrayBufferView>;
  60509. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60510. }
  60511. /**
  60512. * Loader interface with additional members.
  60513. */
  60514. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60515. }
  60516. /** @hidden */
  60517. export interface _IAnimationSamplerData {
  60518. input: Float32Array;
  60519. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60520. output: Float32Array;
  60521. }
  60522. /**
  60523. * Loader interface with additional members.
  60524. */
  60525. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60526. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60527. }
  60528. /**
  60529. * Loader interface with additional members.
  60530. */
  60531. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60532. channels: IAnimationChannel[];
  60533. samplers: IAnimationSampler[];
  60534. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60535. }
  60536. /**
  60537. * Loader interface with additional members.
  60538. */
  60539. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60540. /** @hidden */ data?: Promise<ArrayBufferView>;
  60541. }
  60542. /**
  60543. * Loader interface with additional members.
  60544. */
  60545. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60546. /** @hidden */ data?: Promise<ArrayBufferView>;
  60547. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60548. }
  60549. /**
  60550. * Loader interface with additional members.
  60551. */
  60552. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60553. }
  60554. /**
  60555. * Loader interface with additional members.
  60556. */
  60557. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60558. /** @hidden */ data?: Promise<ArrayBufferView>;
  60559. }
  60560. /**
  60561. * Loader interface with additional members.
  60562. */
  60563. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60564. }
  60565. /**
  60566. * Loader interface with additional members.
  60567. */
  60568. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60569. }
  60570. /**
  60571. * Loader interface with additional members.
  60572. */
  60573. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60574. baseColorTexture?: ITextureInfo;
  60575. metallicRoughnessTexture?: ITextureInfo;
  60576. }
  60577. /**
  60578. * Loader interface with additional members.
  60579. */
  60580. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60581. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60582. normalTexture?: IMaterialNormalTextureInfo;
  60583. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60584. emissiveTexture?: ITextureInfo;
  60585. /** @hidden */ data?: {
  60586. [babylonDrawMode: number]: {
  60587. babylonMaterial: Material;
  60588. babylonMeshes: AbstractMesh[];
  60589. promise: Promise<void>;
  60590. };
  60591. };
  60592. }
  60593. /**
  60594. * Loader interface with additional members.
  60595. */
  60596. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60597. primitives: IMeshPrimitive[];
  60598. }
  60599. /**
  60600. * Loader interface with additional members.
  60601. */
  60602. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60603. /** @hidden */ instanceData?: {
  60604. babylonSourceMesh: Mesh;
  60605. promise: Promise<any>;
  60606. };
  60607. }
  60608. /**
  60609. * Loader interface with additional members.
  60610. */
  60611. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60612. /**
  60613. * The parent glTF node.
  60614. */
  60615. parent?: INode;
  60616. /** @hidden */ babylonTransformNode?: TransformNode;
  60617. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60618. /** @hidden */ babylonBones?: Bone[];
  60619. /** @hidden */ numMorphTargets?: number;
  60620. }
  60621. /** @hidden */
  60622. export interface _ISamplerData {
  60623. noMipMaps: boolean;
  60624. samplingMode: number;
  60625. wrapU: number;
  60626. wrapV: number;
  60627. }
  60628. /**
  60629. * Loader interface with additional members.
  60630. */
  60631. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60632. /** @hidden */ data?: _ISamplerData;
  60633. }
  60634. /**
  60635. * Loader interface with additional members.
  60636. */
  60637. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60638. }
  60639. /**
  60640. * Loader interface with additional members.
  60641. */
  60642. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60643. /** @hidden */ data?: {
  60644. babylonSkeleton: Skeleton;
  60645. promise: Promise<void>;
  60646. };
  60647. }
  60648. /**
  60649. * Loader interface with additional members.
  60650. */
  60651. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60652. }
  60653. /**
  60654. * Loader interface with additional members.
  60655. */
  60656. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60657. }
  60658. /**
  60659. * Loader interface with additional members.
  60660. */
  60661. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60662. accessors?: IAccessor[];
  60663. animations?: IAnimation[];
  60664. buffers?: IBuffer[];
  60665. bufferViews?: IBufferView[];
  60666. cameras?: ICamera[];
  60667. images?: IImage[];
  60668. materials?: IMaterial[];
  60669. meshes?: IMesh[];
  60670. nodes?: INode[];
  60671. samplers?: ISampler[];
  60672. scenes?: IScene[];
  60673. skins?: ISkin[];
  60674. textures?: ITexture[];
  60675. }
  60676. }
  60677. declare module BABYLON.GLTF2 {
  60678. /**
  60679. * Interface for a glTF loader extension.
  60680. */
  60681. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60682. /**
  60683. * Called after the loader state changes to LOADING.
  60684. */
  60685. onLoading?(): void;
  60686. /**
  60687. * Called after the loader state changes to READY.
  60688. */
  60689. onReady?(): void;
  60690. /**
  60691. * Define this method to modify the default behavior when loading scenes.
  60692. * @param context The context when loading the asset
  60693. * @param scene The glTF scene property
  60694. * @returns A promise that resolves when the load is complete or null if not handled
  60695. */
  60696. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60697. /**
  60698. * Define this method to modify the default behavior when loading nodes.
  60699. * @param context The context when loading the asset
  60700. * @param node The glTF node property
  60701. * @param assign A function called synchronously after parsing the glTF properties
  60702. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60703. */
  60704. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60705. /**
  60706. * Define this method to modify the default behavior when loading cameras.
  60707. * @param context The context when loading the asset
  60708. * @param camera The glTF camera property
  60709. * @param assign A function called synchronously after parsing the glTF properties
  60710. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60711. */
  60712. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60713. /**
  60714. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60715. * @param context The context when loading the asset
  60716. * @param primitive The glTF mesh primitive property
  60717. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60718. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60719. /**
  60720. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60721. * @param context The context when loading the asset
  60722. * @param name The mesh name when loading the asset
  60723. * @param node The glTF node when loading the asset
  60724. * @param mesh The glTF mesh when loading the asset
  60725. * @param primitive The glTF mesh primitive property
  60726. * @param assign A function called synchronously after parsing the glTF properties
  60727. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60728. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60729. /**
  60730. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60731. * @param context The context when loading the asset
  60732. * @param material The glTF material property
  60733. * @param assign A function called synchronously after parsing the glTF properties
  60734. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60735. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60736. /**
  60737. * Define this method to modify the default behavior when creating materials.
  60738. * @param context The context when loading the asset
  60739. * @param material The glTF material property
  60740. * @param babylonDrawMode The draw mode for the Babylon material
  60741. * @returns The Babylon material or null if not handled
  60742. */
  60743. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60744. /**
  60745. * Define this method to modify the default behavior when loading material properties.
  60746. * @param context The context when loading the asset
  60747. * @param material The glTF material property
  60748. * @param babylonMaterial The Babylon material
  60749. * @returns A promise that resolves when the load is complete or null if not handled
  60750. */
  60751. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60752. /**
  60753. * Define this method to modify the default behavior when loading texture infos.
  60754. * @param context The context when loading the asset
  60755. * @param textureInfo The glTF texture info property
  60756. * @param assign A function called synchronously after parsing the glTF properties
  60757. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60758. */
  60759. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60760. /**
  60761. * Define this method to modify the default behavior when loading animations.
  60762. * @param context The context when loading the asset
  60763. * @param animation The glTF animation property
  60764. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60765. */
  60766. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60767. /**
  60768. * @hidden Define this method to modify the default behavior when loading skins.
  60769. * @param context The context when loading the asset
  60770. * @param node The glTF node property
  60771. * @param skin The glTF skin property
  60772. * @returns A promise that resolves when the load is complete or null if not handled
  60773. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60774. /**
  60775. * @hidden Define this method to modify the default behavior when loading uris.
  60776. * @param context The context when loading the asset
  60777. * @param property The glTF property associated with the uri
  60778. * @param uri The uri to load
  60779. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60780. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60781. }
  60782. }
  60783. declare module BABYLON.GLTF2 {
  60784. /**
  60785. * Helper class for working with arrays when loading the glTF asset
  60786. */
  60787. export class ArrayItem {
  60788. /**
  60789. * Gets an item from the given array.
  60790. * @param context The context when loading the asset
  60791. * @param array The array to get the item from
  60792. * @param index The index to the array
  60793. * @returns The array item
  60794. */
  60795. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60796. /**
  60797. * Assign an `index` field to each item of the given array.
  60798. * @param array The array of items
  60799. */
  60800. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60801. }
  60802. /**
  60803. * The glTF 2.0 loader
  60804. */
  60805. export class GLTFLoader implements IGLTFLoader {
  60806. /** @hidden */ completePromises: Promise<any>[];
  60807. private _disposed;
  60808. private _parent;
  60809. private _state;
  60810. private _extensions;
  60811. private _rootUrl;
  60812. private _fileName;
  60813. private _uniqueRootUrl;
  60814. private _gltf;
  60815. private _babylonScene;
  60816. private _rootBabylonMesh;
  60817. private _defaultBabylonMaterialData;
  60818. private _progressCallback?;
  60819. private _requests;
  60820. private static readonly _DefaultSampler;
  60821. private static _ExtensionNames;
  60822. private static _ExtensionFactories;
  60823. /**
  60824. * Registers a loader extension.
  60825. * @param name The name of the loader extension.
  60826. * @param factory The factory function that creates the loader extension.
  60827. */
  60828. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60829. /**
  60830. * Unregisters a loader extension.
  60831. * @param name The name of the loader extenion.
  60832. * @returns A boolean indicating whether the extension has been unregistered
  60833. */
  60834. static UnregisterExtension(name: string): boolean;
  60835. /**
  60836. * Gets the loader state.
  60837. */
  60838. readonly state: Nullable<GLTFLoaderState>;
  60839. /**
  60840. * The glTF object parsed from the JSON.
  60841. */
  60842. readonly gltf: IGLTF;
  60843. /**
  60844. * The Babylon scene when loading the asset.
  60845. */
  60846. readonly babylonScene: Scene;
  60847. /**
  60848. * The root Babylon mesh when loading the asset.
  60849. */
  60850. readonly rootBabylonMesh: Mesh;
  60851. /** @hidden */
  60852. constructor(parent: GLTFFileLoader);
  60853. /** @hidden */
  60854. dispose(): void;
  60855. /** @hidden */
  60856. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60857. meshes: AbstractMesh[];
  60858. particleSystems: IParticleSystem[];
  60859. skeletons: Skeleton[];
  60860. animationGroups: AnimationGroup[];
  60861. }>;
  60862. /** @hidden */
  60863. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60864. private _loadAsync;
  60865. private _loadData;
  60866. private _setupData;
  60867. private _loadExtensions;
  60868. private _checkExtensions;
  60869. private _setState;
  60870. private _createRootNode;
  60871. /**
  60872. * Loads a glTF scene.
  60873. * @param context The context when loading the asset
  60874. * @param scene The glTF scene property
  60875. * @returns A promise that resolves when the load is complete
  60876. */
  60877. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60878. private _forEachPrimitive;
  60879. private _getMeshes;
  60880. private _getSkeletons;
  60881. private _getAnimationGroups;
  60882. private _startAnimations;
  60883. /**
  60884. * Loads a glTF node.
  60885. * @param context The context when loading the asset
  60886. * @param node The glTF node property
  60887. * @param assign A function called synchronously after parsing the glTF properties
  60888. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60889. */
  60890. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60891. private _loadMeshAsync;
  60892. /**
  60893. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60894. * @param context The context when loading the asset
  60895. * @param name The mesh name when loading the asset
  60896. * @param node The glTF node when loading the asset
  60897. * @param mesh The glTF mesh when loading the asset
  60898. * @param primitive The glTF mesh primitive property
  60899. * @param assign A function called synchronously after parsing the glTF properties
  60900. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60901. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60902. private _loadVertexDataAsync;
  60903. private _createMorphTargets;
  60904. private _loadMorphTargetsAsync;
  60905. private _loadMorphTargetVertexDataAsync;
  60906. private static _LoadTransform;
  60907. private _loadSkinAsync;
  60908. private _loadBones;
  60909. private _loadBone;
  60910. private _loadSkinInverseBindMatricesDataAsync;
  60911. private _updateBoneMatrices;
  60912. private _getNodeMatrix;
  60913. /**
  60914. * Loads a glTF camera.
  60915. * @param context The context when loading the asset
  60916. * @param camera The glTF camera property
  60917. * @param assign A function called synchronously after parsing the glTF properties
  60918. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60919. */
  60920. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60921. private _loadAnimationsAsync;
  60922. /**
  60923. * Loads a glTF animation.
  60924. * @param context The context when loading the asset
  60925. * @param animation The glTF animation property
  60926. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60927. */
  60928. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60929. /**
  60930. * @hidden Loads a glTF animation channel.
  60931. * @param context The context when loading the asset
  60932. * @param animationContext The context of the animation when loading the asset
  60933. * @param animation The glTF animation property
  60934. * @param channel The glTF animation channel property
  60935. * @param babylonAnimationGroup The babylon animation group property
  60936. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  60937. * @returns A void promise when the channel load is complete
  60938. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  60939. private _loadAnimationSamplerAsync;
  60940. private _loadBufferAsync;
  60941. /**
  60942. * Loads a glTF buffer view.
  60943. * @param context The context when loading the asset
  60944. * @param bufferView The glTF buffer view property
  60945. * @returns A promise that resolves with the loaded data when the load is complete
  60946. */
  60947. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60948. private _loadIndicesAccessorAsync;
  60949. private _loadFloatAccessorAsync;
  60950. private _loadVertexBufferViewAsync;
  60951. private _loadVertexAccessorAsync;
  60952. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60953. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60954. private _createDefaultMaterial;
  60955. /**
  60956. * Creates a Babylon material from a glTF material.
  60957. * @param context The context when loading the asset
  60958. * @param material The glTF material property
  60959. * @param babylonDrawMode The draw mode for the Babylon material
  60960. * @returns The Babylon material
  60961. */
  60962. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60963. /**
  60964. * Loads properties from a glTF material into a Babylon material.
  60965. * @param context The context when loading the asset
  60966. * @param material The glTF material property
  60967. * @param babylonMaterial The Babylon material
  60968. * @returns A promise that resolves when the load is complete
  60969. */
  60970. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60971. /**
  60972. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60973. * @param context The context when loading the asset
  60974. * @param material The glTF material property
  60975. * @param babylonMaterial The Babylon material
  60976. * @returns A promise that resolves when the load is complete
  60977. */
  60978. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60979. /**
  60980. * Loads the alpha properties from a glTF material into a Babylon material.
  60981. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60982. * @param context The context when loading the asset
  60983. * @param material The glTF material property
  60984. * @param babylonMaterial The Babylon material
  60985. */
  60986. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60987. /**
  60988. * Loads a glTF texture info.
  60989. * @param context The context when loading the asset
  60990. * @param textureInfo The glTF texture info property
  60991. * @param assign A function called synchronously after parsing the glTF properties
  60992. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60993. */
  60994. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60995. private _loadTextureAsync;
  60996. private _loadSampler;
  60997. /**
  60998. * Loads a glTF image.
  60999. * @param context The context when loading the asset
  61000. * @param image The glTF image property
  61001. * @returns A promise that resolves with the loaded data when the load is complete
  61002. */
  61003. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61004. /**
  61005. * Loads a glTF uri.
  61006. * @param context The context when loading the asset
  61007. * @param property The glTF property associated with the uri
  61008. * @param uri The base64 or relative uri
  61009. * @returns A promise that resolves with the loaded data when the load is complete
  61010. */
  61011. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61012. private _onProgress;
  61013. /**
  61014. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61015. * @param babylonObject the Babylon object with metadata
  61016. * @param pointer the JSON pointer
  61017. */
  61018. static AddPointerMetadata(babylonObject: {
  61019. metadata: any;
  61020. }, pointer: string): void;
  61021. private static _GetTextureWrapMode;
  61022. private static _GetTextureSamplingMode;
  61023. private static _GetTypedArray;
  61024. private static _GetNumComponents;
  61025. private static _ValidateUri;
  61026. private static _GetDrawMode;
  61027. private _compileMaterialsAsync;
  61028. private _compileShadowGeneratorsAsync;
  61029. private _forEachExtensions;
  61030. private _applyExtensions;
  61031. private _extensionsOnLoading;
  61032. private _extensionsOnReady;
  61033. private _extensionsLoadSceneAsync;
  61034. private _extensionsLoadNodeAsync;
  61035. private _extensionsLoadCameraAsync;
  61036. private _extensionsLoadVertexDataAsync;
  61037. private _extensionsLoadMeshPrimitiveAsync;
  61038. private _extensionsLoadMaterialAsync;
  61039. private _extensionsCreateMaterial;
  61040. private _extensionsLoadMaterialPropertiesAsync;
  61041. private _extensionsLoadTextureInfoAsync;
  61042. private _extensionsLoadAnimationAsync;
  61043. private _extensionsLoadSkinAsync;
  61044. private _extensionsLoadUriAsync;
  61045. /**
  61046. * Helper method called by a loader extension to load an glTF extension.
  61047. * @param context The context when loading the asset
  61048. * @param property The glTF property to load the extension from
  61049. * @param extensionName The name of the extension to load
  61050. * @param actionAsync The action to run
  61051. * @returns The promise returned by actionAsync or null if the extension does not exist
  61052. */
  61053. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61054. /**
  61055. * Helper method called by a loader extension to load a glTF extra.
  61056. * @param context The context when loading the asset
  61057. * @param property The glTF property to load the extra from
  61058. * @param extensionName The name of the extension to load
  61059. * @param actionAsync The action to run
  61060. * @returns The promise returned by actionAsync or null if the extra does not exist
  61061. */
  61062. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61063. /**
  61064. * Increments the indentation level and logs a message.
  61065. * @param message The message to log
  61066. */
  61067. logOpen(message: string): void;
  61068. /**
  61069. * Decrements the indentation level.
  61070. */
  61071. logClose(): void;
  61072. /**
  61073. * Logs a message
  61074. * @param message The message to log
  61075. */
  61076. log(message: string): void;
  61077. /**
  61078. * Starts a performance counter.
  61079. * @param counterName The name of the performance counter
  61080. */
  61081. startPerformanceCounter(counterName: string): void;
  61082. /**
  61083. * Ends a performance counter.
  61084. * @param counterName The name of the performance counter
  61085. */
  61086. endPerformanceCounter(counterName: string): void;
  61087. }
  61088. }
  61089. declare module BABYLON.GLTF2.Loader.Extensions {
  61090. /**
  61091. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61092. */
  61093. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61094. /** The name of this extension. */
  61095. readonly name: string;
  61096. /** Defines whether this extension is enabled. */
  61097. enabled: boolean;
  61098. private _loader;
  61099. private _lights?;
  61100. /** @hidden */
  61101. constructor(loader: GLTFLoader);
  61102. /** @hidden */
  61103. dispose(): void;
  61104. /** @hidden */
  61105. onLoading(): void;
  61106. /** @hidden */
  61107. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61108. private _loadLightAsync;
  61109. }
  61110. }
  61111. declare module BABYLON.GLTF2.Loader.Extensions {
  61112. /**
  61113. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61114. */
  61115. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61116. /** The name of this extension. */
  61117. readonly name: string;
  61118. /** The draco compression used to decode vertex data. */
  61119. dracoCompression?: DracoCompression;
  61120. /** Defines whether this extension is enabled. */
  61121. enabled: boolean;
  61122. private _loader;
  61123. private _dracoCompressionOwned;
  61124. /** @hidden */
  61125. constructor(loader: GLTFLoader);
  61126. /** @hidden */
  61127. dispose(): void;
  61128. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61129. }
  61130. }
  61131. declare module BABYLON.GLTF2.Loader.Extensions {
  61132. /**
  61133. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61134. */
  61135. export class KHR_lights implements IGLTFLoaderExtension {
  61136. /** The name of this extension. */
  61137. readonly name: string;
  61138. /** Defines whether this extension is enabled. */
  61139. enabled: boolean;
  61140. private _loader;
  61141. private _lights?;
  61142. /** @hidden */
  61143. constructor(loader: GLTFLoader);
  61144. /** @hidden */
  61145. dispose(): void;
  61146. /** @hidden */
  61147. onLoading(): void;
  61148. /** @hidden */
  61149. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61150. }
  61151. }
  61152. declare module BABYLON.GLTF2.Loader.Extensions {
  61153. /**
  61154. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61155. */
  61156. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61157. /** The name of this extension. */
  61158. readonly name: string;
  61159. /** Defines whether this extension is enabled. */
  61160. enabled: boolean;
  61161. private _loader;
  61162. /** @hidden */
  61163. constructor(loader: GLTFLoader);
  61164. /** @hidden */
  61165. dispose(): void;
  61166. /** @hidden */
  61167. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61168. private _loadSpecularGlossinessPropertiesAsync;
  61169. }
  61170. }
  61171. declare module BABYLON.GLTF2.Loader.Extensions {
  61172. /**
  61173. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61174. */
  61175. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61176. /** The name of this extension. */
  61177. readonly name: string;
  61178. /** Defines whether this extension is enabled. */
  61179. enabled: boolean;
  61180. private _loader;
  61181. /** @hidden */
  61182. constructor(loader: GLTFLoader);
  61183. /** @hidden */
  61184. dispose(): void;
  61185. /** @hidden */
  61186. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61187. private _loadUnlitPropertiesAsync;
  61188. }
  61189. }
  61190. declare module BABYLON.GLTF2.Loader.Extensions {
  61191. /**
  61192. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61193. */
  61194. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61195. /** The name of this extension. */
  61196. readonly name: string;
  61197. /** Defines whether this extension is enabled. */
  61198. enabled: boolean;
  61199. private _loader;
  61200. /** @hidden */
  61201. constructor(loader: GLTFLoader);
  61202. /** @hidden */
  61203. dispose(): void;
  61204. /** @hidden */
  61205. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61206. }
  61207. }
  61208. declare module BABYLON.GLTF2.Loader.Extensions {
  61209. /**
  61210. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61211. */
  61212. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61213. /** The name of this extension. */
  61214. readonly name: string;
  61215. /** Defines whether this extension is enabled. */
  61216. enabled: boolean;
  61217. private _loader;
  61218. private _clips;
  61219. private _emitters;
  61220. /** @hidden */
  61221. constructor(loader: GLTFLoader);
  61222. /** @hidden */
  61223. dispose(): void;
  61224. /** @hidden */
  61225. onLoading(): void;
  61226. /** @hidden */
  61227. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61228. /** @hidden */
  61229. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61230. /** @hidden */
  61231. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61232. private _loadClipAsync;
  61233. private _loadEmitterAsync;
  61234. private _getEventAction;
  61235. private _loadAnimationEventAsync;
  61236. }
  61237. }
  61238. declare module BABYLON.GLTF2.Loader.Extensions {
  61239. /**
  61240. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61241. */
  61242. export class MSFT_lod implements IGLTFLoaderExtension {
  61243. /** The name of this extension. */
  61244. readonly name: string;
  61245. /** Defines whether this extension is enabled. */
  61246. enabled: boolean;
  61247. /**
  61248. * Maximum number of LODs to load, starting from the lowest LOD.
  61249. */
  61250. maxLODsToLoad: number;
  61251. /**
  61252. * Observable raised when all node LODs of one level are loaded.
  61253. * The event data is the index of the loaded LOD starting from zero.
  61254. * Dispose the loader to cancel the loading of the next level of LODs.
  61255. */
  61256. onNodeLODsLoadedObservable: Observable<number>;
  61257. /**
  61258. * Observable raised when all material LODs of one level are loaded.
  61259. * The event data is the index of the loaded LOD starting from zero.
  61260. * Dispose the loader to cancel the loading of the next level of LODs.
  61261. */
  61262. onMaterialLODsLoadedObservable: Observable<number>;
  61263. private _loader;
  61264. private _nodeIndexLOD;
  61265. private _nodeSignalLODs;
  61266. private _nodePromiseLODs;
  61267. private _materialIndexLOD;
  61268. private _materialSignalLODs;
  61269. private _materialPromiseLODs;
  61270. /** @hidden */
  61271. constructor(loader: GLTFLoader);
  61272. /** @hidden */
  61273. dispose(): void;
  61274. /** @hidden */
  61275. onReady(): void;
  61276. /** @hidden */
  61277. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61278. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61279. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61280. /**
  61281. * Gets an array of LOD properties from lowest to highest.
  61282. */
  61283. private _getLODs;
  61284. private _disposeUnusedMaterials;
  61285. }
  61286. }
  61287. declare module BABYLON.GLTF2.Loader.Extensions {
  61288. /** @hidden */
  61289. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61290. readonly name: string;
  61291. enabled: boolean;
  61292. private _loader;
  61293. constructor(loader: GLTFLoader);
  61294. dispose(): void;
  61295. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61296. }
  61297. }
  61298. declare module BABYLON.GLTF2.Loader.Extensions {
  61299. /** @hidden */
  61300. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61301. readonly name: string;
  61302. enabled: boolean;
  61303. private _loader;
  61304. constructor(loader: GLTFLoader);
  61305. dispose(): void;
  61306. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61307. }
  61308. }
  61309. declare module BABYLON {
  61310. /**
  61311. * Class reading and parsing the MTL file bundled with the obj file.
  61312. */
  61313. export class MTLFileLoader {
  61314. /**
  61315. * All material loaded from the mtl will be set here
  61316. */
  61317. materials: StandardMaterial[];
  61318. /**
  61319. * This function will read the mtl file and create each material described inside
  61320. * This function could be improve by adding :
  61321. * -some component missing (Ni, Tf...)
  61322. * -including the specific options available
  61323. *
  61324. * @param scene defines the scene the material will be created in
  61325. * @param data defines the mtl data to parse
  61326. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61327. */
  61328. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61329. /**
  61330. * Gets the texture for the material.
  61331. *
  61332. * If the material is imported from input file,
  61333. * We sanitize the url to ensure it takes the textre from aside the material.
  61334. *
  61335. * @param rootUrl The root url to load from
  61336. * @param value The value stored in the mtl
  61337. * @return The Texture
  61338. */
  61339. private static _getTexture;
  61340. }
  61341. /**
  61342. * Options for loading OBJ/MTL files
  61343. */
  61344. type MeshLoadOptions = {
  61345. /**
  61346. * Defines if UVs are optimized by default during load.
  61347. */
  61348. OptimizeWithUV: boolean;
  61349. /**
  61350. * Invert model on y-axis (does a model scaling inversion)
  61351. */
  61352. InvertY: boolean;
  61353. /**
  61354. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61355. */
  61356. ImportVertexColors: boolean;
  61357. /**
  61358. * Compute the normals for the model, even if normals are present in the file.
  61359. */
  61360. ComputeNormals: boolean;
  61361. /**
  61362. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61363. */
  61364. SkipMaterials: boolean;
  61365. /**
  61366. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61367. */
  61368. MaterialLoadingFailsSilently: boolean;
  61369. };
  61370. /**
  61371. * OBJ file type loader.
  61372. * This is a babylon scene loader plugin.
  61373. */
  61374. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61375. /**
  61376. * Defines if UVs are optimized by default during load.
  61377. */
  61378. static OPTIMIZE_WITH_UV: boolean;
  61379. /**
  61380. * Invert model on y-axis (does a model scaling inversion)
  61381. */
  61382. static INVERT_Y: boolean;
  61383. /**
  61384. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61385. */
  61386. static IMPORT_VERTEX_COLORS: boolean;
  61387. /**
  61388. * Compute the normals for the model, even if normals are present in the file.
  61389. */
  61390. static COMPUTE_NORMALS: boolean;
  61391. /**
  61392. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61393. */
  61394. static SKIP_MATERIALS: boolean;
  61395. /**
  61396. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61397. *
  61398. * Defaults to true for backwards compatibility.
  61399. */
  61400. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61401. /**
  61402. * Defines the name of the plugin.
  61403. */
  61404. name: string;
  61405. /**
  61406. * Defines the extension the plugin is able to load.
  61407. */
  61408. extensions: string;
  61409. /** @hidden */
  61410. obj: RegExp;
  61411. /** @hidden */
  61412. group: RegExp;
  61413. /** @hidden */
  61414. mtllib: RegExp;
  61415. /** @hidden */
  61416. usemtl: RegExp;
  61417. /** @hidden */
  61418. smooth: RegExp;
  61419. /** @hidden */
  61420. vertexPattern: RegExp;
  61421. /** @hidden */
  61422. normalPattern: RegExp;
  61423. /** @hidden */
  61424. uvPattern: RegExp;
  61425. /** @hidden */
  61426. facePattern1: RegExp;
  61427. /** @hidden */
  61428. facePattern2: RegExp;
  61429. /** @hidden */
  61430. facePattern3: RegExp;
  61431. /** @hidden */
  61432. facePattern4: RegExp;
  61433. /** @hidden */
  61434. facePattern5: RegExp;
  61435. private _meshLoadOptions;
  61436. /**
  61437. * Creates loader for .OBJ files
  61438. *
  61439. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61440. */
  61441. constructor(meshLoadOptions?: MeshLoadOptions);
  61442. private static readonly currentMeshLoadOptions;
  61443. /**
  61444. * Calls synchronously the MTL file attached to this obj.
  61445. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61446. * Without this function materials are not displayed in the first frame (but displayed after).
  61447. * In consequence it is impossible to get material information in your HTML file
  61448. *
  61449. * @param url The URL of the MTL file
  61450. * @param rootUrl
  61451. * @param onSuccess Callback function to be called when the MTL file is loaded
  61452. * @private
  61453. */
  61454. private _loadMTL;
  61455. /**
  61456. * Instantiates a OBJ file loader plugin.
  61457. * @returns the created plugin
  61458. */
  61459. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61460. /**
  61461. * If the data string can be loaded directly.
  61462. *
  61463. * @param data string containing the file data
  61464. * @returns if the data can be loaded directly
  61465. */
  61466. canDirectLoad(data: string): boolean;
  61467. /**
  61468. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61469. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61470. * @param scene the scene the meshes should be added to
  61471. * @param data the OBJ data to load
  61472. * @param rootUrl root url to load from
  61473. * @param onProgress event that fires when loading progress has occured
  61474. * @param fileName Defines the name of the file to load
  61475. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61476. */
  61477. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61478. meshes: AbstractMesh[];
  61479. particleSystems: IParticleSystem[];
  61480. skeletons: Skeleton[];
  61481. animationGroups: AnimationGroup[];
  61482. }>;
  61483. /**
  61484. * Imports all objects from the loaded OBJ data and adds them to the scene
  61485. * @param scene the scene the objects should be added to
  61486. * @param data the OBJ data to load
  61487. * @param rootUrl root url to load from
  61488. * @param onProgress event that fires when loading progress has occured
  61489. * @param fileName Defines the name of the file to load
  61490. * @returns a promise which completes when objects have been loaded to the scene
  61491. */
  61492. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61493. /**
  61494. * Load into an asset container.
  61495. * @param scene The scene to load into
  61496. * @param data The data to import
  61497. * @param rootUrl The root url for scene and resources
  61498. * @param onProgress The callback when the load progresses
  61499. * @param fileName Defines the name of the file to load
  61500. * @returns The loaded asset container
  61501. */
  61502. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61503. /**
  61504. * Read the OBJ file and create an Array of meshes.
  61505. * Each mesh contains all information given by the OBJ and the MTL file.
  61506. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61507. *
  61508. * @param meshesNames
  61509. * @param scene Scene The scene where are displayed the data
  61510. * @param data String The content of the obj file
  61511. * @param rootUrl String The path to the folder
  61512. * @returns Array<AbstractMesh>
  61513. * @private
  61514. */
  61515. private _parseSolid;
  61516. }
  61517. }
  61518. declare module BABYLON {
  61519. /**
  61520. * STL file type loader.
  61521. * This is a babylon scene loader plugin.
  61522. */
  61523. export class STLFileLoader implements ISceneLoaderPlugin {
  61524. /** @hidden */
  61525. solidPattern: RegExp;
  61526. /** @hidden */
  61527. facetsPattern: RegExp;
  61528. /** @hidden */
  61529. normalPattern: RegExp;
  61530. /** @hidden */
  61531. vertexPattern: RegExp;
  61532. /**
  61533. * Defines the name of the plugin.
  61534. */
  61535. name: string;
  61536. /**
  61537. * Defines the extensions the stl loader is able to load.
  61538. * force data to come in as an ArrayBuffer
  61539. * we'll convert to string if it looks like it's an ASCII .stl
  61540. */
  61541. extensions: ISceneLoaderPluginExtensions;
  61542. /**
  61543. * Import meshes into a scene.
  61544. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61545. * @param scene The scene to import into
  61546. * @param data The data to import
  61547. * @param rootUrl The root url for scene and resources
  61548. * @param meshes The meshes array to import into
  61549. * @param particleSystems The particle systems array to import into
  61550. * @param skeletons The skeletons array to import into
  61551. * @param onError The callback when import fails
  61552. * @returns True if successful or false otherwise
  61553. */
  61554. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61555. /**
  61556. * Load into a scene.
  61557. * @param scene The scene to load into
  61558. * @param data The data to import
  61559. * @param rootUrl The root url for scene and resources
  61560. * @param onError The callback when import fails
  61561. * @returns true if successful or false otherwise
  61562. */
  61563. load(scene: Scene, data: any, rootUrl: string): boolean;
  61564. /**
  61565. * Load into an asset container.
  61566. * @param scene The scene to load into
  61567. * @param data The data to import
  61568. * @param rootUrl The root url for scene and resources
  61569. * @param onError The callback when import fails
  61570. * @returns The loaded asset container
  61571. */
  61572. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61573. private _isBinary;
  61574. private _parseBinary;
  61575. private _parseASCII;
  61576. }
  61577. }
  61578. declare module BABYLON {
  61579. /**
  61580. * Class for generating OBJ data from a Babylon scene.
  61581. */
  61582. export class OBJExport {
  61583. /**
  61584. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61585. * @param mesh defines the list of meshes to serialize
  61586. * @param materials defines if materials should be exported
  61587. * @param matlibname defines the name of the associated mtl file
  61588. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61589. * @returns the OBJ content
  61590. */
  61591. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61592. /**
  61593. * Exports the material(s) of a mesh in .MTL file format (text)
  61594. * @param mesh defines the mesh to extract the material from
  61595. * @returns the mtl content
  61596. */
  61597. static MTL(mesh: Mesh): string;
  61598. }
  61599. }
  61600. declare module BABYLON {
  61601. /** @hidden */
  61602. export var __IGLTFExporterExtension: number;
  61603. /**
  61604. * Interface for extending the exporter
  61605. * @hidden
  61606. */
  61607. export interface IGLTFExporterExtension {
  61608. /**
  61609. * The name of this extension
  61610. */
  61611. readonly name: string;
  61612. /**
  61613. * Defines whether this extension is enabled
  61614. */
  61615. enabled: boolean;
  61616. /**
  61617. * Defines whether this extension is required
  61618. */
  61619. required: boolean;
  61620. }
  61621. }
  61622. declare module BABYLON.GLTF2.Exporter {
  61623. /** @hidden */
  61624. export var __IGLTFExporterExtensionV2: number;
  61625. /**
  61626. * Interface for a glTF exporter extension
  61627. * @hidden
  61628. */
  61629. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61630. /**
  61631. * Define this method to modify the default behavior before exporting a texture
  61632. * @param context The context when loading the asset
  61633. * @param babylonTexture The glTF texture info property
  61634. * @param mimeType The mime-type of the generated image
  61635. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61636. */
  61637. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61638. /**
  61639. * Define this method to modify the default behavior when exporting texture info
  61640. * @param context The context when loading the asset
  61641. * @param meshPrimitive glTF mesh primitive
  61642. * @param babylonSubMesh Babylon submesh
  61643. * @param binaryWriter glTF serializer binary writer instance
  61644. * @returns nullable IMeshPrimitive promise
  61645. */
  61646. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61647. /**
  61648. * Define this method to modify the default behavior when exporting a node
  61649. * @param context The context when exporting the node
  61650. * @param node glTF node
  61651. * @param babylonNode BabylonJS node
  61652. * @returns nullable INode promise
  61653. */
  61654. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61655. /**
  61656. * Called after the exporter state changes to EXPORTING
  61657. */
  61658. onExporting?(): void;
  61659. }
  61660. }
  61661. declare module BABYLON.GLTF2.Exporter {
  61662. /**
  61663. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61664. * @hidden
  61665. */
  61666. export class _GLTFMaterialExporter {
  61667. /**
  61668. * Represents the dielectric specular values for R, G and B
  61669. */
  61670. private static readonly _DielectricSpecular;
  61671. /**
  61672. * Allows the maximum specular power to be defined for material calculations
  61673. */
  61674. private static readonly _MaxSpecularPower;
  61675. /**
  61676. * Mapping to store textures
  61677. */
  61678. private _textureMap;
  61679. /**
  61680. * Numeric tolerance value
  61681. */
  61682. private static readonly _Epsilon;
  61683. /**
  61684. * Reference to the glTF Exporter
  61685. */
  61686. private _exporter;
  61687. constructor(exporter: _Exporter);
  61688. /**
  61689. * Specifies if two colors are approximately equal in value
  61690. * @param color1 first color to compare to
  61691. * @param color2 second color to compare to
  61692. * @param epsilon threshold value
  61693. */
  61694. private static FuzzyEquals;
  61695. /**
  61696. * Gets the materials from a Babylon scene and converts them to glTF materials
  61697. * @param scene babylonjs scene
  61698. * @param mimeType texture mime type
  61699. * @param images array of images
  61700. * @param textures array of textures
  61701. * @param materials array of materials
  61702. * @param imageData mapping of texture names to base64 textures
  61703. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61704. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61705. /**
  61706. * Makes a copy of the glTF material without the texture parameters
  61707. * @param originalMaterial original glTF material
  61708. * @returns glTF material without texture parameters
  61709. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61710. /**
  61711. * Specifies if the material has any texture parameters present
  61712. * @param material glTF Material
  61713. * @returns boolean specifying if texture parameters are present
  61714. */ hasTexturesPresent(material: IMaterial): boolean;
  61715. /**
  61716. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61717. * @param babylonStandardMaterial
  61718. * @returns glTF Metallic Roughness Material representation
  61719. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61720. /**
  61721. * Computes the metallic factor
  61722. * @param diffuse diffused value
  61723. * @param specular specular value
  61724. * @param oneMinusSpecularStrength one minus the specular strength
  61725. * @returns metallic value
  61726. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61727. /**
  61728. * Gets the glTF alpha mode from the Babylon Material
  61729. * @param babylonMaterial Babylon Material
  61730. * @returns The Babylon alpha mode value
  61731. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61732. /**
  61733. * Converts a Babylon Standard Material to a glTF Material
  61734. * @param babylonStandardMaterial BJS Standard Material
  61735. * @param mimeType mime type to use for the textures
  61736. * @param images array of glTF image interfaces
  61737. * @param textures array of glTF texture interfaces
  61738. * @param materials array of glTF material interfaces
  61739. * @param imageData map of image file name to data
  61740. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61741. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61742. /**
  61743. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61744. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61745. * @param mimeType mime type to use for the textures
  61746. * @param images array of glTF image interfaces
  61747. * @param textures array of glTF texture interfaces
  61748. * @param materials array of glTF material interfaces
  61749. * @param imageData map of image file name to data
  61750. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61751. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61752. /**
  61753. * Converts an image typed array buffer to a base64 image
  61754. * @param buffer typed array buffer
  61755. * @param width width of the image
  61756. * @param height height of the image
  61757. * @param mimeType mimetype of the image
  61758. * @returns base64 image string
  61759. */
  61760. private _createBase64FromCanvasAsync;
  61761. /**
  61762. * Generates a white texture based on the specified width and height
  61763. * @param width width of the texture in pixels
  61764. * @param height height of the texture in pixels
  61765. * @param scene babylonjs scene
  61766. * @returns white texture
  61767. */
  61768. private _createWhiteTexture;
  61769. /**
  61770. * 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
  61771. * @param texture1 first texture to resize
  61772. * @param texture2 second texture to resize
  61773. * @param scene babylonjs scene
  61774. * @returns resized textures or null
  61775. */
  61776. private _resizeTexturesToSameDimensions;
  61777. /**
  61778. * Converts an array of pixels to a Float32Array
  61779. * Throws an error if the pixel format is not supported
  61780. * @param pixels - array buffer containing pixel values
  61781. * @returns Float32 of pixels
  61782. */
  61783. private _convertPixelArrayToFloat32;
  61784. /**
  61785. * Convert Specular Glossiness Textures to Metallic Roughness
  61786. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61787. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61788. * @param diffuseTexture texture used to store diffuse information
  61789. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61790. * @param factors specular glossiness material factors
  61791. * @param mimeType the mime type to use for the texture
  61792. * @returns pbr metallic roughness interface or null
  61793. */
  61794. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61795. /**
  61796. * Converts specular glossiness material properties to metallic roughness
  61797. * @param specularGlossiness interface with specular glossiness material properties
  61798. * @returns interface with metallic roughness material properties
  61799. */
  61800. private _convertSpecularGlossinessToMetallicRoughness;
  61801. /**
  61802. * Calculates the surface reflectance, independent of lighting conditions
  61803. * @param color Color source to calculate brightness from
  61804. * @returns number representing the perceived brightness, or zero if color is undefined
  61805. */
  61806. private _getPerceivedBrightness;
  61807. /**
  61808. * Returns the maximum color component value
  61809. * @param color
  61810. * @returns maximum color component value, or zero if color is null or undefined
  61811. */
  61812. private _getMaxComponent;
  61813. /**
  61814. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61815. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61816. * @param mimeType mime type to use for the textures
  61817. * @param images array of glTF image interfaces
  61818. * @param textures array of glTF texture interfaces
  61819. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61820. * @param imageData map of image file name to data
  61821. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61822. * @returns glTF PBR Metallic Roughness factors
  61823. */
  61824. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61825. private _getGLTFTextureSampler;
  61826. private _getGLTFTextureWrapMode;
  61827. private _getGLTFTextureWrapModesSampler;
  61828. /**
  61829. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61830. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61831. * @param mimeType mime type to use for the textures
  61832. * @param images array of glTF image interfaces
  61833. * @param textures array of glTF texture interfaces
  61834. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61835. * @param imageData map of image file name to data
  61836. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61837. * @returns glTF PBR Metallic Roughness factors
  61838. */
  61839. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61840. /**
  61841. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61842. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61843. * @param mimeType mime type to use for the textures
  61844. * @param images array of glTF image interfaces
  61845. * @param textures array of glTF texture interfaces
  61846. * @param materials array of glTF material interfaces
  61847. * @param imageData map of image file name to data
  61848. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61849. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61850. private setMetallicRoughnessPbrMaterial;
  61851. private getPixelsFromTexture;
  61852. /**
  61853. * Extracts a texture from a Babylon texture into file data and glTF data
  61854. * @param babylonTexture Babylon texture to extract
  61855. * @param mimeType Mime Type of the babylonTexture
  61856. * @return glTF texture info, or null if the texture format is not supported
  61857. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61858. /**
  61859. * Builds a texture from base64 string
  61860. * @param base64Texture base64 texture string
  61861. * @param baseTextureName Name to use for the texture
  61862. * @param mimeType image mime type for the texture
  61863. * @param images array of images
  61864. * @param textures array of textures
  61865. * @param imageData map of image data
  61866. * @returns glTF texture info, or null if the texture format is not supported
  61867. */
  61868. private _getTextureInfoFromBase64;
  61869. }
  61870. }
  61871. declare module BABYLON {
  61872. /**
  61873. * Class for holding and downloading glTF file data
  61874. */
  61875. export class GLTFData {
  61876. /**
  61877. * Object which contains the file name as the key and its data as the value
  61878. */
  61879. glTFFiles: {
  61880. [fileName: string]: string | Blob;
  61881. };
  61882. /**
  61883. * Initializes the glTF file object
  61884. */
  61885. constructor();
  61886. /**
  61887. * Downloads the glTF data as files based on their names and data
  61888. */
  61889. downloadFiles(): void;
  61890. }
  61891. }
  61892. declare module BABYLON {
  61893. /**
  61894. * Holds a collection of exporter options and parameters
  61895. */
  61896. export interface IExportOptions {
  61897. /**
  61898. * Function which indicates whether a babylon node should be exported or not
  61899. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61900. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61901. */
  61902. shouldExportNode?(node: Node): boolean;
  61903. /**
  61904. * The sample rate to bake animation curves
  61905. */
  61906. animationSampleRate?: number;
  61907. /**
  61908. * Begin serialization without waiting for the scene to be ready
  61909. */
  61910. exportWithoutWaitingForScene?: boolean;
  61911. }
  61912. /**
  61913. * Class for generating glTF data from a Babylon scene.
  61914. */
  61915. export class GLTF2Export {
  61916. /**
  61917. * Exports the geometry of the scene to .gltf file format asynchronously
  61918. * @param scene Babylon scene with scene hierarchy information
  61919. * @param filePrefix File prefix to use when generating the glTF file
  61920. * @param options Exporter options
  61921. * @returns Returns an object with a .gltf file and associates texture names
  61922. * as keys and their data and paths as values
  61923. */
  61924. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61925. private static _PreExportAsync;
  61926. private static _PostExportAsync;
  61927. /**
  61928. * Exports the geometry of the scene to .glb file format asychronously
  61929. * @param scene Babylon scene with scene hierarchy information
  61930. * @param filePrefix File prefix to use when generating glb file
  61931. * @param options Exporter options
  61932. * @returns Returns an object with a .glb filename as key and data as value
  61933. */
  61934. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61935. }
  61936. }
  61937. declare module BABYLON.GLTF2.Exporter {
  61938. /**
  61939. * @hidden
  61940. */
  61941. export class _GLTFUtilities {
  61942. /**
  61943. * Creates a buffer view based on the supplied arguments
  61944. * @param bufferIndex index value of the specified buffer
  61945. * @param byteOffset byte offset value
  61946. * @param byteLength byte length of the bufferView
  61947. * @param byteStride byte distance between conequential elements
  61948. * @param name name of the buffer view
  61949. * @returns bufferView for glTF
  61950. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61951. /**
  61952. * Creates an accessor based on the supplied arguments
  61953. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61954. * @param name The name of the accessor
  61955. * @param type The type of the accessor
  61956. * @param componentType The datatype of components in the attribute
  61957. * @param count The number of attributes referenced by this accessor
  61958. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61959. * @param min Minimum value of each component in this attribute
  61960. * @param max Maximum value of each component in this attribute
  61961. * @returns accessor for glTF
  61962. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61963. /**
  61964. * Calculates the minimum and maximum values of an array of position floats
  61965. * @param positions Positions array of a mesh
  61966. * @param vertexStart Starting vertex offset to calculate min and max values
  61967. * @param vertexCount Number of vertices to check for min and max values
  61968. * @returns min number array and max number array
  61969. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61970. min: number[];
  61971. max: number[];
  61972. };
  61973. /**
  61974. * Converts a new right-handed Vector3
  61975. * @param vector vector3 array
  61976. * @returns right-handed Vector3
  61977. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61978. /**
  61979. * Converts a Vector3 to right-handed
  61980. * @param vector Vector3 to convert to right-handed
  61981. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61982. /**
  61983. * Converts a three element number array to right-handed
  61984. * @param vector number array to convert to right-handed
  61985. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61986. /**
  61987. * Converts a new right-handed Vector3
  61988. * @param vector vector3 array
  61989. * @returns right-handed Vector3
  61990. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61991. /**
  61992. * Converts a Vector3 to right-handed
  61993. * @param vector Vector3 to convert to right-handed
  61994. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61995. /**
  61996. * Converts a three element number array to right-handed
  61997. * @param vector number array to convert to right-handed
  61998. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61999. /**
  62000. * Converts a Vector4 to right-handed
  62001. * @param vector Vector4 to convert to right-handed
  62002. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62003. /**
  62004. * Converts a Vector4 to right-handed
  62005. * @param vector Vector4 to convert to right-handed
  62006. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62007. /**
  62008. * Converts a Quaternion to right-handed
  62009. * @param quaternion Source quaternion to convert to right-handed
  62010. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62011. /**
  62012. * Converts a Quaternion to right-handed
  62013. * @param quaternion Source quaternion to convert to right-handed
  62014. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62015. }
  62016. }
  62017. declare module BABYLON.GLTF2.Exporter {
  62018. /**
  62019. * Converts Babylon Scene into glTF 2.0.
  62020. * @hidden
  62021. */
  62022. export class _Exporter {
  62023. /**
  62024. * Stores the glTF to export
  62025. */ glTF: IGLTF;
  62026. /**
  62027. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62028. */ bufferViews: IBufferView[];
  62029. /**
  62030. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62031. */ accessors: IAccessor[];
  62032. /**
  62033. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62034. */
  62035. private _nodes;
  62036. /**
  62037. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62038. */
  62039. private _scenes;
  62040. /**
  62041. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62042. */
  62043. private _meshes;
  62044. /**
  62045. * Stores all the generated material information, which represents the appearance of each primitive
  62046. */ materials: IMaterial[]; materialMap: {
  62047. [materialID: number]: number;
  62048. };
  62049. /**
  62050. * Stores all the generated texture information, which is referenced by glTF materials
  62051. */ textures: ITexture[];
  62052. /**
  62053. * Stores all the generated image information, which is referenced by glTF textures
  62054. */ images: IImage[];
  62055. /**
  62056. * Stores all the texture samplers
  62057. */ samplers: ISampler[];
  62058. /**
  62059. * Stores all the generated animation samplers, which is referenced by glTF animations
  62060. */
  62061. /**
  62062. * Stores the animations for glTF models
  62063. */
  62064. private _animations;
  62065. /**
  62066. * Stores the total amount of bytes stored in the glTF buffer
  62067. */
  62068. private _totalByteLength;
  62069. /**
  62070. * Stores a reference to the Babylon scene containing the source geometry and material information
  62071. */ babylonScene: Scene;
  62072. /**
  62073. * Stores a map of the image data, where the key is the file name and the value
  62074. * is the image data
  62075. */ imageData: {
  62076. [fileName: string]: {
  62077. data: Uint8Array;
  62078. mimeType: ImageMimeType;
  62079. };
  62080. };
  62081. /**
  62082. * Stores a map of the unique id of a node to its index in the node array
  62083. */
  62084. private _nodeMap;
  62085. /**
  62086. * Specifies if the Babylon scene should be converted to right-handed on export
  62087. */ convertToRightHandedSystem: boolean;
  62088. /**
  62089. * Baked animation sample rate
  62090. */
  62091. private _animationSampleRate;
  62092. /**
  62093. * Callback which specifies if a node should be exported or not
  62094. */
  62095. private _shouldExportNode;
  62096. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62097. private _extensions;
  62098. private static _ExtensionNames;
  62099. private static _ExtensionFactories;
  62100. 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>>;
  62101. private _forEachExtensions;
  62102. private _extensionsOnExporting;
  62103. /**
  62104. * Load glTF serializer extensions
  62105. */
  62106. private _loadExtensions;
  62107. /**
  62108. * Creates a glTF Exporter instance, which can accept optional exporter options
  62109. * @param babylonScene Babylon scene object
  62110. * @param options Options to modify the behavior of the exporter
  62111. */
  62112. constructor(babylonScene: Scene, options?: IExportOptions);
  62113. /**
  62114. * Registers a glTF exporter extension
  62115. * @param name Name of the extension to export
  62116. * @param factory The factory function that creates the exporter extension
  62117. */
  62118. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62119. /**
  62120. * Un-registers an exporter extension
  62121. * @param name The name fo the exporter extension
  62122. * @returns A boolean indicating whether the extension has been un-registered
  62123. */
  62124. static UnregisterExtension(name: string): boolean;
  62125. /**
  62126. * Lazy load a local engine with premultiplied alpha set to false
  62127. */ getLocalEngine(): Engine;
  62128. private reorderIndicesBasedOnPrimitiveMode;
  62129. /**
  62130. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62131. * clock-wise during export to glTF
  62132. * @param submesh BabylonJS submesh
  62133. * @param primitiveMode Primitive mode of the mesh
  62134. * @param sideOrientation the winding order of the submesh
  62135. * @param vertexBufferKind The type of vertex attribute
  62136. * @param meshAttributeArray The vertex attribute data
  62137. * @param byteOffset The offset to the binary data
  62138. * @param binaryWriter The binary data for the glTF file
  62139. */
  62140. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62141. /**
  62142. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62143. * clock-wise during export to glTF
  62144. * @param submesh BabylonJS submesh
  62145. * @param primitiveMode Primitive mode of the mesh
  62146. * @param sideOrientation the winding order of the submesh
  62147. * @param vertexBufferKind The type of vertex attribute
  62148. * @param meshAttributeArray The vertex attribute data
  62149. * @param byteOffset The offset to the binary data
  62150. * @param binaryWriter The binary data for the glTF file
  62151. */
  62152. private reorderTriangleFillMode;
  62153. /**
  62154. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62155. * clock-wise during export to glTF
  62156. * @param submesh BabylonJS submesh
  62157. * @param primitiveMode Primitive mode of the mesh
  62158. * @param sideOrientation the winding order of the submesh
  62159. * @param vertexBufferKind The type of vertex attribute
  62160. * @param meshAttributeArray The vertex attribute data
  62161. * @param byteOffset The offset to the binary data
  62162. * @param binaryWriter The binary data for the glTF file
  62163. */
  62164. private reorderTriangleStripDrawMode;
  62165. /**
  62166. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62167. * clock-wise during export to glTF
  62168. * @param submesh BabylonJS submesh
  62169. * @param primitiveMode Primitive mode of the mesh
  62170. * @param sideOrientation the winding order of the submesh
  62171. * @param vertexBufferKind The type of vertex attribute
  62172. * @param meshAttributeArray The vertex attribute data
  62173. * @param byteOffset The offset to the binary data
  62174. * @param binaryWriter The binary data for the glTF file
  62175. */
  62176. private reorderTriangleFanMode;
  62177. /**
  62178. * Writes the vertex attribute data to binary
  62179. * @param vertices The vertices to write to the binary writer
  62180. * @param byteOffset The offset into the binary writer to overwrite binary data
  62181. * @param vertexAttributeKind The vertex attribute type
  62182. * @param meshAttributeArray The vertex attribute data
  62183. * @param binaryWriter The writer containing the binary data
  62184. */
  62185. private writeVertexAttributeData;
  62186. /**
  62187. * Writes mesh attribute data to a data buffer
  62188. * Returns the bytelength of the data
  62189. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62190. * @param meshAttributeArray Array containing the attribute data
  62191. * @param binaryWriter The buffer to write the binary data to
  62192. * @param indices Used to specify the order of the vertex data
  62193. */
  62194. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62195. /**
  62196. * Generates glTF json data
  62197. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62198. * @param glTFPrefix Text to use when prefixing a glTF file
  62199. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62200. * @returns json data as string
  62201. */
  62202. private generateJSON;
  62203. /**
  62204. * Generates data for .gltf and .bin files based on the glTF prefix string
  62205. * @param glTFPrefix Text to use when prefixing a glTF file
  62206. * @returns GLTFData with glTF file data
  62207. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62208. /**
  62209. * Creates a binary buffer for glTF
  62210. * @returns array buffer for binary data
  62211. */
  62212. private _generateBinaryAsync;
  62213. /**
  62214. * Pads the number to a multiple of 4
  62215. * @param num number to pad
  62216. * @returns padded number
  62217. */
  62218. private _getPadding;
  62219. /**
  62220. * Generates a glb file from the json and binary data
  62221. * Returns an object with the glb file name as the key and data as the value
  62222. * @param glTFPrefix
  62223. * @returns object with glb filename as key and data as value
  62224. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62225. /**
  62226. * Sets the TRS for each node
  62227. * @param node glTF Node for storing the transformation data
  62228. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62229. */
  62230. private setNodeTransformation;
  62231. private getVertexBufferFromMesh;
  62232. /**
  62233. * Creates a bufferview based on the vertices type for the Babylon mesh
  62234. * @param kind Indicates the type of vertices data
  62235. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62236. * @param binaryWriter The buffer to write the bufferview data to
  62237. */
  62238. private createBufferViewKind;
  62239. /**
  62240. * The primitive mode of the Babylon mesh
  62241. * @param babylonMesh The BabylonJS mesh
  62242. */
  62243. private getMeshPrimitiveMode;
  62244. /**
  62245. * Sets the primitive mode of the glTF mesh primitive
  62246. * @param meshPrimitive glTF mesh primitive
  62247. * @param primitiveMode The primitive mode
  62248. */
  62249. private setPrimitiveMode;
  62250. /**
  62251. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62252. * @param meshPrimitive glTF mesh primitive
  62253. * @param attributeKind vertex attribute
  62254. * @returns boolean specifying if uv coordinates are present
  62255. */
  62256. private setAttributeKind;
  62257. /**
  62258. * Sets data for the primitive attributes of each submesh
  62259. * @param mesh glTF Mesh object to store the primitive attribute information
  62260. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62261. * @param binaryWriter Buffer to write the attribute data to
  62262. */
  62263. private setPrimitiveAttributesAsync;
  62264. /**
  62265. * Creates a glTF scene based on the array of meshes
  62266. * Returns the the total byte offset
  62267. * @param babylonScene Babylon scene to get the mesh data from
  62268. * @param binaryWriter Buffer to write binary data to
  62269. */
  62270. private createSceneAsync;
  62271. /**
  62272. * Creates a mapping of Node unique id to node index and handles animations
  62273. * @param babylonScene Babylon Scene
  62274. * @param nodes Babylon transform nodes
  62275. * @param shouldExportNode Callback specifying if a transform node should be exported
  62276. * @param binaryWriter Buffer to write binary data to
  62277. * @returns Node mapping of unique id to index
  62278. */
  62279. private createNodeMapAndAnimationsAsync;
  62280. /**
  62281. * Creates a glTF node from a Babylon mesh
  62282. * @param babylonMesh Source Babylon mesh
  62283. * @param binaryWriter Buffer for storing geometry data
  62284. * @returns glTF node
  62285. */
  62286. private createNodeAsync;
  62287. }
  62288. /**
  62289. * @hidden
  62290. *
  62291. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62292. */
  62293. export class _BinaryWriter {
  62294. /**
  62295. * Array buffer which stores all binary data
  62296. */
  62297. private _arrayBuffer;
  62298. /**
  62299. * View of the array buffer
  62300. */
  62301. private _dataView;
  62302. /**
  62303. * byte offset of data in array buffer
  62304. */
  62305. private _byteOffset;
  62306. /**
  62307. * Initialize binary writer with an initial byte length
  62308. * @param byteLength Initial byte length of the array buffer
  62309. */
  62310. constructor(byteLength: number);
  62311. /**
  62312. * Resize the array buffer to the specified byte length
  62313. * @param byteLength
  62314. */
  62315. private resizeBuffer;
  62316. /**
  62317. * Get an array buffer with the length of the byte offset
  62318. * @returns ArrayBuffer resized to the byte offset
  62319. */
  62320. getArrayBuffer(): ArrayBuffer;
  62321. /**
  62322. * Get the byte offset of the array buffer
  62323. * @returns byte offset
  62324. */
  62325. getByteOffset(): number;
  62326. /**
  62327. * Stores an UInt8 in the array buffer
  62328. * @param entry
  62329. * @param byteOffset If defined, specifies where to set the value as an offset.
  62330. */
  62331. setUInt8(entry: number, byteOffset?: number): void;
  62332. /**
  62333. * Gets an UInt32 in the array buffer
  62334. * @param entry
  62335. * @param byteOffset If defined, specifies where to set the value as an offset.
  62336. */
  62337. getUInt32(byteOffset: number): number;
  62338. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62339. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62340. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62341. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62342. /**
  62343. * Stores a Float32 in the array buffer
  62344. * @param entry
  62345. */
  62346. setFloat32(entry: number, byteOffset?: number): void;
  62347. /**
  62348. * Stores an UInt32 in the array buffer
  62349. * @param entry
  62350. * @param byteOffset If defined, specifies where to set the value as an offset.
  62351. */
  62352. setUInt32(entry: number, byteOffset?: number): void;
  62353. }
  62354. }
  62355. declare module BABYLON.GLTF2.Exporter {
  62356. /**
  62357. * @hidden
  62358. * Interface to store animation data.
  62359. */
  62360. export interface _IAnimationData {
  62361. /**
  62362. * Keyframe data.
  62363. */
  62364. inputs: number[];
  62365. /**
  62366. * Value data.
  62367. */
  62368. outputs: number[][];
  62369. /**
  62370. * Animation interpolation data.
  62371. */
  62372. samplerInterpolation: AnimationSamplerInterpolation;
  62373. /**
  62374. * Minimum keyframe value.
  62375. */
  62376. inputsMin: number;
  62377. /**
  62378. * Maximum keyframe value.
  62379. */
  62380. inputsMax: number;
  62381. }
  62382. /**
  62383. * @hidden
  62384. */
  62385. export interface _IAnimationInfo {
  62386. /**
  62387. * The target channel for the animation
  62388. */
  62389. animationChannelTargetPath: AnimationChannelTargetPath;
  62390. /**
  62391. * The glTF accessor type for the data.
  62392. */
  62393. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62394. /**
  62395. * Specifies if quaternions should be used.
  62396. */
  62397. useQuaternion: boolean;
  62398. }
  62399. /**
  62400. * @hidden
  62401. * Utility class for generating glTF animation data from BabylonJS.
  62402. */
  62403. export class _GLTFAnimation {
  62404. /**
  62405. * @ignore
  62406. *
  62407. * Creates glTF channel animation from BabylonJS animation.
  62408. * @param babylonTransformNode - BabylonJS mesh.
  62409. * @param animation - animation.
  62410. * @param animationChannelTargetPath - The target animation channel.
  62411. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62412. * @param useQuaternion - Specifies if quaternions are used.
  62413. * @returns nullable IAnimationData
  62414. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62415. private static _DeduceAnimationInfo;
  62416. /**
  62417. * @ignore
  62418. * Create node animations from the transform node animations
  62419. * @param babylonNode
  62420. * @param runtimeGLTFAnimation
  62421. * @param idleGLTFAnimations
  62422. * @param nodeMap
  62423. * @param nodes
  62424. * @param binaryWriter
  62425. * @param bufferViews
  62426. * @param accessors
  62427. * @param convertToRightHandedSystem
  62428. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62429. [key: number]: number;
  62430. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62431. /**
  62432. * @ignore
  62433. * Create node animations from the animation groups
  62434. * @param babylonScene
  62435. * @param glTFAnimations
  62436. * @param nodeMap
  62437. * @param nodes
  62438. * @param binaryWriter
  62439. * @param bufferViews
  62440. * @param accessors
  62441. * @param convertToRightHandedSystem
  62442. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62443. [key: number]: number;
  62444. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62445. private static AddAnimation;
  62446. /**
  62447. * Create a baked animation
  62448. * @param babylonTransformNode BabylonJS mesh
  62449. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62450. * @param animationChannelTargetPath animation target channel
  62451. * @param minFrame minimum animation frame
  62452. * @param maxFrame maximum animation frame
  62453. * @param fps frames per second of the animation
  62454. * @param inputs input key frames of the animation
  62455. * @param outputs output key frame data of the animation
  62456. * @param convertToRightHandedSystem converts the values to right-handed
  62457. * @param useQuaternion specifies if quaternions should be used
  62458. */
  62459. private static _CreateBakedAnimation;
  62460. private static _ConvertFactorToVector3OrQuaternion;
  62461. private static _SetInterpolatedValue;
  62462. /**
  62463. * Creates linear animation from the animation key frames
  62464. * @param babylonTransformNode BabylonJS mesh
  62465. * @param animation BabylonJS animation
  62466. * @param animationChannelTargetPath The target animation channel
  62467. * @param frameDelta The difference between the last and first frame of the animation
  62468. * @param inputs Array to store the key frame times
  62469. * @param outputs Array to store the key frame data
  62470. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62471. * @param useQuaternion Specifies if quaternions are used in the animation
  62472. */
  62473. private static _CreateLinearOrStepAnimation;
  62474. /**
  62475. * Creates cubic spline animation from the animation key frames
  62476. * @param babylonTransformNode BabylonJS mesh
  62477. * @param animation BabylonJS animation
  62478. * @param animationChannelTargetPath The target animation channel
  62479. * @param frameDelta The difference between the last and first frame of the animation
  62480. * @param inputs Array to store the key frame times
  62481. * @param outputs Array to store the key frame data
  62482. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62483. * @param useQuaternion Specifies if quaternions are used in the animation
  62484. */
  62485. private static _CreateCubicSplineAnimation;
  62486. private static _GetBasePositionRotationOrScale;
  62487. /**
  62488. * Adds a key frame value
  62489. * @param keyFrame
  62490. * @param animation
  62491. * @param outputs
  62492. * @param animationChannelTargetPath
  62493. * @param basePositionRotationOrScale
  62494. * @param convertToRightHandedSystem
  62495. * @param useQuaternion
  62496. */
  62497. private static _AddKeyframeValue;
  62498. /**
  62499. * Determine the interpolation based on the key frames
  62500. * @param keyFrames
  62501. * @param animationChannelTargetPath
  62502. * @param useQuaternion
  62503. */
  62504. private static _DeduceInterpolation;
  62505. /**
  62506. * Adds an input tangent or output tangent to the output data
  62507. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62508. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62509. * @param outputs The animation data by keyframe
  62510. * @param animationChannelTargetPath The target animation channel
  62511. * @param interpolation The interpolation type
  62512. * @param keyFrame The key frame with the animation data
  62513. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62514. * @param useQuaternion Specifies if quaternions are used
  62515. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62516. */
  62517. private static AddSplineTangent;
  62518. /**
  62519. * Get the minimum and maximum key frames' frame values
  62520. * @param keyFrames animation key frames
  62521. * @returns the minimum and maximum key frame value
  62522. */
  62523. private static calculateMinMaxKeyFrames;
  62524. }
  62525. }
  62526. declare module BABYLON.GLTF2.Exporter {
  62527. /** @hidden */
  62528. export var textureTransformPixelShader: {
  62529. name: string;
  62530. shader: string;
  62531. };
  62532. }
  62533. declare module BABYLON.GLTF2.Exporter.Extensions {
  62534. /**
  62535. * @hidden
  62536. */
  62537. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62538. /** Name of this extension */
  62539. readonly name: string;
  62540. /** Defines whether this extension is enabled */
  62541. enabled: boolean;
  62542. /** Defines whether this extension is required */
  62543. required: boolean;
  62544. /** Reference to the glTF exporter */
  62545. private _exporter;
  62546. constructor(exporter: _Exporter);
  62547. dispose(): void;
  62548. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62549. /**
  62550. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62551. * @param babylonTexture
  62552. * @param offset
  62553. * @param rotation
  62554. * @param scale
  62555. * @param scene
  62556. */
  62557. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62558. }
  62559. }
  62560. declare module BABYLON.GLTF2.Exporter.Extensions {
  62561. /**
  62562. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62563. */
  62564. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62565. /** The name of this extension. */
  62566. readonly name: string;
  62567. /** Defines whether this extension is enabled. */
  62568. enabled: boolean;
  62569. /** Defines whether this extension is required */
  62570. required: boolean;
  62571. /** Reference to the glTF exporter */
  62572. private _exporter;
  62573. private _lights;
  62574. /** @hidden */
  62575. constructor(exporter: _Exporter);
  62576. /** @hidden */
  62577. dispose(): void;
  62578. /** @hidden */
  62579. onExporting(): void;
  62580. /**
  62581. * Define this method to modify the default behavior when exporting a node
  62582. * @param context The context when exporting the node
  62583. * @param node glTF node
  62584. * @param babylonNode BabylonJS node
  62585. * @returns nullable INode promise
  62586. */
  62587. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62588. }
  62589. }
  62590. declare module BABYLON {
  62591. /**
  62592. * Class for generating STL data from a Babylon scene.
  62593. */
  62594. export class STLExport {
  62595. /**
  62596. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62597. * @param meshes list defines the mesh to serialize
  62598. * @param download triggers the automatic download of the file.
  62599. * @param fileName changes the downloads fileName.
  62600. * @param binary changes the STL to a binary type.
  62601. * @param isLittleEndian toggle for binary type exporter.
  62602. * @returns the STL as UTF8 string
  62603. */
  62604. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62605. }
  62606. }
  62607. /**
  62608. * @ignoreChildren
  62609. * @ignore
  62610. */
  62611. declare module "babylonjs-gltf2interface" {
  62612. export = BABYLON.GLTF2;
  62613. }
  62614. /**
  62615. * Module for glTF 2.0 Interface
  62616. * @ignoreChildren
  62617. * @ignore
  62618. */
  62619. declare module BABYLON.GLTF2 {
  62620. /**
  62621. * The datatype of the components in the attribute
  62622. */
  62623. const enum AccessorComponentType {
  62624. /**
  62625. * Byte
  62626. */
  62627. BYTE = 5120,
  62628. /**
  62629. * Unsigned Byte
  62630. */
  62631. UNSIGNED_BYTE = 5121,
  62632. /**
  62633. * Short
  62634. */
  62635. SHORT = 5122,
  62636. /**
  62637. * Unsigned Short
  62638. */
  62639. UNSIGNED_SHORT = 5123,
  62640. /**
  62641. * Unsigned Int
  62642. */
  62643. UNSIGNED_INT = 5125,
  62644. /**
  62645. * Float
  62646. */
  62647. FLOAT = 5126,
  62648. }
  62649. /**
  62650. * Specifies if the attirbute is a scalar, vector, or matrix
  62651. */
  62652. const enum AccessorType {
  62653. /**
  62654. * Scalar
  62655. */
  62656. SCALAR = "SCALAR",
  62657. /**
  62658. * Vector2
  62659. */
  62660. VEC2 = "VEC2",
  62661. /**
  62662. * Vector3
  62663. */
  62664. VEC3 = "VEC3",
  62665. /**
  62666. * Vector4
  62667. */
  62668. VEC4 = "VEC4",
  62669. /**
  62670. * Matrix2x2
  62671. */
  62672. MAT2 = "MAT2",
  62673. /**
  62674. * Matrix3x3
  62675. */
  62676. MAT3 = "MAT3",
  62677. /**
  62678. * Matrix4x4
  62679. */
  62680. MAT4 = "MAT4",
  62681. }
  62682. /**
  62683. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62684. */
  62685. const enum AnimationChannelTargetPath {
  62686. /**
  62687. * Translation
  62688. */
  62689. TRANSLATION = "translation",
  62690. /**
  62691. * Rotation
  62692. */
  62693. ROTATION = "rotation",
  62694. /**
  62695. * Scale
  62696. */
  62697. SCALE = "scale",
  62698. /**
  62699. * Weights
  62700. */
  62701. WEIGHTS = "weights",
  62702. }
  62703. /**
  62704. * Interpolation algorithm
  62705. */
  62706. const enum AnimationSamplerInterpolation {
  62707. /**
  62708. * The animated values are linearly interpolated between keyframes
  62709. */
  62710. LINEAR = "LINEAR",
  62711. /**
  62712. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62713. */
  62714. STEP = "STEP",
  62715. /**
  62716. * The animation's interpolation is computed using a cubic spline with specified tangents
  62717. */
  62718. CUBICSPLINE = "CUBICSPLINE",
  62719. }
  62720. /**
  62721. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62722. */
  62723. const enum CameraType {
  62724. /**
  62725. * A perspective camera containing properties to create a perspective projection matrix
  62726. */
  62727. PERSPECTIVE = "perspective",
  62728. /**
  62729. * An orthographic camera containing properties to create an orthographic projection matrix
  62730. */
  62731. ORTHOGRAPHIC = "orthographic",
  62732. }
  62733. /**
  62734. * The mime-type of the image
  62735. */
  62736. const enum ImageMimeType {
  62737. /**
  62738. * JPEG Mime-type
  62739. */
  62740. JPEG = "image/jpeg",
  62741. /**
  62742. * PNG Mime-type
  62743. */
  62744. PNG = "image/png",
  62745. }
  62746. /**
  62747. * The alpha rendering mode of the material
  62748. */
  62749. const enum MaterialAlphaMode {
  62750. /**
  62751. * The alpha value is ignored and the rendered output is fully opaque
  62752. */
  62753. OPAQUE = "OPAQUE",
  62754. /**
  62755. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62756. */
  62757. MASK = "MASK",
  62758. /**
  62759. * 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)
  62760. */
  62761. BLEND = "BLEND",
  62762. }
  62763. /**
  62764. * The type of the primitives to render
  62765. */
  62766. const enum MeshPrimitiveMode {
  62767. /**
  62768. * Points
  62769. */
  62770. POINTS = 0,
  62771. /**
  62772. * Lines
  62773. */
  62774. LINES = 1,
  62775. /**
  62776. * Line Loop
  62777. */
  62778. LINE_LOOP = 2,
  62779. /**
  62780. * Line Strip
  62781. */
  62782. LINE_STRIP = 3,
  62783. /**
  62784. * Triangles
  62785. */
  62786. TRIANGLES = 4,
  62787. /**
  62788. * Triangle Strip
  62789. */
  62790. TRIANGLE_STRIP = 5,
  62791. /**
  62792. * Triangle Fan
  62793. */
  62794. TRIANGLE_FAN = 6,
  62795. }
  62796. /**
  62797. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62798. */
  62799. const enum TextureMagFilter {
  62800. /**
  62801. * Nearest
  62802. */
  62803. NEAREST = 9728,
  62804. /**
  62805. * Linear
  62806. */
  62807. LINEAR = 9729,
  62808. }
  62809. /**
  62810. * Minification filter. All valid values correspond to WebGL enums
  62811. */
  62812. const enum TextureMinFilter {
  62813. /**
  62814. * Nearest
  62815. */
  62816. NEAREST = 9728,
  62817. /**
  62818. * Linear
  62819. */
  62820. LINEAR = 9729,
  62821. /**
  62822. * Nearest Mip-Map Nearest
  62823. */
  62824. NEAREST_MIPMAP_NEAREST = 9984,
  62825. /**
  62826. * Linear Mipmap Nearest
  62827. */
  62828. LINEAR_MIPMAP_NEAREST = 9985,
  62829. /**
  62830. * Nearest Mipmap Linear
  62831. */
  62832. NEAREST_MIPMAP_LINEAR = 9986,
  62833. /**
  62834. * Linear Mipmap Linear
  62835. */
  62836. LINEAR_MIPMAP_LINEAR = 9987,
  62837. }
  62838. /**
  62839. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62840. */
  62841. const enum TextureWrapMode {
  62842. /**
  62843. * Clamp to Edge
  62844. */
  62845. CLAMP_TO_EDGE = 33071,
  62846. /**
  62847. * Mirrored Repeat
  62848. */
  62849. MIRRORED_REPEAT = 33648,
  62850. /**
  62851. * Repeat
  62852. */
  62853. REPEAT = 10497,
  62854. }
  62855. /**
  62856. * glTF Property
  62857. */
  62858. interface IProperty {
  62859. /**
  62860. * Dictionary object with extension-specific objects
  62861. */
  62862. extensions?: {
  62863. [key: string]: any;
  62864. };
  62865. /**
  62866. * Application-Specific data
  62867. */
  62868. extras?: any;
  62869. }
  62870. /**
  62871. * glTF Child of Root Property
  62872. */
  62873. interface IChildRootProperty extends IProperty {
  62874. /**
  62875. * The user-defined name of this object
  62876. */
  62877. name?: string;
  62878. }
  62879. /**
  62880. * Indices of those attributes that deviate from their initialization value
  62881. */
  62882. interface IAccessorSparseIndices extends IProperty {
  62883. /**
  62884. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62885. */
  62886. bufferView: number;
  62887. /**
  62888. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62889. */
  62890. byteOffset?: number;
  62891. /**
  62892. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62893. */
  62894. componentType: AccessorComponentType;
  62895. }
  62896. /**
  62897. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62898. */
  62899. interface IAccessorSparseValues extends IProperty {
  62900. /**
  62901. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62902. */
  62903. bufferView: number;
  62904. /**
  62905. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62906. */
  62907. byteOffset?: number;
  62908. }
  62909. /**
  62910. * Sparse storage of attributes that deviate from their initialization value
  62911. */
  62912. interface IAccessorSparse extends IProperty {
  62913. /**
  62914. * The number of attributes encoded in this sparse accessor
  62915. */
  62916. count: number;
  62917. /**
  62918. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62919. */
  62920. indices: IAccessorSparseIndices;
  62921. /**
  62922. * 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
  62923. */
  62924. values: IAccessorSparseValues;
  62925. }
  62926. /**
  62927. * 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
  62928. */
  62929. interface IAccessor extends IChildRootProperty {
  62930. /**
  62931. * The index of the bufferview
  62932. */
  62933. bufferView?: number;
  62934. /**
  62935. * The offset relative to the start of the bufferView in bytes
  62936. */
  62937. byteOffset?: number;
  62938. /**
  62939. * The datatype of components in the attribute
  62940. */
  62941. componentType: AccessorComponentType;
  62942. /**
  62943. * Specifies whether integer data values should be normalized
  62944. */
  62945. normalized?: boolean;
  62946. /**
  62947. * The number of attributes referenced by this accessor
  62948. */
  62949. count: number;
  62950. /**
  62951. * Specifies if the attribute is a scalar, vector, or matrix
  62952. */
  62953. type: AccessorType;
  62954. /**
  62955. * Maximum value of each component in this attribute
  62956. */
  62957. max?: number[];
  62958. /**
  62959. * Minimum value of each component in this attribute
  62960. */
  62961. min?: number[];
  62962. /**
  62963. * Sparse storage of attributes that deviate from their initialization value
  62964. */
  62965. sparse?: IAccessorSparse;
  62966. }
  62967. /**
  62968. * Targets an animation's sampler at a node's property
  62969. */
  62970. interface IAnimationChannel extends IProperty {
  62971. /**
  62972. * The index of a sampler in this animation used to compute the value for the target
  62973. */
  62974. sampler: number;
  62975. /**
  62976. * The index of the node and TRS property to target
  62977. */
  62978. target: IAnimationChannelTarget;
  62979. }
  62980. /**
  62981. * The index of the node and TRS property that an animation channel targets
  62982. */
  62983. interface IAnimationChannelTarget extends IProperty {
  62984. /**
  62985. * The index of the node to target
  62986. */
  62987. node: number;
  62988. /**
  62989. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62990. */
  62991. path: AnimationChannelTargetPath;
  62992. }
  62993. /**
  62994. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62995. */
  62996. interface IAnimationSampler extends IProperty {
  62997. /**
  62998. * The index of an accessor containing keyframe input values, e.g., time
  62999. */
  63000. input: number;
  63001. /**
  63002. * Interpolation algorithm
  63003. */
  63004. interpolation?: AnimationSamplerInterpolation;
  63005. /**
  63006. * The index of an accessor, containing keyframe output values
  63007. */
  63008. output: number;
  63009. }
  63010. /**
  63011. * A keyframe animation
  63012. */
  63013. interface IAnimation extends IChildRootProperty {
  63014. /**
  63015. * An array of channels, each of which targets an animation's sampler at a node's property
  63016. */
  63017. channels: IAnimationChannel[];
  63018. /**
  63019. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63020. */
  63021. samplers: IAnimationSampler[];
  63022. }
  63023. /**
  63024. * Metadata about the glTF asset
  63025. */
  63026. interface IAsset extends IChildRootProperty {
  63027. /**
  63028. * A copyright message suitable for display to credit the content creator
  63029. */
  63030. copyright?: string;
  63031. /**
  63032. * Tool that generated this glTF model. Useful for debugging
  63033. */
  63034. generator?: string;
  63035. /**
  63036. * The glTF version that this asset targets
  63037. */
  63038. version: string;
  63039. /**
  63040. * The minimum glTF version that this asset targets
  63041. */
  63042. minVersion?: string;
  63043. }
  63044. /**
  63045. * A buffer points to binary geometry, animation, or skins
  63046. */
  63047. interface IBuffer extends IChildRootProperty {
  63048. /**
  63049. * 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
  63050. */
  63051. uri?: string;
  63052. /**
  63053. * The length of the buffer in bytes
  63054. */
  63055. byteLength: number;
  63056. }
  63057. /**
  63058. * A view into a buffer generally representing a subset of the buffer
  63059. */
  63060. interface IBufferView extends IChildRootProperty {
  63061. /**
  63062. * The index of the buffer
  63063. */
  63064. buffer: number;
  63065. /**
  63066. * The offset into the buffer in bytes
  63067. */
  63068. byteOffset?: number;
  63069. /**
  63070. * The lenth of the bufferView in bytes
  63071. */
  63072. byteLength: number;
  63073. /**
  63074. * The stride, in bytes
  63075. */
  63076. byteStride?: number;
  63077. }
  63078. /**
  63079. * An orthographic camera containing properties to create an orthographic projection matrix
  63080. */
  63081. interface ICameraOrthographic extends IProperty {
  63082. /**
  63083. * The floating-point horizontal magnification of the view. Must not be zero
  63084. */
  63085. xmag: number;
  63086. /**
  63087. * The floating-point vertical magnification of the view. Must not be zero
  63088. */
  63089. ymag: number;
  63090. /**
  63091. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63092. */
  63093. zfar: number;
  63094. /**
  63095. * The floating-point distance to the near clipping plane
  63096. */
  63097. znear: number;
  63098. }
  63099. /**
  63100. * A perspective camera containing properties to create a perspective projection matrix
  63101. */
  63102. interface ICameraPerspective extends IProperty {
  63103. /**
  63104. * The floating-point aspect ratio of the field of view
  63105. */
  63106. aspectRatio?: number;
  63107. /**
  63108. * The floating-point vertical field of view in radians
  63109. */
  63110. yfov: number;
  63111. /**
  63112. * The floating-point distance to the far clipping plane
  63113. */
  63114. zfar?: number;
  63115. /**
  63116. * The floating-point distance to the near clipping plane
  63117. */
  63118. znear: number;
  63119. }
  63120. /**
  63121. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63122. */
  63123. interface ICamera extends IChildRootProperty {
  63124. /**
  63125. * An orthographic camera containing properties to create an orthographic projection matrix
  63126. */
  63127. orthographic?: ICameraOrthographic;
  63128. /**
  63129. * A perspective camera containing properties to create a perspective projection matrix
  63130. */
  63131. perspective?: ICameraPerspective;
  63132. /**
  63133. * Specifies if the camera uses a perspective or orthographic projection
  63134. */
  63135. type: CameraType;
  63136. }
  63137. /**
  63138. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63139. */
  63140. interface IImage extends IChildRootProperty {
  63141. /**
  63142. * 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
  63143. */
  63144. uri?: string;
  63145. /**
  63146. * The image's MIME type
  63147. */
  63148. mimeType?: ImageMimeType;
  63149. /**
  63150. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63151. */
  63152. bufferView?: number;
  63153. }
  63154. /**
  63155. * Material Normal Texture Info
  63156. */
  63157. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63158. /**
  63159. * The scalar multiplier applied to each normal vector of the normal texture
  63160. */
  63161. scale?: number;
  63162. }
  63163. /**
  63164. * Material Occlusion Texture Info
  63165. */
  63166. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63167. /**
  63168. * A scalar multiplier controlling the amount of occlusion applied
  63169. */
  63170. strength?: number;
  63171. }
  63172. /**
  63173. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63174. */
  63175. interface IMaterialPbrMetallicRoughness {
  63176. /**
  63177. * The material's base color factor
  63178. */
  63179. baseColorFactor?: number[];
  63180. /**
  63181. * The base color texture
  63182. */
  63183. baseColorTexture?: ITextureInfo;
  63184. /**
  63185. * The metalness of the material
  63186. */
  63187. metallicFactor?: number;
  63188. /**
  63189. * The roughness of the material
  63190. */
  63191. roughnessFactor?: number;
  63192. /**
  63193. * The metallic-roughness texture
  63194. */
  63195. metallicRoughnessTexture?: ITextureInfo;
  63196. }
  63197. /**
  63198. * The material appearance of a primitive
  63199. */
  63200. interface IMaterial extends IChildRootProperty {
  63201. /**
  63202. * 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
  63203. */
  63204. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63205. /**
  63206. * The normal map texture
  63207. */
  63208. normalTexture?: IMaterialNormalTextureInfo;
  63209. /**
  63210. * The occlusion map texture
  63211. */
  63212. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63213. /**
  63214. * The emissive map texture
  63215. */
  63216. emissiveTexture?: ITextureInfo;
  63217. /**
  63218. * 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
  63219. */
  63220. emissiveFactor?: number[];
  63221. /**
  63222. * The alpha rendering mode of the material
  63223. */
  63224. alphaMode?: MaterialAlphaMode;
  63225. /**
  63226. * The alpha cutoff value of the material
  63227. */
  63228. alphaCutoff?: number;
  63229. /**
  63230. * Specifies whether the material is double sided
  63231. */
  63232. doubleSided?: boolean;
  63233. }
  63234. /**
  63235. * Geometry to be rendered with the given material
  63236. */
  63237. interface IMeshPrimitive extends IProperty {
  63238. /**
  63239. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63240. */
  63241. attributes: {
  63242. [name: string]: number;
  63243. };
  63244. /**
  63245. * The index of the accessor that contains the indices
  63246. */
  63247. indices?: number;
  63248. /**
  63249. * The index of the material to apply to this primitive when rendering
  63250. */
  63251. material?: number;
  63252. /**
  63253. * The type of primitives to render. All valid values correspond to WebGL enums
  63254. */
  63255. mode?: MeshPrimitiveMode;
  63256. /**
  63257. * 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
  63258. */
  63259. targets?: {
  63260. [name: string]: number;
  63261. }[];
  63262. }
  63263. /**
  63264. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63265. */
  63266. interface IMesh extends IChildRootProperty {
  63267. /**
  63268. * An array of primitives, each defining geometry to be rendered with a material
  63269. */
  63270. primitives: IMeshPrimitive[];
  63271. /**
  63272. * Array of weights to be applied to the Morph Targets
  63273. */
  63274. weights?: number[];
  63275. }
  63276. /**
  63277. * A node in the node hierarchy
  63278. */
  63279. interface INode extends IChildRootProperty {
  63280. /**
  63281. * The index of the camera referenced by this node
  63282. */
  63283. camera?: number;
  63284. /**
  63285. * The indices of this node's children
  63286. */
  63287. children?: number[];
  63288. /**
  63289. * The index of the skin referenced by this node
  63290. */
  63291. skin?: number;
  63292. /**
  63293. * A floating-point 4x4 transformation matrix stored in column-major order
  63294. */
  63295. matrix?: number[];
  63296. /**
  63297. * The index of the mesh in this node
  63298. */
  63299. mesh?: number;
  63300. /**
  63301. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63302. */
  63303. rotation?: number[];
  63304. /**
  63305. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63306. */
  63307. scale?: number[];
  63308. /**
  63309. * The node's translation along the x, y, and z axes
  63310. */
  63311. translation?: number[];
  63312. /**
  63313. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63314. */
  63315. weights?: number[];
  63316. }
  63317. /**
  63318. * Texture sampler properties for filtering and wrapping modes
  63319. */
  63320. interface ISampler extends IChildRootProperty {
  63321. /**
  63322. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63323. */
  63324. magFilter?: TextureMagFilter;
  63325. /**
  63326. * Minification filter. All valid values correspond to WebGL enums
  63327. */
  63328. minFilter?: TextureMinFilter;
  63329. /**
  63330. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63331. */
  63332. wrapS?: TextureWrapMode;
  63333. /**
  63334. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63335. */
  63336. wrapT?: TextureWrapMode;
  63337. }
  63338. /**
  63339. * The root nodes of a scene
  63340. */
  63341. interface IScene extends IChildRootProperty {
  63342. /**
  63343. * The indices of each root node
  63344. */
  63345. nodes: number[];
  63346. }
  63347. /**
  63348. * Joints and matrices defining a skin
  63349. */
  63350. interface ISkin extends IChildRootProperty {
  63351. /**
  63352. * 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
  63353. */
  63354. inverseBindMatrices?: number;
  63355. /**
  63356. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63357. */
  63358. skeleton?: number;
  63359. /**
  63360. * 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)
  63361. */
  63362. joints: number[];
  63363. }
  63364. /**
  63365. * A texture and its sampler
  63366. */
  63367. interface ITexture extends IChildRootProperty {
  63368. /**
  63369. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63370. */
  63371. sampler?: number;
  63372. /**
  63373. * The index of the image used by this texture
  63374. */
  63375. source: number;
  63376. }
  63377. /**
  63378. * Reference to a texture
  63379. */
  63380. interface ITextureInfo extends IProperty {
  63381. /**
  63382. * The index of the texture
  63383. */
  63384. index: number;
  63385. /**
  63386. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63387. */
  63388. texCoord?: number;
  63389. }
  63390. /**
  63391. * The root object for a glTF asset
  63392. */
  63393. interface IGLTF extends IProperty {
  63394. /**
  63395. * An array of accessors. An accessor is a typed view into a bufferView
  63396. */
  63397. accessors?: IAccessor[];
  63398. /**
  63399. * An array of keyframe animations
  63400. */
  63401. animations?: IAnimation[];
  63402. /**
  63403. * Metadata about the glTF asset
  63404. */
  63405. asset: IAsset;
  63406. /**
  63407. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63408. */
  63409. buffers?: IBuffer[];
  63410. /**
  63411. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63412. */
  63413. bufferViews?: IBufferView[];
  63414. /**
  63415. * An array of cameras
  63416. */
  63417. cameras?: ICamera[];
  63418. /**
  63419. * Names of glTF extensions used somewhere in this asset
  63420. */
  63421. extensionsUsed?: string[];
  63422. /**
  63423. * Names of glTF extensions required to properly load this asset
  63424. */
  63425. extensionsRequired?: string[];
  63426. /**
  63427. * An array of images. An image defines data used to create a texture
  63428. */
  63429. images?: IImage[];
  63430. /**
  63431. * An array of materials. A material defines the appearance of a primitive
  63432. */
  63433. materials?: IMaterial[];
  63434. /**
  63435. * An array of meshes. A mesh is a set of primitives to be rendered
  63436. */
  63437. meshes?: IMesh[];
  63438. /**
  63439. * An array of nodes
  63440. */
  63441. nodes?: INode[];
  63442. /**
  63443. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63444. */
  63445. samplers?: ISampler[];
  63446. /**
  63447. * The index of the default scene
  63448. */
  63449. scene?: number;
  63450. /**
  63451. * An array of scenes
  63452. */
  63453. scenes?: IScene[];
  63454. /**
  63455. * An array of skins. A skin is defined by joints and matrices
  63456. */
  63457. skins?: ISkin[];
  63458. /**
  63459. * An array of textures
  63460. */
  63461. textures?: ITexture[];
  63462. }
  63463. /**
  63464. * Interface for glTF validation results
  63465. */
  63466. interface IGLTFValidationResults {
  63467. info: {
  63468. generator: string;
  63469. hasAnimations: boolean;
  63470. hasDefaultScene: boolean;
  63471. hasMaterials: boolean;
  63472. hasMorphTargets: boolean;
  63473. hasSkins: boolean;
  63474. hasTextures: boolean;
  63475. maxAttributesUsed: number;
  63476. primitivesCount: number
  63477. };
  63478. issues: {
  63479. messages: Array<string>;
  63480. numErrors: number;
  63481. numHints: number;
  63482. numInfos: number;
  63483. numWarnings: number;
  63484. truncated: boolean
  63485. };
  63486. mimeType: string;
  63487. uri: string;
  63488. validatedAt: string;
  63489. validatorVersion: string;
  63490. }
  63491. /**
  63492. * Interface for glTF validation options
  63493. */
  63494. interface IGLTFValidationOptions {
  63495. uri?: string;
  63496. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63497. validateAccessorData?: boolean;
  63498. maxIssues?: number;
  63499. ignoredIssues?: Array<string>;
  63500. severityOverrides?: Object;
  63501. }
  63502. /**
  63503. * glTF validator object Tyyings
  63504. */
  63505. interface IGLTFValidatorTypings {
  63506. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63507. }
  63508. }
  63509. /**
  63510. * Interface for glTF validation results
  63511. */
  63512. interface IGLTFValidationResults {
  63513. info: {
  63514. generator: string;
  63515. hasAnimations: boolean;
  63516. hasDefaultScene: boolean;
  63517. hasMaterials: boolean;
  63518. hasMorphTargets: boolean;
  63519. hasSkins: boolean;
  63520. hasTextures: boolean;
  63521. maxAttributesUsed: number;
  63522. primitivesCount: number
  63523. };
  63524. issues: {
  63525. messages: Array<string>;
  63526. numErrors: number;
  63527. numHints: number;
  63528. numInfos: number;
  63529. numWarnings: number;
  63530. truncated: boolean
  63531. };
  63532. mimeType: string;
  63533. uri: string;
  63534. validatedAt: string;
  63535. validatorVersion: string;
  63536. }
  63537. /**
  63538. * Interface for glTF validation options
  63539. */
  63540. interface IGLTFValidationOptions {
  63541. uri?: string;
  63542. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63543. validateAccessorData?: boolean;
  63544. maxIssues?: number;
  63545. ignoredIssues?: Array<string>;
  63546. severityOverrides?: Object;
  63547. }
  63548. /**
  63549. * glTF validator object Tyyings
  63550. */
  63551. interface IGLTFValidatorTypings {
  63552. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63553. }
  63554. declare module BABYLON {
  63555. /** @hidden */
  63556. export var cellPixelShader: {
  63557. name: string;
  63558. shader: string;
  63559. };
  63560. }
  63561. declare module BABYLON {
  63562. /** @hidden */
  63563. export var cellVertexShader: {
  63564. name: string;
  63565. shader: string;
  63566. };
  63567. }
  63568. declare module BABYLON {
  63569. export class CellMaterial extends BABYLON.PushMaterial {
  63570. private _diffuseTexture;
  63571. diffuseTexture: BABYLON.BaseTexture;
  63572. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63573. computeHighLevel: boolean;
  63574. private _disableLighting;
  63575. disableLighting: boolean;
  63576. private _maxSimultaneousLights;
  63577. maxSimultaneousLights: number;
  63578. private _renderId;
  63579. constructor(name: string, scene: BABYLON.Scene);
  63580. needAlphaBlending(): boolean;
  63581. needAlphaTesting(): boolean;
  63582. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63583. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63584. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63585. getAnimatables(): BABYLON.IAnimatable[];
  63586. getActiveTextures(): BABYLON.BaseTexture[];
  63587. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63588. dispose(forceDisposeEffect?: boolean): void;
  63589. getClassName(): string;
  63590. clone(name: string): CellMaterial;
  63591. serialize(): any;
  63592. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63593. }
  63594. }
  63595. declare module BABYLON {
  63596. export class CustomShaderStructure {
  63597. FragmentStore: string;
  63598. VertexStore: string;
  63599. constructor();
  63600. }
  63601. export class ShaderSpecialParts {
  63602. constructor();
  63603. Fragment_Begin: string;
  63604. Fragment_Definitions: string;
  63605. Fragment_MainBegin: string;
  63606. Fragment_Custom_Diffuse: string;
  63607. Fragment_Before_Lights: string;
  63608. Fragment_Before_Fog: string;
  63609. Fragment_Custom_Alpha: string;
  63610. Fragment_Before_FragColor: string;
  63611. Vertex_Begin: string;
  63612. Vertex_Definitions: string;
  63613. Vertex_MainBegin: string;
  63614. Vertex_Before_PositionUpdated: string;
  63615. Vertex_Before_NormalUpdated: string;
  63616. Vertex_MainEnd: string;
  63617. }
  63618. export class CustomMaterial extends BABYLON.StandardMaterial {
  63619. static ShaderIndexer: number;
  63620. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63621. FragmentShader: string;
  63622. VertexShader: string;
  63623. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63624. ReviewUniform(name: string, arr: string[]): string[];
  63625. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63626. constructor(name: string, scene: BABYLON.Scene);
  63627. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63628. Fragment_Begin(shaderPart: string): CustomMaterial;
  63629. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63630. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63631. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63632. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63633. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63634. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63635. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63636. Vertex_Begin(shaderPart: string): CustomMaterial;
  63637. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63638. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63639. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63640. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63641. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63642. }
  63643. }
  63644. declare module BABYLON {
  63645. export class ShaderAlebdoParts {
  63646. constructor();
  63647. Fragment_Begin: string;
  63648. Fragment_Definitions: string;
  63649. Fragment_MainBegin: string;
  63650. Fragment_Custom_Albedo: string;
  63651. Fragment_Before_Lights: string;
  63652. Fragment_Before_Fog: string;
  63653. Fragment_Custom_Alpha: string;
  63654. Fragment_Before_FragColor: string;
  63655. Vertex_Begin: string;
  63656. Vertex_Definitions: string;
  63657. Vertex_MainBegin: string;
  63658. Vertex_Before_PositionUpdated: string;
  63659. Vertex_Before_NormalUpdated: string;
  63660. Vertex_MainEnd: string;
  63661. }
  63662. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63663. static ShaderIndexer: number;
  63664. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63665. FragmentShader: string;
  63666. VertexShader: string;
  63667. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63668. ReviewUniform(name: string, arr: string[]): string[];
  63669. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63670. constructor(name: string, scene: BABYLON.Scene);
  63671. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63672. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63673. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63674. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63675. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63676. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63677. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63678. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63679. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63680. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63681. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63682. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63683. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63684. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63685. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63686. }
  63687. }
  63688. declare module BABYLON {
  63689. /** @hidden */
  63690. export var firePixelShader: {
  63691. name: string;
  63692. shader: string;
  63693. };
  63694. }
  63695. declare module BABYLON {
  63696. /** @hidden */
  63697. export var fireVertexShader: {
  63698. name: string;
  63699. shader: string;
  63700. };
  63701. }
  63702. declare module BABYLON {
  63703. export class FireMaterial extends BABYLON.PushMaterial {
  63704. private _diffuseTexture;
  63705. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63706. private _distortionTexture;
  63707. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63708. private _opacityTexture;
  63709. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63710. diffuseColor: BABYLON.Color3;
  63711. speed: number;
  63712. private _scaledDiffuse;
  63713. private _renderId;
  63714. private _lastTime;
  63715. constructor(name: string, scene: BABYLON.Scene);
  63716. needAlphaBlending(): boolean;
  63717. needAlphaTesting(): boolean;
  63718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63721. getAnimatables(): BABYLON.IAnimatable[];
  63722. getActiveTextures(): BABYLON.BaseTexture[];
  63723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63724. getClassName(): string;
  63725. dispose(forceDisposeEffect?: boolean): void;
  63726. clone(name: string): FireMaterial;
  63727. serialize(): any;
  63728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63729. }
  63730. }
  63731. declare module BABYLON {
  63732. /** @hidden */
  63733. export var furPixelShader: {
  63734. name: string;
  63735. shader: string;
  63736. };
  63737. }
  63738. declare module BABYLON {
  63739. /** @hidden */
  63740. export var furVertexShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module BABYLON {
  63746. export class FurMaterial extends BABYLON.PushMaterial {
  63747. private _diffuseTexture;
  63748. diffuseTexture: BABYLON.BaseTexture;
  63749. private _heightTexture;
  63750. heightTexture: BABYLON.BaseTexture;
  63751. diffuseColor: BABYLON.Color3;
  63752. furLength: number;
  63753. furAngle: number;
  63754. furColor: BABYLON.Color3;
  63755. furOffset: number;
  63756. furSpacing: number;
  63757. furGravity: BABYLON.Vector3;
  63758. furSpeed: number;
  63759. furDensity: number;
  63760. furOcclusion: number;
  63761. furTexture: BABYLON.DynamicTexture;
  63762. private _disableLighting;
  63763. disableLighting: boolean;
  63764. private _maxSimultaneousLights;
  63765. maxSimultaneousLights: number;
  63766. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63767. private _renderId;
  63768. private _furTime;
  63769. constructor(name: string, scene: BABYLON.Scene);
  63770. furTime: number;
  63771. needAlphaBlending(): boolean;
  63772. needAlphaTesting(): boolean;
  63773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63774. updateFur(): void;
  63775. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63776. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63777. getAnimatables(): BABYLON.IAnimatable[];
  63778. getActiveTextures(): BABYLON.BaseTexture[];
  63779. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63780. dispose(forceDisposeEffect?: boolean): void;
  63781. clone(name: string): FurMaterial;
  63782. serialize(): any;
  63783. getClassName(): string;
  63784. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63785. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63786. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /** @hidden */
  63791. export var gradientPixelShader: {
  63792. name: string;
  63793. shader: string;
  63794. };
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var gradientVertexShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. export class GradientMaterial extends BABYLON.PushMaterial {
  63805. private _maxSimultaneousLights;
  63806. maxSimultaneousLights: number;
  63807. topColor: BABYLON.Color3;
  63808. topColorAlpha: number;
  63809. bottomColor: BABYLON.Color3;
  63810. bottomColorAlpha: number;
  63811. offset: number;
  63812. scale: number;
  63813. smoothness: number;
  63814. private _disableLighting;
  63815. disableLighting: boolean;
  63816. private _renderId;
  63817. constructor(name: string, scene: BABYLON.Scene);
  63818. needAlphaBlending(): boolean;
  63819. needAlphaTesting(): boolean;
  63820. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63821. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63822. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63823. getAnimatables(): BABYLON.IAnimatable[];
  63824. dispose(forceDisposeEffect?: boolean): void;
  63825. clone(name: string): GradientMaterial;
  63826. serialize(): any;
  63827. getClassName(): string;
  63828. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63829. }
  63830. }
  63831. declare module BABYLON {
  63832. /** @hidden */
  63833. export var gridPixelShader: {
  63834. name: string;
  63835. shader: string;
  63836. };
  63837. }
  63838. declare module BABYLON {
  63839. /** @hidden */
  63840. export var gridVertexShader: {
  63841. name: string;
  63842. shader: string;
  63843. };
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * The grid materials allows you to wrap any shape with a grid.
  63848. * Colors are customizable.
  63849. */
  63850. export class GridMaterial extends BABYLON.PushMaterial {
  63851. /**
  63852. * Main color of the grid (e.g. between lines)
  63853. */
  63854. mainColor: BABYLON.Color3;
  63855. /**
  63856. * Color of the grid lines.
  63857. */
  63858. lineColor: BABYLON.Color3;
  63859. /**
  63860. * The scale of the grid compared to unit.
  63861. */
  63862. gridRatio: number;
  63863. /**
  63864. * Allows setting an offset for the grid lines.
  63865. */
  63866. gridOffset: BABYLON.Vector3;
  63867. /**
  63868. * The frequency of thicker lines.
  63869. */
  63870. majorUnitFrequency: number;
  63871. /**
  63872. * The visibility of minor units in the grid.
  63873. */
  63874. minorUnitVisibility: number;
  63875. /**
  63876. * The grid opacity outside of the lines.
  63877. */
  63878. opacity: number;
  63879. /**
  63880. * Determine RBG output is premultiplied by alpha value.
  63881. */
  63882. preMultiplyAlpha: boolean;
  63883. private _opacityTexture;
  63884. opacityTexture: BABYLON.BaseTexture;
  63885. private _gridControl;
  63886. private _renderId;
  63887. /**
  63888. * constructor
  63889. * @param name The name given to the material in order to identify it afterwards.
  63890. * @param scene The scene the material is used in.
  63891. */
  63892. constructor(name: string, scene: BABYLON.Scene);
  63893. /**
  63894. * Returns wehter or not the grid requires alpha blending.
  63895. */
  63896. needAlphaBlending(): boolean;
  63897. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63898. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63899. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63900. /**
  63901. * Dispose the material and its associated resources.
  63902. * @param forceDisposeEffect will also dispose the used effect when true
  63903. */
  63904. dispose(forceDisposeEffect?: boolean): void;
  63905. clone(name: string): GridMaterial;
  63906. serialize(): any;
  63907. getClassName(): string;
  63908. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63909. }
  63910. }
  63911. declare module BABYLON {
  63912. /** @hidden */
  63913. export var lavaPixelShader: {
  63914. name: string;
  63915. shader: string;
  63916. };
  63917. }
  63918. declare module BABYLON {
  63919. /** @hidden */
  63920. export var lavaVertexShader: {
  63921. name: string;
  63922. shader: string;
  63923. };
  63924. }
  63925. declare module BABYLON {
  63926. export class LavaMaterial extends BABYLON.PushMaterial {
  63927. private _diffuseTexture;
  63928. diffuseTexture: BABYLON.BaseTexture;
  63929. noiseTexture: BABYLON.BaseTexture;
  63930. fogColor: BABYLON.Color3;
  63931. speed: number;
  63932. movingSpeed: number;
  63933. lowFrequencySpeed: number;
  63934. fogDensity: number;
  63935. private _lastTime;
  63936. diffuseColor: BABYLON.Color3;
  63937. private _disableLighting;
  63938. disableLighting: boolean;
  63939. private _unlit;
  63940. unlit: boolean;
  63941. private _maxSimultaneousLights;
  63942. maxSimultaneousLights: number;
  63943. private _scaledDiffuse;
  63944. private _renderId;
  63945. constructor(name: string, scene: BABYLON.Scene);
  63946. needAlphaBlending(): boolean;
  63947. needAlphaTesting(): boolean;
  63948. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63949. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63950. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63951. getAnimatables(): BABYLON.IAnimatable[];
  63952. getActiveTextures(): BABYLON.BaseTexture[];
  63953. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63954. dispose(forceDisposeEffect?: boolean): void;
  63955. clone(name: string): LavaMaterial;
  63956. serialize(): any;
  63957. getClassName(): string;
  63958. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /** @hidden */
  63963. export var mixPixelShader: {
  63964. name: string;
  63965. shader: string;
  63966. };
  63967. }
  63968. declare module BABYLON {
  63969. /** @hidden */
  63970. export var mixVertexShader: {
  63971. name: string;
  63972. shader: string;
  63973. };
  63974. }
  63975. declare module BABYLON {
  63976. export class MixMaterial extends BABYLON.PushMaterial {
  63977. /**
  63978. * Mix textures
  63979. */
  63980. private _mixTexture1;
  63981. mixTexture1: BABYLON.BaseTexture;
  63982. private _mixTexture2;
  63983. mixTexture2: BABYLON.BaseTexture;
  63984. /**
  63985. * Diffuse textures
  63986. */
  63987. private _diffuseTexture1;
  63988. diffuseTexture1: BABYLON.Texture;
  63989. private _diffuseTexture2;
  63990. diffuseTexture2: BABYLON.Texture;
  63991. private _diffuseTexture3;
  63992. diffuseTexture3: BABYLON.Texture;
  63993. private _diffuseTexture4;
  63994. diffuseTexture4: BABYLON.Texture;
  63995. private _diffuseTexture5;
  63996. diffuseTexture5: BABYLON.Texture;
  63997. private _diffuseTexture6;
  63998. diffuseTexture6: BABYLON.Texture;
  63999. private _diffuseTexture7;
  64000. diffuseTexture7: BABYLON.Texture;
  64001. private _diffuseTexture8;
  64002. diffuseTexture8: BABYLON.Texture;
  64003. /**
  64004. * Uniforms
  64005. */
  64006. diffuseColor: BABYLON.Color3;
  64007. specularColor: BABYLON.Color3;
  64008. specularPower: number;
  64009. private _disableLighting;
  64010. disableLighting: boolean;
  64011. private _maxSimultaneousLights;
  64012. maxSimultaneousLights: number;
  64013. private _renderId;
  64014. constructor(name: string, scene: BABYLON.Scene);
  64015. needAlphaBlending(): boolean;
  64016. needAlphaTesting(): boolean;
  64017. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64018. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64019. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64020. getAnimatables(): BABYLON.IAnimatable[];
  64021. getActiveTextures(): BABYLON.BaseTexture[];
  64022. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64023. dispose(forceDisposeEffect?: boolean): void;
  64024. clone(name: string): MixMaterial;
  64025. serialize(): any;
  64026. getClassName(): string;
  64027. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64028. }
  64029. }
  64030. declare module BABYLON {
  64031. /** @hidden */
  64032. export var normalPixelShader: {
  64033. name: string;
  64034. shader: string;
  64035. };
  64036. }
  64037. declare module BABYLON {
  64038. /** @hidden */
  64039. export var normalVertexShader: {
  64040. name: string;
  64041. shader: string;
  64042. };
  64043. }
  64044. declare module BABYLON {
  64045. export class NormalMaterial extends BABYLON.PushMaterial {
  64046. private _diffuseTexture;
  64047. diffuseTexture: BABYLON.BaseTexture;
  64048. diffuseColor: BABYLON.Color3;
  64049. private _disableLighting;
  64050. disableLighting: boolean;
  64051. private _maxSimultaneousLights;
  64052. maxSimultaneousLights: number;
  64053. private _renderId;
  64054. constructor(name: string, scene: BABYLON.Scene);
  64055. needAlphaBlending(): boolean;
  64056. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64057. needAlphaTesting(): boolean;
  64058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64059. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64060. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64061. getAnimatables(): BABYLON.IAnimatable[];
  64062. getActiveTextures(): BABYLON.BaseTexture[];
  64063. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64064. dispose(forceDisposeEffect?: boolean): void;
  64065. clone(name: string): NormalMaterial;
  64066. serialize(): any;
  64067. getClassName(): string;
  64068. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64069. }
  64070. }
  64071. declare module BABYLON {
  64072. /** @hidden */
  64073. export var shadowOnlyPixelShader: {
  64074. name: string;
  64075. shader: string;
  64076. };
  64077. }
  64078. declare module BABYLON {
  64079. /** @hidden */
  64080. export var shadowOnlyVertexShader: {
  64081. name: string;
  64082. shader: string;
  64083. };
  64084. }
  64085. declare module BABYLON {
  64086. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64087. private _renderId;
  64088. private _activeLight;
  64089. constructor(name: string, scene: BABYLON.Scene);
  64090. shadowColor: BABYLON.Color3;
  64091. needAlphaBlending(): boolean;
  64092. needAlphaTesting(): boolean;
  64093. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64094. activeLight: BABYLON.IShadowLight;
  64095. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64096. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64097. clone(name: string): ShadowOnlyMaterial;
  64098. serialize(): any;
  64099. getClassName(): string;
  64100. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64101. }
  64102. }
  64103. declare module BABYLON {
  64104. /** @hidden */
  64105. export var simplePixelShader: {
  64106. name: string;
  64107. shader: string;
  64108. };
  64109. }
  64110. declare module BABYLON {
  64111. /** @hidden */
  64112. export var simpleVertexShader: {
  64113. name: string;
  64114. shader: string;
  64115. };
  64116. }
  64117. declare module BABYLON {
  64118. export class SimpleMaterial extends BABYLON.PushMaterial {
  64119. private _diffuseTexture;
  64120. diffuseTexture: BABYLON.BaseTexture;
  64121. diffuseColor: BABYLON.Color3;
  64122. private _disableLighting;
  64123. disableLighting: boolean;
  64124. private _maxSimultaneousLights;
  64125. maxSimultaneousLights: number;
  64126. private _renderId;
  64127. constructor(name: string, scene: BABYLON.Scene);
  64128. needAlphaBlending(): boolean;
  64129. needAlphaTesting(): boolean;
  64130. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64131. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64132. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64133. getAnimatables(): BABYLON.IAnimatable[];
  64134. getActiveTextures(): BABYLON.BaseTexture[];
  64135. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64136. dispose(forceDisposeEffect?: boolean): void;
  64137. clone(name: string): SimpleMaterial;
  64138. serialize(): any;
  64139. getClassName(): string;
  64140. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64141. }
  64142. }
  64143. declare module BABYLON {
  64144. /** @hidden */
  64145. export var skyPixelShader: {
  64146. name: string;
  64147. shader: string;
  64148. };
  64149. }
  64150. declare module BABYLON {
  64151. /** @hidden */
  64152. export var skyVertexShader: {
  64153. name: string;
  64154. shader: string;
  64155. };
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64160. * @see https://doc.babylonjs.com/extensions/sky
  64161. */
  64162. export class SkyMaterial extends BABYLON.PushMaterial {
  64163. /**
  64164. * Defines the overall luminance of sky in interval ]0, 1[.
  64165. */
  64166. luminance: number;
  64167. /**
  64168. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64169. */
  64170. turbidity: number;
  64171. /**
  64172. * Defines the sky appearance (light intensity).
  64173. */
  64174. rayleigh: number;
  64175. /**
  64176. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64177. */
  64178. mieCoefficient: number;
  64179. /**
  64180. * Defines the amount of haze particles following the Mie scattering theory.
  64181. */
  64182. mieDirectionalG: number;
  64183. /**
  64184. * Defines the distance of the sun according to the active scene camera.
  64185. */
  64186. distance: number;
  64187. /**
  64188. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64189. * "inclined".
  64190. */
  64191. inclination: number;
  64192. /**
  64193. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64194. * an object direction and a reference direction.
  64195. */
  64196. azimuth: number;
  64197. /**
  64198. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64199. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64200. */
  64201. sunPosition: BABYLON.Vector3;
  64202. /**
  64203. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64204. * .sunPosition property.
  64205. */
  64206. useSunPosition: boolean;
  64207. /**
  64208. * Defines an offset vector used to get a horizon offset.
  64209. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64210. */
  64211. cameraOffset: BABYLON.Vector3;
  64212. private _cameraPosition;
  64213. private _renderId;
  64214. /**
  64215. * Instantiates a new sky material.
  64216. * This material allows to create dynamic and texture free
  64217. * effects for skyboxes by taking care of the atmosphere state.
  64218. * @see https://doc.babylonjs.com/extensions/sky
  64219. * @param name Define the name of the material in the scene
  64220. * @param scene Define the scene the material belong to
  64221. */
  64222. constructor(name: string, scene: BABYLON.Scene);
  64223. /**
  64224. * Specifies if the material will require alpha blending
  64225. * @returns a boolean specifying if alpha blending is needed
  64226. */
  64227. needAlphaBlending(): boolean;
  64228. /**
  64229. * Specifies if this material should be rendered in alpha test mode
  64230. * @returns false as the sky material doesn't need alpha testing.
  64231. */
  64232. needAlphaTesting(): boolean;
  64233. /**
  64234. * Get the texture used for alpha test purpose.
  64235. * @returns null as the sky material has no texture.
  64236. */
  64237. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64238. /**
  64239. * Get if the submesh is ready to be used and all its information available.
  64240. * Child classes can use it to update shaders
  64241. * @param mesh defines the mesh to check
  64242. * @param subMesh defines which submesh to check
  64243. * @param useInstances specifies that instances should be used
  64244. * @returns a boolean indicating that the submesh is ready or not
  64245. */
  64246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64247. /**
  64248. * Binds the submesh to this material by preparing the effect and shader to draw
  64249. * @param world defines the world transformation matrix
  64250. * @param mesh defines the mesh containing the submesh
  64251. * @param subMesh defines the submesh to bind the material to
  64252. */
  64253. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64254. /**
  64255. * Get the list of animatables in the material.
  64256. * @returns the list of animatables object used in the material
  64257. */
  64258. getAnimatables(): BABYLON.IAnimatable[];
  64259. /**
  64260. * Disposes the material
  64261. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64262. */
  64263. dispose(forceDisposeEffect?: boolean): void;
  64264. /**
  64265. * Makes a duplicate of the material, and gives it a new name
  64266. * @param name defines the new name for the duplicated material
  64267. * @returns the cloned material
  64268. */
  64269. clone(name: string): SkyMaterial;
  64270. /**
  64271. * Serializes this material in a JSON representation
  64272. * @returns the serialized material object
  64273. */
  64274. serialize(): any;
  64275. /**
  64276. * Gets the current class name of the material e.g. "SkyMaterial"
  64277. * Mainly use in serialization.
  64278. * @returns the class name
  64279. */
  64280. getClassName(): string;
  64281. /**
  64282. * Creates a sky material from parsed material data
  64283. * @param source defines the JSON representation of the material
  64284. * @param scene defines the hosting scene
  64285. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64286. * @returns a new sky material
  64287. */
  64288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /** @hidden */
  64293. export var terrainPixelShader: {
  64294. name: string;
  64295. shader: string;
  64296. };
  64297. }
  64298. declare module BABYLON {
  64299. /** @hidden */
  64300. export var terrainVertexShader: {
  64301. name: string;
  64302. shader: string;
  64303. };
  64304. }
  64305. declare module BABYLON {
  64306. export class TerrainMaterial extends BABYLON.PushMaterial {
  64307. private _mixTexture;
  64308. mixTexture: BABYLON.BaseTexture;
  64309. private _diffuseTexture1;
  64310. diffuseTexture1: BABYLON.Texture;
  64311. private _diffuseTexture2;
  64312. diffuseTexture2: BABYLON.Texture;
  64313. private _diffuseTexture3;
  64314. diffuseTexture3: BABYLON.Texture;
  64315. private _bumpTexture1;
  64316. bumpTexture1: BABYLON.Texture;
  64317. private _bumpTexture2;
  64318. bumpTexture2: BABYLON.Texture;
  64319. private _bumpTexture3;
  64320. bumpTexture3: BABYLON.Texture;
  64321. diffuseColor: BABYLON.Color3;
  64322. specularColor: BABYLON.Color3;
  64323. specularPower: number;
  64324. private _disableLighting;
  64325. disableLighting: boolean;
  64326. private _maxSimultaneousLights;
  64327. maxSimultaneousLights: number;
  64328. private _renderId;
  64329. constructor(name: string, scene: BABYLON.Scene);
  64330. needAlphaBlending(): boolean;
  64331. needAlphaTesting(): boolean;
  64332. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64333. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64334. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64335. getAnimatables(): BABYLON.IAnimatable[];
  64336. getActiveTextures(): BABYLON.BaseTexture[];
  64337. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64338. dispose(forceDisposeEffect?: boolean): void;
  64339. clone(name: string): TerrainMaterial;
  64340. serialize(): any;
  64341. getClassName(): string;
  64342. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64343. }
  64344. }
  64345. declare module BABYLON {
  64346. /** @hidden */
  64347. export var triplanarPixelShader: {
  64348. name: string;
  64349. shader: string;
  64350. };
  64351. }
  64352. declare module BABYLON {
  64353. /** @hidden */
  64354. export var triplanarVertexShader: {
  64355. name: string;
  64356. shader: string;
  64357. };
  64358. }
  64359. declare module BABYLON {
  64360. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64361. mixTexture: BABYLON.BaseTexture;
  64362. private _diffuseTextureX;
  64363. diffuseTextureX: BABYLON.BaseTexture;
  64364. private _diffuseTextureY;
  64365. diffuseTextureY: BABYLON.BaseTexture;
  64366. private _diffuseTextureZ;
  64367. diffuseTextureZ: BABYLON.BaseTexture;
  64368. private _normalTextureX;
  64369. normalTextureX: BABYLON.BaseTexture;
  64370. private _normalTextureY;
  64371. normalTextureY: BABYLON.BaseTexture;
  64372. private _normalTextureZ;
  64373. normalTextureZ: BABYLON.BaseTexture;
  64374. tileSize: number;
  64375. diffuseColor: BABYLON.Color3;
  64376. specularColor: BABYLON.Color3;
  64377. specularPower: number;
  64378. private _disableLighting;
  64379. disableLighting: boolean;
  64380. private _maxSimultaneousLights;
  64381. maxSimultaneousLights: number;
  64382. private _renderId;
  64383. constructor(name: string, scene: BABYLON.Scene);
  64384. needAlphaBlending(): boolean;
  64385. needAlphaTesting(): boolean;
  64386. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64387. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64388. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64389. getAnimatables(): BABYLON.IAnimatable[];
  64390. getActiveTextures(): BABYLON.BaseTexture[];
  64391. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64392. dispose(forceDisposeEffect?: boolean): void;
  64393. clone(name: string): TriPlanarMaterial;
  64394. serialize(): any;
  64395. getClassName(): string;
  64396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64397. }
  64398. }
  64399. declare module BABYLON {
  64400. /** @hidden */
  64401. export var waterPixelShader: {
  64402. name: string;
  64403. shader: string;
  64404. };
  64405. }
  64406. declare module BABYLON {
  64407. /** @hidden */
  64408. export var waterVertexShader: {
  64409. name: string;
  64410. shader: string;
  64411. };
  64412. }
  64413. declare module BABYLON {
  64414. export class WaterMaterial extends BABYLON.PushMaterial {
  64415. renderTargetSize: BABYLON.Vector2;
  64416. private _bumpTexture;
  64417. bumpTexture: BABYLON.BaseTexture;
  64418. diffuseColor: BABYLON.Color3;
  64419. specularColor: BABYLON.Color3;
  64420. specularPower: number;
  64421. private _disableLighting;
  64422. disableLighting: boolean;
  64423. private _maxSimultaneousLights;
  64424. maxSimultaneousLights: number;
  64425. /**
  64426. * @param {number}: Represents the wind force
  64427. */
  64428. windForce: number;
  64429. /**
  64430. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64431. */
  64432. windDirection: BABYLON.Vector2;
  64433. /**
  64434. * @param {number}: Wave height, represents the height of the waves
  64435. */
  64436. waveHeight: number;
  64437. /**
  64438. * @param {number}: Bump height, represents the bump height related to the bump map
  64439. */
  64440. bumpHeight: number;
  64441. /**
  64442. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64443. */
  64444. private _bumpSuperimpose;
  64445. bumpSuperimpose: boolean;
  64446. /**
  64447. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64448. */
  64449. private _fresnelSeparate;
  64450. fresnelSeparate: boolean;
  64451. /**
  64452. * @param {boolean}: bump Waves modify the reflection.
  64453. */
  64454. private _bumpAffectsReflection;
  64455. bumpAffectsReflection: boolean;
  64456. /**
  64457. * @param {number}: The water color blended with the refraction (near)
  64458. */
  64459. waterColor: BABYLON.Color3;
  64460. /**
  64461. * @param {number}: The blend factor related to the water color
  64462. */
  64463. colorBlendFactor: number;
  64464. /**
  64465. * @param {number}: The water color blended with the reflection (far)
  64466. */
  64467. waterColor2: BABYLON.Color3;
  64468. /**
  64469. * @param {number}: The blend factor related to the water color (reflection, far)
  64470. */
  64471. colorBlendFactor2: number;
  64472. /**
  64473. * @param {number}: Represents the maximum length of a wave
  64474. */
  64475. waveLength: number;
  64476. /**
  64477. * @param {number}: Defines the waves speed
  64478. */
  64479. waveSpeed: number;
  64480. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64481. private _mesh;
  64482. private _refractionRTT;
  64483. private _reflectionRTT;
  64484. private _reflectionTransform;
  64485. private _lastTime;
  64486. private _lastDeltaTime;
  64487. private _renderId;
  64488. private _useLogarithmicDepth;
  64489. private _waitingRenderList;
  64490. /**
  64491. * Gets a boolean indicating that current material needs to register RTT
  64492. */
  64493. readonly hasRenderTargetTextures: boolean;
  64494. /**
  64495. * Constructor
  64496. */
  64497. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64498. useLogarithmicDepth: boolean;
  64499. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64500. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64501. addToRenderList(node: any): void;
  64502. enableRenderTargets(enable: boolean): void;
  64503. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64504. readonly renderTargetsEnabled: boolean;
  64505. needAlphaBlending(): boolean;
  64506. needAlphaTesting(): boolean;
  64507. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64508. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64509. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64510. private _createRenderTargets;
  64511. getAnimatables(): BABYLON.IAnimatable[];
  64512. getActiveTextures(): BABYLON.BaseTexture[];
  64513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64514. dispose(forceDisposeEffect?: boolean): void;
  64515. clone(name: string): WaterMaterial;
  64516. serialize(): any;
  64517. getClassName(): string;
  64518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64519. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64520. }
  64521. }
  64522. declare module BABYLON {
  64523. /** @hidden */
  64524. export var asciiartPixelShader: {
  64525. name: string;
  64526. shader: string;
  64527. };
  64528. }
  64529. declare module BABYLON {
  64530. /**
  64531. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64532. *
  64533. * It basically takes care rendering the font front the given font size to a texture.
  64534. * This is used later on in the postprocess.
  64535. */
  64536. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64537. private _font;
  64538. private _text;
  64539. private _charSize;
  64540. /**
  64541. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64542. */
  64543. readonly charSize: number;
  64544. /**
  64545. * Create a new instance of the Ascii Art FontTexture class
  64546. * @param name the name of the texture
  64547. * @param font the font to use, use the W3C CSS notation
  64548. * @param text the caracter set to use in the rendering.
  64549. * @param scene the scene that owns the texture
  64550. */
  64551. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64552. /**
  64553. * Gets the max char width of a font.
  64554. * @param font the font to use, use the W3C CSS notation
  64555. * @return the max char width
  64556. */
  64557. private getFontWidth;
  64558. /**
  64559. * Gets the max char height of a font.
  64560. * @param font the font to use, use the W3C CSS notation
  64561. * @return the max char height
  64562. */
  64563. private getFontHeight;
  64564. /**
  64565. * Clones the current AsciiArtTexture.
  64566. * @return the clone of the texture.
  64567. */
  64568. clone(): AsciiArtFontTexture;
  64569. /**
  64570. * Parses a json object representing the texture and returns an instance of it.
  64571. * @param source the source JSON representation
  64572. * @param scene the scene to create the texture for
  64573. * @return the parsed texture
  64574. */
  64575. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64576. }
  64577. /**
  64578. * Option available in the Ascii Art Post Process.
  64579. */
  64580. export interface IAsciiArtPostProcessOptions {
  64581. /**
  64582. * The font to use following the w3c font definition.
  64583. */
  64584. font?: string;
  64585. /**
  64586. * The character set to use in the postprocess.
  64587. */
  64588. characterSet?: string;
  64589. /**
  64590. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64591. * This number is defined between 0 and 1;
  64592. */
  64593. mixToTile?: number;
  64594. /**
  64595. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64596. * This number is defined between 0 and 1;
  64597. */
  64598. mixToNormal?: number;
  64599. }
  64600. /**
  64601. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64602. *
  64603. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64604. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64605. */
  64606. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64607. /**
  64608. * The font texture used to render the char in the post process.
  64609. */
  64610. private _asciiArtFontTexture;
  64611. /**
  64612. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64613. * This number is defined between 0 and 1;
  64614. */
  64615. mixToTile: number;
  64616. /**
  64617. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64618. * This number is defined between 0 and 1;
  64619. */
  64620. mixToNormal: number;
  64621. /**
  64622. * Instantiates a new Ascii Art Post Process.
  64623. * @param name the name to give to the postprocess
  64624. * @camera the camera to apply the post process to.
  64625. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64626. */
  64627. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64628. }
  64629. }
  64630. declare module BABYLON {
  64631. /** @hidden */
  64632. export var digitalrainPixelShader: {
  64633. name: string;
  64634. shader: string;
  64635. };
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64640. *
  64641. * It basically takes care rendering the font front the given font size to a texture.
  64642. * This is used later on in the postprocess.
  64643. */
  64644. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64645. private _font;
  64646. private _text;
  64647. private _charSize;
  64648. /**
  64649. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64650. */
  64651. readonly charSize: number;
  64652. /**
  64653. * Create a new instance of the Digital Rain FontTexture class
  64654. * @param name the name of the texture
  64655. * @param font the font to use, use the W3C CSS notation
  64656. * @param text the caracter set to use in the rendering.
  64657. * @param scene the scene that owns the texture
  64658. */
  64659. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64660. /**
  64661. * Gets the max char width of a font.
  64662. * @param font the font to use, use the W3C CSS notation
  64663. * @return the max char width
  64664. */
  64665. private getFontWidth;
  64666. /**
  64667. * Gets the max char height of a font.
  64668. * @param font the font to use, use the W3C CSS notation
  64669. * @return the max char height
  64670. */
  64671. private getFontHeight;
  64672. /**
  64673. * Clones the current DigitalRainFontTexture.
  64674. * @return the clone of the texture.
  64675. */
  64676. clone(): DigitalRainFontTexture;
  64677. /**
  64678. * Parses a json object representing the texture and returns an instance of it.
  64679. * @param source the source JSON representation
  64680. * @param scene the scene to create the texture for
  64681. * @return the parsed texture
  64682. */
  64683. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64684. }
  64685. /**
  64686. * Option available in the Digital Rain Post Process.
  64687. */
  64688. export interface IDigitalRainPostProcessOptions {
  64689. /**
  64690. * The font to use following the w3c font definition.
  64691. */
  64692. font?: string;
  64693. /**
  64694. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64695. * This number is defined between 0 and 1;
  64696. */
  64697. mixToTile?: number;
  64698. /**
  64699. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64700. * This number is defined between 0 and 1;
  64701. */
  64702. mixToNormal?: number;
  64703. }
  64704. /**
  64705. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64706. *
  64707. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64708. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64709. */
  64710. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64711. /**
  64712. * The font texture used to render the char in the post process.
  64713. */
  64714. private _digitalRainFontTexture;
  64715. /**
  64716. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  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 digital rain.
  64722. * This number is defined between 0 and 1;
  64723. */
  64724. mixToNormal: number;
  64725. /**
  64726. * Instantiates a new Digital Rain Post Process.
  64727. * @param name the name to give to the postprocess
  64728. * @camera the camera to apply the post process to.
  64729. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64730. */
  64731. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64732. }
  64733. }
  64734. declare module BABYLON {
  64735. /** @hidden */
  64736. export var oceanPostProcessPixelShader: {
  64737. name: string;
  64738. shader: string;
  64739. };
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * Option available in the Ocean Post Process.
  64744. */
  64745. export interface IOceanPostProcessOptions {
  64746. /**
  64747. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64748. */
  64749. reflectionSize?: number | {
  64750. width: number;
  64751. height: number;
  64752. } | {
  64753. ratio: number;
  64754. };
  64755. /**
  64756. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64757. */
  64758. refractionSize?: number | {
  64759. width: number;
  64760. height: number;
  64761. } | {
  64762. ratio: number;
  64763. };
  64764. }
  64765. /**
  64766. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64767. *
  64768. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64769. * Example usage:
  64770. * var pp = new OceanPostProcess("myOcean", camera);
  64771. * pp.reflectionEnabled = true;
  64772. * pp.refractionEnabled = true;
  64773. */
  64774. export class OceanPostProcess extends BABYLON.PostProcess {
  64775. /**
  64776. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64777. */
  64778. /**
  64779. * Sets weither or not the real-time reflection is enabled on the ocean.
  64780. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64781. */
  64782. reflectionEnabled: boolean;
  64783. /**
  64784. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64785. */
  64786. /**
  64787. * Sets weither or not the real-time refraction is enabled on the ocean.
  64788. * Is set to true, the refraction render target texture will be used as refraction texture.
  64789. */
  64790. refractionEnabled: boolean;
  64791. /**
  64792. * Gets wether or not the post-processes is supported by the running hardware.
  64793. * This requires draw buffer supports.
  64794. */
  64795. readonly isSupported: boolean;
  64796. /**
  64797. * This is the reflection mirror texture used to display reflections on the ocean.
  64798. * By default, render list is empty.
  64799. */
  64800. reflectionTexture: BABYLON.MirrorTexture;
  64801. /**
  64802. * This is the refraction render target texture used to display refraction on the ocean.
  64803. * By default, render list is empty.
  64804. */
  64805. refractionTexture: BABYLON.RenderTargetTexture;
  64806. private _time;
  64807. private _cameraRotation;
  64808. private _cameraViewMatrix;
  64809. private _reflectionEnabled;
  64810. private _refractionEnabled;
  64811. private _geometryRenderer;
  64812. /**
  64813. * Instantiates a new Ocean Post Process.
  64814. * @param name the name to give to the postprocess.
  64815. * @camera the camera to apply the post process to.
  64816. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64817. */
  64818. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64819. /**
  64820. * Returns the appropriate defines according to the current configuration.
  64821. */
  64822. private _getDefines;
  64823. /**
  64824. * Computes the current camera rotation as the shader requires a camera rotation.
  64825. */
  64826. private _computeCameraRotation;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /** @hidden */
  64831. export var brickProceduralTexturePixelShader: {
  64832. name: string;
  64833. shader: string;
  64834. };
  64835. }
  64836. declare module BABYLON {
  64837. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64838. private _numberOfBricksHeight;
  64839. private _numberOfBricksWidth;
  64840. private _jointColor;
  64841. private _brickColor;
  64842. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64843. updateShaderUniforms(): void;
  64844. numberOfBricksHeight: number;
  64845. numberOfBricksWidth: number;
  64846. jointColor: BABYLON.Color3;
  64847. brickColor: BABYLON.Color3;
  64848. /**
  64849. * Serializes this brick procedural texture
  64850. * @returns a serialized brick procedural texture object
  64851. */
  64852. serialize(): any;
  64853. /**
  64854. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64855. * @param parsedTexture defines parsed texture data
  64856. * @param scene defines the current scene
  64857. * @param rootUrl defines the root URL containing brick procedural texture information
  64858. * @returns a parsed Brick Procedural BABYLON.Texture
  64859. */
  64860. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. /** @hidden */
  64865. export var cloudProceduralTexturePixelShader: {
  64866. name: string;
  64867. shader: string;
  64868. };
  64869. }
  64870. declare module BABYLON {
  64871. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64872. private _skyColor;
  64873. private _cloudColor;
  64874. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64875. updateShaderUniforms(): void;
  64876. skyColor: BABYLON.Color4;
  64877. cloudColor: BABYLON.Color4;
  64878. /**
  64879. * Serializes this cloud procedural texture
  64880. * @returns a serialized cloud procedural texture object
  64881. */
  64882. serialize(): any;
  64883. /**
  64884. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64885. * @param parsedTexture defines parsed texture data
  64886. * @param scene defines the current scene
  64887. * @param rootUrl defines the root URL containing cloud procedural texture information
  64888. * @returns a parsed Cloud Procedural BABYLON.Texture
  64889. */
  64890. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64891. }
  64892. }
  64893. declare module BABYLON {
  64894. /** @hidden */
  64895. export var fireProceduralTexturePixelShader: {
  64896. name: string;
  64897. shader: string;
  64898. };
  64899. }
  64900. declare module BABYLON {
  64901. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64902. private _time;
  64903. private _speed;
  64904. private _autoGenerateTime;
  64905. private _fireColors;
  64906. private _alphaThreshold;
  64907. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64908. updateShaderUniforms(): void;
  64909. render(useCameraPostProcess?: boolean): void;
  64910. static readonly PurpleFireColors: BABYLON.Color3[];
  64911. static readonly GreenFireColors: BABYLON.Color3[];
  64912. static readonly RedFireColors: BABYLON.Color3[];
  64913. static readonly BlueFireColors: BABYLON.Color3[];
  64914. autoGenerateTime: boolean;
  64915. fireColors: BABYLON.Color3[];
  64916. time: number;
  64917. speed: BABYLON.Vector2;
  64918. alphaThreshold: number;
  64919. /**
  64920. * Serializes this fire procedural texture
  64921. * @returns a serialized fire procedural texture object
  64922. */
  64923. serialize(): any;
  64924. /**
  64925. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64926. * @param parsedTexture defines parsed texture data
  64927. * @param scene defines the current scene
  64928. * @param rootUrl defines the root URL containing fire procedural texture information
  64929. * @returns a parsed Fire Procedural BABYLON.Texture
  64930. */
  64931. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64932. }
  64933. }
  64934. declare module BABYLON {
  64935. /** @hidden */
  64936. export var grassProceduralTexturePixelShader: {
  64937. name: string;
  64938. shader: string;
  64939. };
  64940. }
  64941. declare module BABYLON {
  64942. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64943. private _grassColors;
  64944. private _groundColor;
  64945. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64946. updateShaderUniforms(): void;
  64947. grassColors: BABYLON.Color3[];
  64948. groundColor: BABYLON.Color3;
  64949. /**
  64950. * Serializes this grass procedural texture
  64951. * @returns a serialized grass procedural texture object
  64952. */
  64953. serialize(): any;
  64954. /**
  64955. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64956. * @param parsedTexture defines parsed texture data
  64957. * @param scene defines the current scene
  64958. * @param rootUrl defines the root URL containing grass procedural texture information
  64959. * @returns a parsed Grass Procedural BABYLON.Texture
  64960. */
  64961. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64962. }
  64963. }
  64964. declare module BABYLON {
  64965. /** @hidden */
  64966. export var marbleProceduralTexturePixelShader: {
  64967. name: string;
  64968. shader: string;
  64969. };
  64970. }
  64971. declare module BABYLON {
  64972. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64973. private _numberOfTilesHeight;
  64974. private _numberOfTilesWidth;
  64975. private _amplitude;
  64976. private _jointColor;
  64977. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64978. updateShaderUniforms(): void;
  64979. numberOfTilesHeight: number;
  64980. amplitude: number;
  64981. numberOfTilesWidth: number;
  64982. jointColor: BABYLON.Color3;
  64983. /**
  64984. * Serializes this marble procedural texture
  64985. * @returns a serialized marble procedural texture object
  64986. */
  64987. serialize(): any;
  64988. /**
  64989. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64990. * @param parsedTexture defines parsed texture data
  64991. * @param scene defines the current scene
  64992. * @param rootUrl defines the root URL containing marble procedural texture information
  64993. * @returns a parsed Marble Procedural BABYLON.Texture
  64994. */
  64995. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64996. }
  64997. }
  64998. declare module BABYLON {
  64999. /** @hidden */
  65000. export var normalMapProceduralTexturePixelShader: {
  65001. name: string;
  65002. shader: string;
  65003. };
  65004. }
  65005. declare module BABYLON {
  65006. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65007. private _baseTexture;
  65008. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65009. updateShaderUniforms(): void;
  65010. render(useCameraPostProcess?: boolean): void;
  65011. resize(size: any, generateMipMaps: any): void;
  65012. baseTexture: BABYLON.Texture;
  65013. /**
  65014. * Serializes this normal map procedural texture
  65015. * @returns a serialized normal map procedural texture object
  65016. */
  65017. serialize(): any;
  65018. /**
  65019. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65020. * @param parsedTexture defines parsed texture data
  65021. * @param scene defines the current scene
  65022. * @param rootUrl defines the root URL containing normal map procedural texture information
  65023. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65024. */
  65025. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65026. }
  65027. }
  65028. declare module BABYLON {
  65029. /** @hidden */
  65030. export var perlinNoiseProceduralTexturePixelShader: {
  65031. name: string;
  65032. shader: string;
  65033. };
  65034. }
  65035. declare module BABYLON {
  65036. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65037. time: number;
  65038. timeScale: number;
  65039. translationSpeed: number;
  65040. private _currentTranslation;
  65041. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65042. updateShaderUniforms(): void;
  65043. render(useCameraPostProcess?: boolean): void;
  65044. resize(size: any, generateMipMaps: any): void;
  65045. /**
  65046. * Serializes this perlin noise procedural texture
  65047. * @returns a serialized perlin noise procedural texture object
  65048. */
  65049. serialize(): any;
  65050. /**
  65051. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise 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 perlin noise procedural texture information
  65055. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65056. */
  65057. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /** @hidden */
  65062. export var roadProceduralTexturePixelShader: {
  65063. name: string;
  65064. shader: string;
  65065. };
  65066. }
  65067. declare module BABYLON {
  65068. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65069. private _roadColor;
  65070. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65071. updateShaderUniforms(): void;
  65072. roadColor: BABYLON.Color3;
  65073. /**
  65074. * Serializes this road procedural texture
  65075. * @returns a serialized road procedural texture object
  65076. */
  65077. serialize(): any;
  65078. /**
  65079. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65080. * @param parsedTexture defines parsed texture data
  65081. * @param scene defines the current scene
  65082. * @param rootUrl defines the root URL containing road procedural texture information
  65083. * @returns a parsed Road Procedural BABYLON.Texture
  65084. */
  65085. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65086. }
  65087. }
  65088. declare module BABYLON {
  65089. /** @hidden */
  65090. export var starfieldProceduralTexturePixelShader: {
  65091. name: string;
  65092. shader: string;
  65093. };
  65094. }
  65095. declare module BABYLON {
  65096. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65097. private _time;
  65098. private _alpha;
  65099. private _beta;
  65100. private _zoom;
  65101. private _formuparam;
  65102. private _stepsize;
  65103. private _tile;
  65104. private _brightness;
  65105. private _darkmatter;
  65106. private _distfading;
  65107. private _saturation;
  65108. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65109. updateShaderUniforms(): void;
  65110. time: number;
  65111. alpha: number;
  65112. beta: number;
  65113. formuparam: number;
  65114. stepsize: number;
  65115. zoom: number;
  65116. tile: number;
  65117. brightness: number;
  65118. darkmatter: number;
  65119. distfading: number;
  65120. saturation: number;
  65121. /**
  65122. * Serializes this starfield procedural texture
  65123. * @returns a serialized starfield procedural texture object
  65124. */
  65125. serialize(): any;
  65126. /**
  65127. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65128. * @param parsedTexture defines parsed texture data
  65129. * @param scene defines the current scene
  65130. * @param rootUrl defines the root URL containing startfield procedural texture information
  65131. * @returns a parsed Starfield Procedural BABYLON.Texture
  65132. */
  65133. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /** @hidden */
  65138. export var woodProceduralTexturePixelShader: {
  65139. name: string;
  65140. shader: string;
  65141. };
  65142. }
  65143. declare module BABYLON {
  65144. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65145. private _ampScale;
  65146. private _woodColor;
  65147. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65148. updateShaderUniforms(): void;
  65149. ampScale: number;
  65150. woodColor: BABYLON.Color3;
  65151. /**
  65152. * Serializes this wood procedural texture
  65153. * @returns a serialized wood procedural texture object
  65154. */
  65155. serialize(): any;
  65156. /**
  65157. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65158. * @param parsedTexture defines parsed texture data
  65159. * @param scene defines the current scene
  65160. * @param rootUrl defines the root URL containing wood procedural texture information
  65161. * @returns a parsed Wood Procedural BABYLON.Texture
  65162. */
  65163. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65164. }
  65165. }